Remove unnecessary gl_FragCoord workaround
Bug: skia:
Change-Id: I04b6cbfe083c32a25205e04a4b15672d4b678a9c
Reviewed-on: https://skia-review.googlesource.com/c/174063
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index de239fc..1f2d8f3 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2604,7 +2604,9 @@
#endif
// We've seen Adreno 3xx devices produce incorrect (flipped) values for gl_FragCoord, in some
- // (rare) situations. It's sporadic, and mostly on older drivers.
+ // (rare) situations. It's sporadic, and mostly on older drivers. Additionally, old Adreno
+ // compilers (see crbug.com/skia/4078) crash when accessing .zw of gl_FragCoord, so just bypass
+ // using gl_FragCoord at all to get around it.
if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) {
shaderCaps->fCanUseFragCoord = false;
}
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 26bda18..c231626 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -756,17 +756,9 @@
this->write("gl_FragCoord");
} else {
if (!fSetupFragPositionLocal) {
- // 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 float2 beforehand
- // (and only accessing .xy) seems to "fix" things.
- const char* precision = usesPrecisionModifiers() ? "highp " : "";
- fFunctionHeader += precision;
- fFunctionHeader += " vec2 _sktmpCoord = gl_FragCoord.xy;\n";
- fFunctionHeader += precision;
- fFunctionHeader += " vec4 sk_FragCoord = vec4(_sktmpCoord.x, " SKSL_RTHEIGHT_NAME
- " - _sktmpCoord.y, 1.0, 1.0);\n";
+ fFunctionHeader += usesPrecisionModifiers() ? "highp " : "";
+ fFunctionHeader += " vec4 sk_FragCoord = vec4(gl_FragCoord.x, " SKSL_RTHEIGHT_NAME
+ " - gl_FragCoord.y, gl_FragCoord.z, gl_FragCoord.w);\n";
fSetupFragPositionLocal = true;
}
this->write("sk_FragCoord");
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index a9f1abe..8d12dcc 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -1147,8 +1147,8 @@
"uniform float u_skRTHeight;\n"
"out vec4 sk_FragColor;\n"
"void main() {\n"
- " vec2 _sktmpCoord = gl_FragCoord.xy;\n"
- " vec4 sk_FragCoord = vec4(_sktmpCoord.x, u_skRTHeight - _sktmpCoord.y, 1.0, 1.0);\n"
+ " vec4 sk_FragCoord = vec4(gl_FragCoord.x, u_skRTHeight - gl_FragCoord.y, "
+ "gl_FragCoord.z, gl_FragCoord.w);\n"
" sk_FragColor.xy = sk_FragCoord.xy;\n"
"}\n",
&inputs);