Repository navigation
fix: declare default float precision for gles fragment shaders - #244
Merged
Merged
Conversation
- glsl es gives fragment shaders no default float precision, so sources that never declare one are rejected by strict compilers such as angle, webgl and some mobile drivers even though lenient drivers accept them - inject a mediump default when the source declares no precision, kept behind an ifdef GL_ES guard so desktop glsl is unaffected
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GLSL ES defines no default float precision for fragment shaders, unlike vertex shaders. A fragment shader that never declares one relies on the driver being lenient. Strict compilers reject it outright: ANGLE reports "No precision specified for (float)", WebGL validation does the same, and some mobile drivers behave likewise. This bites both in-tree shaders that carry no precision statement (for example the generated gaussian blur fragment shaders) and any custom shader passed through
Filter::CreateWithFragmentShaderString.Fix
Before compiling a fragment shader in
GPUPixelGLProgram::InitWithShaderString, prependprecision mediump float;when the source contains no precision declaration. The injected line sits behind#ifdef GL_ES, so desktop GLSL compilers that predate precision qualifiers never see it. Shaders that already declare precision, including all per-declaration qualified ones, are passed through untouched, so rendering output is unchanged for them.Verification
script/build_macos.shbuilds clean (Release, library plus desktop demo)clang-format --dry-run --Werroris clean for the changed lines