aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-11-11 15:16:46 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-11 21:15:29 +0000
commit7ef4b74e57a143e4e586e577e9b7c11c3aab472d (patch)
tree5ca0e9f4e9fc44806f0ef45eb70c0ff350cf13a0 /tests
parentdca4f6530013cf43a2557ccb07f5cb4fd916b8e8 (diff)
re-re-land of skslc now uses standard Skia caps
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4732 Change-Id: I144110bf66f67a28da7ad333173db43bddf9e8d0 Reviewed-on: https://skia-review.googlesource.com/4732 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/SkSLErrorTest.cpp4
-rw-r--r--tests/SkSLGLSLTest.cpp125
2 files changed, 65 insertions, 64 deletions
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index fc20fa2e6d..e9e05c18d2 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -9,6 +9,8 @@
#include "Test.h"
+#if SKIA_SUPPORT_GPU
+
static void test_failure(skiatest::Reporter* r, const char* src, const char* error) {
SkSL::Compiler compiler;
std::stringstream out;
@@ -368,3 +370,5 @@ DEF_TEST(SkSLStaticIfError, r) {
"void foo() { false ? x : 5; }",
"error: 1: unknown identifier 'x'\n1 error\n");
}
+
+#endif
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index 38fce87e87..b01aad83d6 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -9,7 +9,10 @@
#include "Test.h"
-static void test(skiatest::Reporter* r, const char* src, SkSL::GLCaps caps, const char* expected) {
+#if SKIA_SUPPORT_GPU
+
+static void test(skiatest::Reporter* r, const char* src, const GrGLSLCaps& caps,
+ const char* expected) {
SkSL::Compiler compiler;
std::string output;
bool result = compiler.toGLSL(SkSL::Program::kFragment_Kind, src, caps, &output);
@@ -26,17 +29,14 @@ static void test(skiatest::Reporter* r, const char* src, SkSL::GLCaps caps, cons
}
}
-static SkSL::GLCaps default_caps() {
- return SkSL::GLCaps();
-}
-
DEF_TEST(SkSLHelloWorld, r) {
test(r,
"void main() { sk_FragColor = vec4(0.75); }",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
- " gl_FragColor = vec4(0.75);\n"
+ " sk_FragColor = vec4(0.75);\n"
"}\n");
}
@@ -52,19 +52,20 @@ DEF_TEST(SkSLControl, r) {
"}"
"return;"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" if (sqrt(2.0) > 5.0) {\n"
- " gl_FragColor = vec4(0.75);\n"
+ " sk_FragColor = vec4(0.75);\n"
" } else {\n"
" discard;\n"
" }\n"
" int i = 0;\n"
- " while (i < 10) gl_FragColor *= 0.5;\n"
+ " while (i < 10) sk_FragColor *= 0.5;\n"
" do {\n"
- " gl_FragColor += 0.01;\n"
- " } while (gl_FragColor.x < 0.7);\n"
+ " sk_FragColor += 0.01;\n"
+ " } while (sk_FragColor.x < 0.7);\n"
" for (int i = 0;i < 10; i++) {\n"
" if (i % 0 == 1) break; else continue;\n"
" }\n"
@@ -77,8 +78,9 @@ DEF_TEST(SkSLFunctions, r) {
"float foo(float v[2]) { return v[0] * v[1]; }"
"void bar(inout float x) { float y[2], z; y[0] = x; y[1] = x * 2; z = foo(y); x = z; }"
"void main() { float x = 10; bar(x); sk_FragColor = vec4(x); }",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"float foo(in float v[2]) {\n"
" return v[0] * v[1];\n"
"}\n"
@@ -92,7 +94,7 @@ DEF_TEST(SkSLFunctions, r) {
"void main() {\n"
" float x = 10.0;\n"
" bar(x);\n"
- " gl_FragColor = vec4(x);\n"
+ " sk_FragColor = vec4(x);\n"
"}\n");
}
@@ -118,8 +120,9 @@ DEF_TEST(SkSLOperators, r) {
"z <<= 4;"
"z %= 5;"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float x = 1.0, y = 2.0;\n"
" int z = 3;\n"
@@ -151,8 +154,9 @@ DEF_TEST(SkSLMatrices, r) {
"vec3 v1 = mat3(1) * vec3(1);"
"vec3 v2 = vec3(1) * mat3(1);"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" mat2x4 x = mat2x4(1.0);\n"
" mat3x2 y = mat3x2(1.0, 0.0, 0.0, 1.0, vec2(2.0, 2.0));\n"
@@ -172,8 +176,9 @@ DEF_TEST(SkSLInterfaceBlock, r) {
"};"
"void main() {"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"uniform testBlock {\n"
" float x;\n"
" float[2] y;\n"
@@ -199,8 +204,9 @@ DEF_TEST(SkSLStructs, r) {
"B b1, b2, b3;"
"void main() {"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"struct A {\n"
" int x;\n"
" int y;\n"
@@ -218,22 +224,18 @@ DEF_TEST(SkSLStructs, r) {
}
DEF_TEST(SkSLVersion, r) {
- SkSL::GLCaps caps = default_caps();
- caps.fVersion = 450;
- caps.fIsCoreProfile = true;
test(r,
"in float test; void main() { sk_FragColor = vec4(0.75); }",
- caps,
+ *SkSL::GLSLCapsFactory::Version450Core(),
"#version 450 core\n"
+ "out vec4 sk_FragColor;\n"
"in float test;\n"
"void main() {\n"
- " gl_FragColor = vec4(0.75);\n"
+ " sk_FragColor = vec4(0.75);\n"
"}\n");
- caps.fVersion = 110;
- caps.fIsCoreProfile = false;
test(r,
"in float test; void main() { sk_FragColor = vec4(0.75); }",
- caps,
+ *SkSL::GLSLCapsFactory::Version110(),
"#version 110\n"
"varying float test;\n"
"void main() {\n"
@@ -241,36 +243,22 @@ DEF_TEST(SkSLVersion, r) {
"}\n");
}
-DEF_TEST(SkSLDeclareOutput, r) {
- SkSL::GLCaps caps = default_caps();
- caps.fMustDeclareFragmentShaderOutput = true;
- test(r,
- "void main() { sk_FragColor = vec4(0.75); }",
- caps,
- "#version 400\n"
- "out vec4 sk_FragColor;\n"
- "void main() {\n"
- " sk_FragColor = vec4(0.75);\n"
- "}\n");
-}
-
DEF_TEST(SkSLUsesPrecisionModifiers, r) {
- SkSL::GLCaps caps = default_caps();
test(r,
"void main() { float x = 0.75; highp float y = 1; }",
- caps,
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float x = 0.75;\n"
" float y = 1.0;\n"
"}\n");
- caps.fStandard = SkSL::GLCaps::kGLES_Standard;
- caps.fUsesPrecisionModifiers = true;
test(r,
"void main() { float x = 0.75; highp float y = 1; }",
- caps,
- "#version 400 es\n"
+ *SkSL::GLSLCapsFactory::UsesPrecisionModifiers(),
+ "#version 400\n"
"precision highp float;\n"
+ "out mediump vec4 sk_FragColor;\n"
"void main() {\n"
" float x = 0.75;\n"
" highp float y = 1.0;\n"
@@ -283,22 +271,22 @@ DEF_TEST(SkSLMinAbs, r) {
"float x = -5;"
"x = min(abs(x), 6);"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float x = -5.0;\n"
" x = min(abs(x), 6.0);\n"
"}\n");
- SkSL::GLCaps caps = default_caps();
- caps.fCanUseMinAndAbsTogether = false;
test(r,
"void main() {"
"float x = -5.0;"
"x = min(abs(x), 6.0);"
"}",
- caps,
+ *SkSL::GLSLCapsFactory::CannotUseMinAndAbsTogether(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float minAbsHackVar0;\n"
" float minAbsHackVar1;\n"
@@ -311,18 +299,18 @@ DEF_TEST(SkSLMinAbs, r) {
DEF_TEST(SkSLNegatedAtan, r) {
test(r,
"void main() { vec2 x = vec2(1, 2); float y = atan(x.x, -(2 * x.y)); }",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" vec2 x = vec2(1.0, 2.0);\n"
" float y = atan(x.x, -(2.0 * x.y));\n"
"}\n");
- SkSL::GLCaps caps = default_caps();
- caps.fMustForceNegatedAtanParamToFloat = true;
test(r,
"void main() { vec2 x = vec2(1, 2); float y = atan(x.x, -(2 * x.y)); }",
- caps,
+ *SkSL::GLSLCapsFactory::MustForceNegatedAtanParamToFloat(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" vec2 x = vec2(1.0, 2.0);\n"
" float y = atan(x.x, -1.0 * (2.0 * x.y));\n"
@@ -333,8 +321,9 @@ DEF_TEST(SkSLModifiersDeclaration, r) {
test(r,
"layout(blend_support_all_equations) out;"
"void main() { }",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"layout (blend_support_all_equations) out ;\n"
"void main() {\n"
"}\n");
@@ -353,8 +342,9 @@ DEF_TEST(SkSLHex, r) {
"uint u3 = 0x7fffffff;"
"uint u4 = 0xffffffff;"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" int i1 = 0;\n"
" int i2 = 305441741;\n"
@@ -379,8 +369,9 @@ DEF_TEST(SkSLVectorConstructors, r) {
"ivec2 v7 = ivec2(1);"
"ivec2 v8 = ivec2(vec2(1, 2));"
"vec2 v9 = vec2(ivec2(1, 2));",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"vec2 v1 = vec2(1.0);\n"
"vec2 v2 = vec2(1.0, 2.0);\n"
"vec2 v3 = vec2(1.0);\n"
@@ -397,8 +388,9 @@ DEF_TEST(SkSLArrayConstructors, r) {
"float test1[] = float[](1, 2, 3, 4);"
"vec2 test2[] = vec2[](vec2(1, 2), vec2(3, 4));"
"mat4 test3[] = mat4[]();",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"float test1[] = float[](1.0, 2.0, 3.0, 4.0);\n"
"vec2 test2[] = vec2[](vec2(1.0, 2.0), vec2(3.0, 4.0));\n"
"mat4 test3[] = mat4[]();\n");
@@ -407,25 +399,26 @@ DEF_TEST(SkSLArrayConstructors, r) {
DEF_TEST(SkSLDerivatives, r) {
test(r,
"void main() { float x = dFdx(1); }",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float x = dFdx(1.0);\n"
"}\n");
- SkSL::GLCaps caps = default_caps();
- caps.fShaderDerivativeExtensionString = "GL_OES_standard_derivatives";
test(r,
"void main() { float x = 1; }",
- caps,
+ *SkSL::GLSLCapsFactory::ShaderDerivativeExtensionString(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float x = 1.0;\n"
"}\n");
test(r,
"void main() { float x = dFdx(1); }",
- caps,
+ *SkSL::GLSLCapsFactory::ShaderDerivativeExtensionString(),
"#version 400\n"
"#extension GL_OES_standard_derivatives : require\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float x = dFdx(1.0);\n"
"}\n");
@@ -468,8 +461,9 @@ DEF_TEST(SkSLConstantFolding, r) {
"bool xor_f = 1 == 1 ^^ 1 == 1;"
"int ternary = 10 > 5 ? 10 : 5;"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" float f_add = 34.0;\n"
" float f_sub = 30.0;\n"
@@ -516,8 +510,9 @@ DEF_TEST(SkSLStaticIf, r) {
"if (1 > 2) x = 4; else x = 5;"
"if (false) x = 6;"
"}",
- default_caps(),
+ *SkSL::GLSLCapsFactory::Default(),
"#version 400\n"
+ "out vec4 sk_FragColor;\n"
"void main() {\n"
" int x;\n"
" x = 1;\n"
@@ -527,3 +522,5 @@ DEF_TEST(SkSLStaticIf, r) {
" }\n"
"}\n");
}
+
+#endif