Migrate swizzle tests to golden SkSL files.
This simplifies life when revising the swizzle logic. Change-Id: I7fc63c0cc845c4741c17c82b3078040264b61ba0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317379 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
6d94b65315
commit
7f6378f7f8
@ -55,6 +55,9 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/Switch.sksl",
|
||||
"$_tests/sksl/glsl/SwitchContainingDeadCode.sksl",
|
||||
"$_tests/sksl/glsl/SwitchWithFallthrough.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleConstants.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleOpt.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleScalar.sksl",
|
||||
"$_tests/sksl/glsl/UnusedVariables.sksl",
|
||||
"$_tests/sksl/glsl/VectorConstructors.sksl",
|
||||
"$_tests/sksl/glsl/VectorFolding.sksl",
|
||||
|
@ -1172,149 +1172,6 @@ DEF_TEST(SkSLSwizzleLTRB, r) {
|
||||
);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleConstants, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" half4 v = half4(half(sqrt(1)));"
|
||||
" sk_FragColor = half4(v.x, 1, 1, 1);"
|
||||
" sk_FragColor = half4(v.xy, 1, 1);"
|
||||
" sk_FragColor = half4(v.x1, 1, 1);"
|
||||
" sk_FragColor = half4(v.0y, 1, 1);"
|
||||
" sk_FragColor = half4(v.xyz, 1);"
|
||||
" sk_FragColor = half4(v.xy1, 1);"
|
||||
" sk_FragColor = half4(v.x0z, 1);"
|
||||
" sk_FragColor = half4(v.x10, 1);"
|
||||
" sk_FragColor = half4(v.1yz, 1);"
|
||||
" sk_FragColor = half4(v.0y1, 1);"
|
||||
" sk_FragColor = half4(v.11z, 1);"
|
||||
" sk_FragColor = v.xyzw;"
|
||||
" sk_FragColor = v.xyz1;"
|
||||
" sk_FragColor = v.xy0w;"
|
||||
" sk_FragColor = v.xy10;"
|
||||
" sk_FragColor = v.x1zw;"
|
||||
" sk_FragColor = v.x0z1;"
|
||||
" sk_FragColor = v.x11w;"
|
||||
" sk_FragColor = v.x101;"
|
||||
" sk_FragColor = v.1yzw;"
|
||||
" sk_FragColor = v.0yz1;"
|
||||
" sk_FragColor = v.0y1w;"
|
||||
" sk_FragColor = v.1y11;"
|
||||
" sk_FragColor = v.00zw;"
|
||||
" sk_FragColor = v.00z1;"
|
||||
" sk_FragColor = v.011w;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::RemovePowWithConstantExponent(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" vec4 v = vec4(sqrt(1.0));\n"
|
||||
" sk_FragColor = vec4(v.x, 1.0, 1.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(v.xy, 1.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(vec2(v.x, 1.0), 1.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(vec2(v.y, 0.0).yx, 1.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(v.xyz, 1.0);\n"
|
||||
" sk_FragColor = vec4(vec3(v.xy, 1.0), 1.0);\n"
|
||||
" sk_FragColor = vec4(vec3(v.xz, 0.0).xzy, 1.0);\n"
|
||||
" sk_FragColor = vec4(vec3(v.x, 1.0, 0.0), 1.0);\n"
|
||||
" sk_FragColor = vec4(vec3(v.yz, 1.0).zxy, 1.0);\n"
|
||||
" sk_FragColor = vec4(vec3(v.y, 0.0, 1.0).yxz, 1.0);\n"
|
||||
" sk_FragColor = vec4(vec3(v.z, 1.0, 1.0).yzx, 1.0);\n"
|
||||
" sk_FragColor = v;\n"
|
||||
" sk_FragColor = vec4(v.xyz, 1.0);\n"
|
||||
" sk_FragColor = vec4(v.xyw, 0.0).xywz;\n"
|
||||
" sk_FragColor = vec4(v.xy, 1.0, 0.0);\n"
|
||||
" sk_FragColor = vec4(v.xzw, 1.0).xwyz;\n"
|
||||
" sk_FragColor = vec4(v.xz, 0.0, 1.0).xzyw;\n"
|
||||
" sk_FragColor = vec4(v.xw, 1.0, 1.0).xzwy;\n"
|
||||
" sk_FragColor = vec4(v.x, 1.0, 0.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(v.yzw, 1.0).wxyz;\n"
|
||||
" sk_FragColor = vec4(v.yz, 0.0, 1.0).zxyw;\n"
|
||||
" sk_FragColor = vec4(v.yw, 0.0, 1.0).zxwy;\n"
|
||||
" sk_FragColor = vec4(v.y, 1.0, 1.0, 1.0).yxzw;\n"
|
||||
" sk_FragColor = vec4(v.zw, 0.0, 0.0).zwxy;\n"
|
||||
" sk_FragColor = vec4(v.z, 0.0, 0.0, 1.0).yzxw;\n"
|
||||
" sk_FragColor = vec4(v.w, 0.0, 1.0, 1.0).yzwx;\n"
|
||||
"}\n",
|
||||
SkSL::Program::kFragment_Kind
|
||||
);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleOpt, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" half v = half(sqrt(1));"
|
||||
" sk_FragColor = half4(v).rgba;"
|
||||
" sk_FragColor = half4(v).rgb0.abgr;"
|
||||
" sk_FragColor = half4(v).rgba.00ra;"
|
||||
" sk_FragColor = half4(v).rgba.rrra.00ra.11ab;"
|
||||
" sk_FragColor = half4(v).abga.gb11;"
|
||||
" sk_FragColor = half4(v).abgr.abgr;"
|
||||
" sk_FragColor = half4(half4(v).rrrr.bb, 1, 1);"
|
||||
" sk_FragColor = half4(half4(v).ba.grgr);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" float v = sqrt(1.0);\n"
|
||||
" sk_FragColor = vec4(v);\n"
|
||||
" sk_FragColor = vec4(vec4(v).xyz, 0.0).wzyx;\n"
|
||||
" sk_FragColor = vec4(vec4(v).xw, 0.0, 0.0).zwxy;\n"
|
||||
" sk_FragColor = vec4(vec4(vec4(v).xw, 0.0, 0.0).yx, 1.0, 1.0).zwxy;\n"
|
||||
" sk_FragColor = vec4(vec4(v).zy, 1.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(v);\n"
|
||||
" sk_FragColor = vec4(vec4(v).xx, 1.0, 1.0);\n"
|
||||
" sk_FragColor = vec4(v).wzwz;\n"
|
||||
"}\n",
|
||||
SkSL::Program::kFragment_Kind
|
||||
);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleScalar, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" half x = half(sqrt(4));"
|
||||
" sk_FragColor = x.xx01;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" float x = sqrt(4.0);\n"
|
||||
" sk_FragColor = vec4(vec2(x), 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() {"
|
||||
" sk_FragColor = half(sqrt(4)).xx01;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(vec2(sqrt(4.0)), 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() {"
|
||||
" sk_FragColor = half(sqrt(4)).0x01;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(sqrt(4.0), 0.0, 0.0, 1.0).yxzw;\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() {"
|
||||
" sk_FragColor = half(sqrt(4)).0x0x;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(vec2(sqrt(4.0)), 0.0, 0.0).zxwy;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLStackingVectorCasts, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
|
29
tests/sksl/glsl/SwizzleConstants.sksl
Normal file
29
tests/sksl/glsl/SwizzleConstants.sksl
Normal file
@ -0,0 +1,29 @@
|
||||
void main() {
|
||||
half4 v = half4(half(sqrt(1)));
|
||||
sk_FragColor = half4(v.x, 1, 1, 1);
|
||||
sk_FragColor = half4(v.xy, 1, 1);
|
||||
sk_FragColor = half4(v.x1, 1, 1);
|
||||
sk_FragColor = half4(v.0y, 1, 1);
|
||||
sk_FragColor = half4(v.xyz, 1);
|
||||
sk_FragColor = half4(v.xy1, 1);
|
||||
sk_FragColor = half4(v.x0z, 1);
|
||||
sk_FragColor = half4(v.x10, 1);
|
||||
sk_FragColor = half4(v.1yz, 1);
|
||||
sk_FragColor = half4(v.0y1, 1);
|
||||
sk_FragColor = half4(v.11z, 1);
|
||||
sk_FragColor = v.xyzw;
|
||||
sk_FragColor = v.xyz1;
|
||||
sk_FragColor = v.xy0w;
|
||||
sk_FragColor = v.xy10;
|
||||
sk_FragColor = v.x1zw;
|
||||
sk_FragColor = v.x0z1;
|
||||
sk_FragColor = v.x11w;
|
||||
sk_FragColor = v.x101;
|
||||
sk_FragColor = v.1yzw;
|
||||
sk_FragColor = v.0yz1;
|
||||
sk_FragColor = v.0y1w;
|
||||
sk_FragColor = v.1y11;
|
||||
sk_FragColor = v.00zw;
|
||||
sk_FragColor = v.00z1;
|
||||
sk_FragColor = v.011w;
|
||||
}
|
11
tests/sksl/glsl/SwizzleOpt.sksl
Normal file
11
tests/sksl/glsl/SwizzleOpt.sksl
Normal file
@ -0,0 +1,11 @@
|
||||
void main() {
|
||||
half v = half(sqrt(1));
|
||||
sk_FragColor = half4(v).rgba;
|
||||
sk_FragColor = half4(v).rgb0.abgr;
|
||||
sk_FragColor = half4(v).rgba.00ra;
|
||||
sk_FragColor = half4(v).rgba.rrra.00ra.11ab;
|
||||
sk_FragColor = half4(v).abga.gb11;
|
||||
sk_FragColor = half4(v).abgr.abgr;
|
||||
sk_FragColor = half4(half4(v).rrrr.bb, 1, 1);
|
||||
sk_FragColor = half4(half4(v).ba.grgr);
|
||||
}
|
7
tests/sksl/glsl/SwizzleScalar.sksl
Normal file
7
tests/sksl/glsl/SwizzleScalar.sksl
Normal file
@ -0,0 +1,7 @@
|
||||
void main() {
|
||||
half x = half(sqrt(4));
|
||||
sk_FragColor = x.xx01;
|
||||
sk_FragColor = half(sqrt(4)).xx01;
|
||||
sk_FragColor = half(sqrt(4)).0x01;
|
||||
sk_FragColor = half(sqrt(4)).0x0x;
|
||||
}
|
31
tests/sksl/glsl/golden/SwizzleConstants.glsl
Normal file
31
tests/sksl/glsl/golden/SwizzleConstants.glsl
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
vec4 v = vec4(sqrt(1.0));
|
||||
sk_FragColor = vec4(v.x, 1.0, 1.0, 1.0);
|
||||
sk_FragColor = vec4(v.xy, 1.0, 1.0);
|
||||
sk_FragColor = vec4(vec2(v.x, 1.0), 1.0, 1.0);
|
||||
sk_FragColor = vec4(vec2(v.y, 0.0).yx, 1.0, 1.0);
|
||||
sk_FragColor = vec4(v.xyz, 1.0);
|
||||
sk_FragColor = vec4(vec3(v.xy, 1.0), 1.0);
|
||||
sk_FragColor = vec4(vec3(v.xz, 0.0).xzy, 1.0);
|
||||
sk_FragColor = vec4(vec3(v.x, 1.0, 0.0), 1.0);
|
||||
sk_FragColor = vec4(vec3(v.yz, 1.0).zxy, 1.0);
|
||||
sk_FragColor = vec4(vec3(v.y, 0.0, 1.0).yxz, 1.0);
|
||||
sk_FragColor = vec4(vec3(v.z, 1.0, 1.0).yzx, 1.0);
|
||||
sk_FragColor = v;
|
||||
sk_FragColor = vec4(v.xyz, 1.0);
|
||||
sk_FragColor = vec4(v.xyw, 0.0).xywz;
|
||||
sk_FragColor = vec4(v.xy, 1.0, 0.0);
|
||||
sk_FragColor = vec4(v.xzw, 1.0).xwyz;
|
||||
sk_FragColor = vec4(v.xz, 0.0, 1.0).xzyw;
|
||||
sk_FragColor = vec4(v.xw, 1.0, 1.0).xzwy;
|
||||
sk_FragColor = vec4(v.x, 1.0, 0.0, 1.0);
|
||||
sk_FragColor = vec4(v.yzw, 1.0).wxyz;
|
||||
sk_FragColor = vec4(v.yz, 0.0, 1.0).zxyw;
|
||||
sk_FragColor = vec4(v.yw, 0.0, 1.0).zxwy;
|
||||
sk_FragColor = vec4(v.y, 1.0, 1.0, 1.0).yxzw;
|
||||
sk_FragColor = vec4(v.zw, 0.0, 0.0).zwxy;
|
||||
sk_FragColor = vec4(v.z, 0.0, 0.0, 1.0).yzxw;
|
||||
sk_FragColor = vec4(v.w, 0.0, 1.0, 1.0).yzwx;
|
||||
}
|
13
tests/sksl/glsl/golden/SwizzleOpt.glsl
Normal file
13
tests/sksl/glsl/golden/SwizzleOpt.glsl
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
float v = sqrt(1.0);
|
||||
sk_FragColor = vec4(v);
|
||||
sk_FragColor = vec4(vec4(v).xyz, 0.0).wzyx;
|
||||
sk_FragColor = vec4(vec4(v).xw, 0.0, 0.0).zwxy;
|
||||
sk_FragColor = vec4(vec4(vec4(v).xw, 0.0, 0.0).yx, 1.0, 1.0).zwxy;
|
||||
sk_FragColor = vec4(vec4(v).zy, 1.0, 1.0);
|
||||
sk_FragColor = vec4(v);
|
||||
sk_FragColor = vec4(vec4(v).xx, 1.0, 1.0);
|
||||
sk_FragColor = vec4(v).wzwz;
|
||||
}
|
9
tests/sksl/glsl/golden/SwizzleScalar.glsl
Normal file
9
tests/sksl/glsl/golden/SwizzleScalar.glsl
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
float x = sqrt(4.0);
|
||||
sk_FragColor = vec4(vec2(x), 0.0, 1.0);
|
||||
sk_FragColor = vec4(vec2(sqrt(4.0)), 0.0, 1.0);
|
||||
sk_FragColor = vec4(sqrt(4.0), 0.0, 0.0, 1.0).yxzw;
|
||||
sk_FragColor = vec4(vec2(sqrt(4.0)), 0.0, 0.0).zxwy;
|
||||
}
|
Loading…
Reference in New Issue
Block a user