diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2016-11-11 12:38:50 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-11 18:21:14 +0000 |
commit | 498d403f7703cb2157bf3c877b84906db5a06cd4 (patch) | |
tree | 88d7c27bbaee6d9b9614e29f9363b15543b7860c /tests/SkSLGLSLTest.cpp | |
parent | 041da389dd923689041ba5e45cda34901ba4fe8a (diff) |
re-land of skslc now uses standard Skia caps
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4726
Change-Id: Ib1ea5d4269396e6c57ee1f0d7209aa9a9f2798e8
Reviewed-on: https://skia-review.googlesource.com/4726
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'tests/SkSLGLSLTest.cpp')
-rw-r--r-- | tests/SkSLGLSLTest.cpp | 121 |
1 files changed, 57 insertions, 64 deletions
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp index 38fce87e87..937fd6749a 100644 --- a/tests/SkSLGLSLTest.cpp +++ b/tests/SkSLGLSLTest.cpp @@ -9,7 +9,8 @@ #include "Test.h" -static void test(skiatest::Reporter* r, const char* src, SkSL::GLCaps caps, const char* expected) { +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 +27,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 +50,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 +76,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 +92,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 +118,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 +152,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 +174,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 +202,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 +222,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 +241,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 +269,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 +297,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 +319,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 +340,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 +367,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 +386,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 +397,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 +459,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 +508,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" |