aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-07-21 12:06:52 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-21 12:06:52 -0700
commit18c58c7268e830d5684b97cb010fa1468b16edf9 (patch)
tree419f1ec698db5483bc66cff89a0b6f2b3fe58161 /src
parente617e1525916d7ee684142728c0905828caf49da (diff)
Possible fix Moto E compilation failure
It appears that the Adreno compiler is even more twitchy about gl_FragCoord handling than expected. BUG=skia:4078 Review URL: https://codereview.chromium.org/1246773003
Diffstat (limited to 'src')
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index c2eb09d85a..621243f53b 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -159,6 +159,7 @@ const char* GrGLFragmentShaderBuilder::fragmentPosition() {
}
return "gl_FragCoord";
} else {
+ static const char* kTempName = "tmpXYFragCoord";
static const char* kCoordName = "fragCoordYDown";
if (!fSetupFragPosition) {
// temporarily change the stage index because we're inserting non-stage code.
@@ -173,11 +174,14 @@ const char* GrGLFragmentShaderBuilder::fragmentPosition() {
"RTHeight",
&rtHeightName);
- // Using glFragCoord.zw for the last two components tickles an Adreno driver bug that
- // causes programs to fail to link. Making this function return a vec2() didn't fix the
- // problem but using 1.0 for the last two components does.
- this->codePrependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_FragCoord.y, 1.0, "
- "1.0);\n", kCoordName, rtHeightName);
+ // The Adreno compiler seems to be very touchy about access to "gl_FragCoord".
+ // Accessing glFragCoord.zw can cause a program to fail to link. Additionally,
+ // depending on the surrounding code, accessing .xy with a uniform involved can
+ // do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand
+ // (and only accessing .xy) seems to "fix" things.
+ this->codePrependf("\tvec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n",
+ kCoordName, kTempName, rtHeightName, kTempName);
+ this->codePrependf("vec2 %s = gl_FragCoord.xy;", kTempName);
fSetupFragPosition = true;
}
SkASSERT(fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());