aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkSLGLSLTest.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-11-21 15:59:48 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-22 14:20:27 +0000
commit3605ace7ddaf0b576bf6df1c7a550ab4f44d22a8 (patch)
tree929ee78317ba05e8f2c36c0f1b4bafea87794ca0 /tests/SkSLGLSLTest.cpp
parent9bcca6a2124b60ce9fab18ba697b28fc6a1354db (diff)
sksl programs can now directly query GLSL caps
This adds support for querying "sk_Caps.<cap>" directly from within an SkSL program. Combined with the existing support for collapsing 'if' statements with constant tests, this means we can query caps using ordinary 'if' statements and the tests will collapse out at compile time. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4795 Change-Id: I24d716a7fe6abf1489760bf08189164264269076 Reviewed-on: https://skia-review.googlesource.com/4795 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'tests/SkSLGLSLTest.cpp')
-rw-r--r--tests/SkSLGLSLTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index 7af32bef6f..4a9338113f 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -524,4 +524,27 @@ DEF_TEST(SkSLStaticIf, r) {
"}\n");
}
+DEF_TEST(SkSLCaps, r) {
+ test(r,
+ "void main() {"
+ "int x;"
+ "if (sk_Caps.externalTextureSupport) x = 1;"
+ "if (sk_Caps.fbFetchSupport) x = 2;"
+ "if (sk_Caps.dropsTileOnZeroDivide && sk_Caps.texelFetchSupport) x = 3;"
+ "if (sk_Caps.dropsTileOnZeroDivide && sk_Caps.canUseAnyFunctionInShader) x = 4;"
+ "}",
+ *SkSL::GLSLCapsFactory::VariousCaps(),
+ "#version 400\n"
+ "out vec4 sk_FragColor;\n"
+ "void main() {\n"
+ " int x;\n"
+ " x = 1;\n"
+ " {\n"
+ " }\n"
+ " x = 3;\n"
+ " {\n"
+ " }\n"
+ "}\n");
+}
+
#endif