aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkSLGLSLTest.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-06-01 11:29:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-02 13:23:36 +0000
commit88bd8edcff23dc9cf31b664cba7ba73b235318b0 (patch)
treebda38d25837904f6e5320e3f54b91465a9aab3d9 /tests/SkSLGLSLTest.cpp
parentec4400bfe34bbb90eaceaae168b2c6edf9aca4d9 (diff)
Fixed an issue with sksl variable declarations
There was an issue where multiple variables defined in the same declaration were not being sequenced appropriately during analysis, so 'int x = 0, y = x + 1' would report that x was undefined. Bug: skia: Change-Id: I882f7e216467306f6a6013a0a34aac30a4c60744 Reviewed-on: https://skia-review.googlesource.com/18313 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'tests/SkSLGLSLTest.cpp')
-rw-r--r--tests/SkSLGLSLTest.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index ba6bbbd13f..678ff13dd3 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -1340,24 +1340,39 @@ DEF_TEST(SkSLMultipleAssignments, r) {
DEF_TEST(SkSLComplexDelete, r) {
test(r,
- "uniform mat4 colorXform;"
- "uniform sampler2D sampler;"
- "void main() {"
- "vec4 tmpColor;"
- "sk_FragColor = vec4(1.0) * (tmpColor = texture(sampler, vec2(1)) , "
- "colorXform != mat4(1.0) ? vec4(clamp((mat4(colorXform) * vec4(tmpColor.xyz, 1.0)).xyz, "
- "0.0, tmpColor.w), tmpColor.w) : tmpColor);"
- "}",
- *SkSL::ShaderCapsFactory::Default(),
- "#version 400\n"
- "out vec4 sk_FragColor;\n"
- "uniform mat4 colorXform;\n"
- "uniform sampler2D sampler;\n"
- "void main() {\n"
- " vec4 tmpColor;\n"
- " sk_FragColor = (tmpColor = texture(sampler, vec2(1.0)) , colorXform != mat4(1.0) ? "
- "vec4(clamp((colorXform * vec4(tmpColor.xyz, 1.0)).xyz, 0.0, tmpColor.w), tmpColor.w) : "
- "tmpColor);\n"
- "}\n");
+ "uniform mat4 colorXform;"
+ "uniform sampler2D sampler;"
+ "void main() {"
+ "vec4 tmpColor;"
+ "sk_FragColor = vec4(1.0) * (tmpColor = texture(sampler, vec2(1)) , "
+ "colorXform != mat4(1.0) ? vec4(clamp((mat4(colorXform) * vec4(tmpColor.xyz, 1.0)).xyz, "
+ "0.0, tmpColor.w), tmpColor.w) : tmpColor);"
+ "}",
+ *SkSL::ShaderCapsFactory::Default(),
+ "#version 400\n"
+ "out vec4 sk_FragColor;\n"
+ "uniform mat4 colorXform;\n"
+ "uniform sampler2D sampler;\n"
+ "void main() {\n"
+ " vec4 tmpColor;\n"
+ " sk_FragColor = (tmpColor = texture(sampler, vec2(1.0)) , colorXform != mat4(1.0) ? "
+ "vec4(clamp((colorXform * vec4(tmpColor.xyz, 1.0)).xyz, 0.0, tmpColor.w), tmpColor.w) : "
+ "tmpColor);\n"
+ "}\n");
+}
+
+DEF_TEST(SkSLDependentInitializers, r) {
+ test(r,
+ "void main() {"
+ "float x = 0.5, y = x * 2;"
+ "sk_FragColor = vec4(y);"
+ "}",
+ *SkSL::ShaderCapsFactory::Default(),
+ "#version 400\n"
+ "out vec4 sk_FragColor;\n"
+ "void main() {\n"
+ " sk_FragColor = vec4(1.0);\n"
+ "}\n");
}
+
#endif