aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-07-20 13:09:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-20 17:48:56 +0000
commitcc10d790df6596c21a9e01ed6dadb680d7fe19e5 (patch)
treecd3df572ebbb50d5e2fe7a972ee4d11a293330ef /src
parent8e9b4c47575cd468d345e7b3a0e7ba17d21d42fc (diff)
Move fragCoord workaround declaration
This ensures that all extension directives occur before any non-preprocessor tokens, as required by the spec (ยง 3.4). This was found by Qualcomm, and originally submitted as https://github.com/google/skia/pull/21 Bug: b/111525079 Change-Id: I24357e4d3654e76c2dfbc067aca3088948dfa5a8 Reviewed-on: https://skia-review.googlesource.com/142697 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 5f6fedcdb5..76e76c3271 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -1264,25 +1264,6 @@ void GLSLCodeGenerator::writeHeader() {
this->writeExtension((Extension&) e);
}
}
- if (!fProgram.fSettings.fCaps->canUseFragCoord()) {
- Layout layout;
- switch (fProgram.fKind) {
- case Program::kVertex_Kind: {
- Modifiers modifiers(layout, Modifiers::kOut_Flag | Modifiers::kHighp_Flag);
- this->writeModifiers(modifiers, true);
- this->write("vec4 sk_FragCoord_Workaround;\n");
- break;
- }
- case Program::kFragment_Kind: {
- Modifiers modifiers(layout, Modifiers::kIn_Flag | Modifiers::kHighp_Flag);
- this->writeModifiers(modifiers, true);
- this->write("vec4 sk_FragCoord_Workaround;\n");
- break;
- }
- default:
- break;
- }
- }
}
void GLSLCodeGenerator::writeProgramElement(const ProgramElement& e) {
@@ -1359,6 +1340,27 @@ bool GLSLCodeGenerator::generateCode() {
fOut = rawOut;
write_stringstream(fHeader, *rawOut);
+
+ if (!fProgram.fSettings.fCaps->canUseFragCoord()) {
+ Layout layout;
+ switch (fProgram.fKind) {
+ case Program::kVertex_Kind: {
+ Modifiers modifiers(layout, Modifiers::kOut_Flag | Modifiers::kHighp_Flag);
+ this->writeModifiers(modifiers, true);
+ this->write("vec4 sk_FragCoord_Workaround;\n");
+ break;
+ }
+ case Program::kFragment_Kind: {
+ Modifiers modifiers(layout, Modifiers::kIn_Flag | Modifiers::kHighp_Flag);
+ this->writeModifiers(modifiers, true);
+ this->write("vec4 sk_FragCoord_Workaround;\n");
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
if (this->usesPrecisionModifiers()) {
this->writeLine("precision mediump float;");
}