Convert additional GLSL tests to use golden files.
A handful of simplifications were made, but these hew very close to the original tests and are intended to cover the exact same ground. The remaining unconverted tests depend on non-default caps bits and will be updated once caps handling in skslc is fully landed. Change-Id: I3f3c29bf87f73e501561d7bfcdaabe8acc14b89f Bug: skia:10694 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317390 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
1d3e0e0054
commit
9080540b93
@ -18,6 +18,8 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/ArrayIndexTypes.sksl",
|
||||
"$_tests/sksl/glsl/ArrayTypes.sksl",
|
||||
"$_tests/sksl/glsl/BoolFolding.sksl",
|
||||
"$_tests/sksl/glsl/Caps.sksl",
|
||||
"$_tests/sksl/glsl/CastsRoundTowardZero.sksl",
|
||||
"$_tests/sksl/glsl/ClipDistanceFragment.sksl",
|
||||
"$_tests/sksl/glsl/ClipDistanceVertex.vert",
|
||||
"$_tests/sksl/glsl/Clockwise.sksl",
|
||||
@ -27,8 +29,11 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/Control.sksl",
|
||||
"$_tests/sksl/glsl/DeadLoopVariable.sksl",
|
||||
"$_tests/sksl/glsl/DependentInitializers.sksl",
|
||||
"$_tests/sksl/glsl/Discard.sksl",
|
||||
"$_tests/sksl/glsl/FloatFolding.sksl",
|
||||
"$_tests/sksl/glsl/FrExp.sksl",
|
||||
"$_tests/sksl/glsl/Functions.sksl",
|
||||
"$_tests/sksl/glsl/Height.sksl",
|
||||
"$_tests/sksl/glsl/HelloWorld.sksl",
|
||||
"$_tests/sksl/glsl/Hex.sksl",
|
||||
"$_tests/sksl/glsl/InstanceID.vert",
|
||||
@ -38,11 +43,16 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/InterfaceBlockNamed.sksl",
|
||||
"$_tests/sksl/glsl/Matrices.sksl",
|
||||
"$_tests/sksl/glsl/MatrixFolding.sksl",
|
||||
"$_tests/sksl/glsl/ModifiersDeclaration.sksl",
|
||||
"$_tests/sksl/glsl/MultipleAssignments.sksl",
|
||||
"$_tests/sksl/glsl/NegatedVectorLiteral.sksl",
|
||||
"$_tests/sksl/glsl/NumberConversions.sksl",
|
||||
"$_tests/sksl/glsl/Offset.sksl",
|
||||
"$_tests/sksl/glsl/Operators.sksl",
|
||||
"$_tests/sksl/glsl/RectangleTexture.sksl",
|
||||
"$_tests/sksl/glsl/SampleMask.sksl",
|
||||
"$_tests/sksl/glsl/ShortCircuitBoolFolding.sksl",
|
||||
"$_tests/sksl/glsl/StackingVectorCasts.sksl",
|
||||
"$_tests/sksl/glsl/StaticSwitchWithBreak.sksl",
|
||||
"$_tests/sksl/glsl/StaticSwitchWithBreakInsideBlock.sksl",
|
||||
"$_tests/sksl/glsl/StaticSwitchWithConditionalBreak.sksl",
|
||||
@ -56,12 +66,17 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/SwitchContainingDeadCode.sksl",
|
||||
"$_tests/sksl/glsl/SwitchWithFallthrough.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleConstants.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleLTRB.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleOpt.sksl",
|
||||
"$_tests/sksl/glsl/SwizzleScalar.sksl",
|
||||
"$_tests/sksl/glsl/TernaryAsLValueEntirelyFoldable.sksl",
|
||||
"$_tests/sksl/glsl/TernaryAsLValueFoldableTest.sksl",
|
||||
"$_tests/sksl/glsl/TernaryAsLValueUnfoldable.sksl",
|
||||
"$_tests/sksl/glsl/UnusedVariables.sksl",
|
||||
"$_tests/sksl/glsl/VectorConstructors.sksl",
|
||||
"$_tests/sksl/glsl/VectorFolding.sksl",
|
||||
"$_tests/sksl/glsl/VertexID.vert",
|
||||
"$_tests/sksl/glsl/Width.sksl",
|
||||
"$_tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl",
|
||||
"$_tests/sksl/inliner/DoWhileTestCannotBeInlined.sksl",
|
||||
"$_tests/sksl/inliner/ForBodyMustBeInlinedIntoAScope.sksl",
|
||||
|
@ -173,49 +173,6 @@ DEF_TEST(SkSLNegatedAtan, r) {
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLModifiersDeclaration, r) {
|
||||
test(r,
|
||||
"layout(blend_support_all_equations) out;"
|
||||
"layout(blend_support_all_equations) out;"
|
||||
"layout(blend_support_multiply) out;"
|
||||
"layout(blend_support_screen) out;"
|
||||
"layout(blend_support_overlay) out;"
|
||||
"layout(blend_support_darken) out;"
|
||||
"layout(blend_support_lighten) out;"
|
||||
"layout(blend_support_colordodge) out;"
|
||||
"layout(blend_support_colorburn) out;"
|
||||
"layout(blend_support_hardlight) out;"
|
||||
"layout(blend_support_softlight) out;"
|
||||
"layout(blend_support_difference) out;"
|
||||
"layout(blend_support_exclusion) out;"
|
||||
"layout(blend_support_hsl_hue) out;"
|
||||
"layout(blend_support_hsl_saturation) out;"
|
||||
"layout(blend_support_hsl_color) out;"
|
||||
"layout(blend_support_hsl_luminosity) out;"
|
||||
"void main() { }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"layout (blend_support_all_equations) out ;\n"
|
||||
"layout (blend_support_all_equations) out ;\n"
|
||||
"layout (blend_support_multiply) out ;\n"
|
||||
"layout (blend_support_screen) out ;\n"
|
||||
"layout (blend_support_overlay) out ;\n"
|
||||
"layout (blend_support_darken) out ;\n"
|
||||
"layout (blend_support_lighten) out ;\n"
|
||||
"layout (blend_support_colordodge) out ;\n"
|
||||
"layout (blend_support_colorburn) out ;\n"
|
||||
"layout (blend_support_hardlight) out ;\n"
|
||||
"layout (blend_support_softlight) out ;\n"
|
||||
"layout (blend_support_difference) out ;\n"
|
||||
"layout (blend_support_exclusion) out ;\n"
|
||||
"layout (blend_support_hsl_hue) out ;\n"
|
||||
"layout (blend_support_hsl_saturation) out ;\n"
|
||||
"layout (blend_support_hsl_color) out ;\n"
|
||||
"layout (blend_support_hsl_luminosity) out ;\n"
|
||||
"void main() {\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLDerivatives, r) {
|
||||
test(r,
|
||||
"void main() { sk_FragColor.r = half(dFdx(1)); }",
|
||||
@ -273,25 +230,6 @@ DEF_TEST(SkSLDerivatives, r) {
|
||||
&inputs);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLCaps, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"int x = 0;"
|
||||
"int y = 0;"
|
||||
"int z = 0;"
|
||||
"if (sk_Caps.externalTextureSupport) x = 1;"
|
||||
"if (sk_Caps.fbFetchSupport) y = 1;"
|
||||
"if (sk_Caps.canUseAnyFunctionInShader) z = 1;"
|
||||
"sk_FragColor = half4(x, y, z, 0.0);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::VariousCaps(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(1.0, 0.0, 0.0, 0.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLTexture, r) {
|
||||
test(r,
|
||||
"uniform sampler1D one;"
|
||||
@ -494,38 +432,6 @@ DEF_TEST(SkSLFragCoord, r) {
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLWidthAndHeight, r) {
|
||||
SkSL::Program::Settings settings;
|
||||
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
|
||||
settings.fCaps = caps.get();
|
||||
SkSL::Program::Inputs inputs;
|
||||
test(r,
|
||||
"void main() { sk_FragColor.r = half(sk_FragCoord.x / sk_Width); }",
|
||||
settings,
|
||||
"#version 400\n"
|
||||
"uniform float u_skRTWidth;\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = gl_FragCoord.x / u_skRTWidth;\n"
|
||||
"}\n",
|
||||
&inputs);
|
||||
REPORTER_ASSERT(r, inputs.fRTWidth);
|
||||
REPORTER_ASSERT(r, !inputs.fRTHeight);
|
||||
|
||||
test(r,
|
||||
"void main() { sk_FragColor.r = half(sk_FragCoord.y / sk_Height); }",
|
||||
settings,
|
||||
"#version 400\n"
|
||||
"uniform float u_skRTHeight;\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = gl_FragCoord.y / u_skRTHeight;\n"
|
||||
"}\n",
|
||||
&inputs);
|
||||
REPORTER_ASSERT(r, !inputs.fRTWidth);
|
||||
REPORTER_ASSERT(r, inputs.fRTHeight);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLGeometry, r) {
|
||||
test(r,
|
||||
"layout(points) in;"
|
||||
@ -553,45 +459,6 @@ DEF_TEST(SkSLGeometry, r) {
|
||||
SkSL::Program::kGeometry_Kind);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLRectangleTexture, r) {
|
||||
test(r,
|
||||
"uniform sampler2D test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = sample(test, float2(0.5));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"uniform sampler2D test;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = texture(test, vec2(0.5));\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"uniform sampler2DRect test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = sample(test, float2(0.5));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"uniform sampler2DRect test;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = texture(test, vec2(0.5));\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"uniform sampler2DRect test;"
|
||||
"void main() {"
|
||||
" sk_FragColor = sample(test, float3(0.5));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"uniform sampler2DRect test;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = texture(test, vec3(0.5));\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLGeometryShaders, r) {
|
||||
test(r,
|
||||
"layout(points) in;"
|
||||
@ -730,101 +597,6 @@ DEF_TEST(SkSLTypePrecision, r) {
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLNumberConversions, r) {
|
||||
test(r,
|
||||
"short s = short(sqrt(1));"
|
||||
"int i = int(sqrt(1));"
|
||||
"ushort us = ushort(sqrt(1));"
|
||||
"uint ui = uint(sqrt(1));"
|
||||
"half h = half(sqrt(1));"
|
||||
"float f = sqrt(1);"
|
||||
"short s2s = s;"
|
||||
"short i2s = short(i);"
|
||||
"short us2s = short(us);"
|
||||
"short ui2s = short(ui);"
|
||||
"short h2s = short(h);"
|
||||
"short f2s = short(f);"
|
||||
"int s2i = s;"
|
||||
"int i2i = i;"
|
||||
"int us2i = int(us);"
|
||||
"int ui2i = int(ui);"
|
||||
"int h2i = int(h);"
|
||||
"int f2i = int(f);"
|
||||
"ushort s2us = ushort(s);"
|
||||
"ushort i2us = ushort(i);"
|
||||
"ushort us2us = us;"
|
||||
"ushort ui2us = ushort(ui);"
|
||||
"ushort h2us = ushort(h);"
|
||||
"ushort f2us = ushort(f);"
|
||||
"uint s2ui = uint(s);"
|
||||
"uint i2ui = uint(i);"
|
||||
"uint us2ui = us;"
|
||||
"uint ui2ui = ui;"
|
||||
"uint h2ui = uint(h);"
|
||||
"uint f2ui = uint(f);"
|
||||
"float s2f = s;"
|
||||
"float i2f = i;"
|
||||
"float us2f = us;"
|
||||
"float ui2f = ui;"
|
||||
"float h2f = h;"
|
||||
"float f2f = f;"
|
||||
"void main() {"
|
||||
"sk_FragColor.r = half(s + i + us + half(ui) + h + f + s2s + i2s + us2s + ui2s + h2s + "
|
||||
"f2s + s2i + i2i + us2i + ui2i + h2i + f2i + s2us + i2us + us2us);"
|
||||
"sk_FragColor.r += half(ui2us + h2us + f2us + half(s2ui) + half(i2ui) + half(us2ui) + "
|
||||
"half(ui2ui) + half(h2ui) + half(f2ui) + s2f + i2f + us2f + ui2f + "
|
||||
"h2f + f2f);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"int s = int(sqrt(1.0));\n"
|
||||
"int i = int(sqrt(1.0));\n"
|
||||
"uint us = uint(sqrt(1.0));\n"
|
||||
"uint ui = uint(sqrt(1.0));\n"
|
||||
"float h = sqrt(1.0);\n"
|
||||
"float f = sqrt(1.0);\n"
|
||||
"int s2s = s;\n"
|
||||
"int i2s = i;\n"
|
||||
"int us2s = int(us);\n"
|
||||
"int ui2s = int(ui);\n"
|
||||
"int h2s = int(h);\n"
|
||||
"int f2s = int(f);\n"
|
||||
"int s2i = s;\n"
|
||||
"int i2i = i;\n"
|
||||
"int us2i = int(us);\n"
|
||||
"int ui2i = int(ui);\n"
|
||||
"int h2i = int(h);\n"
|
||||
"int f2i = int(f);\n"
|
||||
"uint s2us = uint(s);\n"
|
||||
"uint i2us = uint(i);\n"
|
||||
"uint us2us = us;\n"
|
||||
"uint ui2us = ui;\n"
|
||||
"uint h2us = uint(h);\n"
|
||||
"uint f2us = uint(f);\n"
|
||||
"uint s2ui = uint(s);\n"
|
||||
"uint i2ui = uint(i);\n"
|
||||
"uint us2ui = us;\n"
|
||||
"uint ui2ui = ui;\n"
|
||||
"uint h2ui = uint(h);\n"
|
||||
"uint f2ui = uint(f);\n"
|
||||
"float s2f = float(s);\n"
|
||||
"float i2f = float(i);\n"
|
||||
"float us2f = float(us);\n"
|
||||
"float ui2f = float(ui);\n"
|
||||
"float h2f = h;\n"
|
||||
"float f2f = f;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = (((((((((((((((((float((s + i) + int(us)) + float(ui)) + h) + f) + "
|
||||
"float(s2s)) + float(i2s)) + float(us2s)) + float(ui2s)) + float(h2s)) + float(f2s)) + "
|
||||
"float(s2i)) + float(i2i)) + float(us2i)) + float(ui2i)) + float(h2i)) + float(f2i)) + "
|
||||
"float(s2us)) + float(i2us)) + float(us2us);\n"
|
||||
" sk_FragColor.x += (((((((((((float((ui2us + h2us) + f2us) + float(s2ui)) + "
|
||||
"float(i2ui)) + float(us2ui)) + float(ui2ui)) + float(h2ui)) + float(f2ui)) + s2f) + "
|
||||
"i2f) + us2f) + ui2f) + h2f) + f2f;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLForceHighPrecision, r) {
|
||||
test(r,
|
||||
"void main() {\n half x = half(sqrt(1));\n half4 y = half4(x);\n sk_FragColor = y;\n }",
|
||||
@ -906,46 +678,6 @@ DEF_TEST(SkSLNormalization, r) {
|
||||
SkSL::Program::kGeometry_Kind);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLTernaryLValue, r) {
|
||||
test(r,
|
||||
"void main() { int r, g; (true ? r : g) = 1; (false ? r : g) = 0; "
|
||||
"sk_FragColor = half4(r, g, 1, 1); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() { half r, g; (true ? r : g) = half(sqrt(1)); (false ? r : g) = half(sqrt(0));"
|
||||
"sk_FragColor = half4(r, g, 1, 1); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" float r, g;\n"
|
||||
" r = sqrt(1.0);\n"
|
||||
" g = sqrt(0.0);\n"
|
||||
" sk_FragColor = vec4(r, g, 1.0, 1.0);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() {"
|
||||
"half r, g;"
|
||||
"(sqrt(1) > 0 ? r : g) = half(sqrt(1));"
|
||||
"(sqrt(0) > 0 ? r : g) = half(sqrt(0));"
|
||||
"sk_FragColor = half4(r, g, 1, 1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" float r, g;\n"
|
||||
" sqrt(1.0) > 0.0 ? r : g = sqrt(1.0);\n"
|
||||
" sqrt(0.0) > 0.0 ? r : g = sqrt(0.0);\n"
|
||||
" sk_FragColor = vec4(r, g, 1.0, 1.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
|
||||
test(r,
|
||||
"uniform sampler2D tex;"
|
||||
@ -991,23 +723,6 @@ DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
|
||||
SkSL::Program::kFragment_Kind);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLFrExp, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" int exp;"
|
||||
" float foo = frexp(0.5, exp);"
|
||||
" sk_FragColor = half4(exp);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" int exp;\n"
|
||||
" float foo = frexp(0.5, exp);\n"
|
||||
" sk_FragColor = vec4(float(exp));\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLWorkaroundAddAndTrueToLoopCondition, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
@ -1156,112 +871,3 @@ DEF_TEST(SkSLWorkaroundRemovePowWithConstantExponent, r) {
|
||||
SkSL::Program::kFragment_Kind
|
||||
);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSwizzleLTRB, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" sk_FragColor = sk_FragColor.BRTL;"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::RemovePowWithConstantExponent(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = sk_FragColor.wzyx;\n"
|
||||
"}\n",
|
||||
SkSL::Program::kFragment_Kind
|
||||
);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLStackingVectorCasts, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" if (half4(0, 0, 1, 1) == half4(int4(0, 0, 1, 1)))"
|
||||
" sk_FragColor = half4(0, 1, 0, 1);"
|
||||
" else"
|
||||
" sk_FragColor = half4(1, 0, 0, 1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() {"
|
||||
" if (half4(int4(0, 0, 1, 1)) == half4(int4(half4(0, 0, 1, 1))))"
|
||||
" sk_FragColor = half4(0, 1, 0, 1);"
|
||||
" else"
|
||||
" sk_FragColor = half4(1, 0, 0, 1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLCastsRoundTowardZero, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" if (half4(int4(0, 0, 1, 2)) == half4(int4(half4(0.01, 0.99, 1.49, 2.75))))"
|
||||
" sk_FragColor = half4(0, 1, 0, 1);"
|
||||
" else"
|
||||
" sk_FragColor = half4(1, 0, 0, 1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() {"
|
||||
" if (half4(int4(0, 0, -1, -2)) == half4(int4(half4(-0.01, -0.99, -1.49, -2.75))))"
|
||||
" sk_FragColor = half4(0, 1, 0, 1);"
|
||||
" else"
|
||||
" sk_FragColor = half4(1, 0, 0, 1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLNegatedVectorLiteral, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
" if (half4(1) == half4(-half2(-1), half2(1)))"
|
||||
" sk_FragColor = half4(0, 1, 0, 1);"
|
||||
" else"
|
||||
" sk_FragColor = half4(1, 0, 0, 1);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLDiscard, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
"half x;"
|
||||
" @switch (1) {"
|
||||
" case 0: x = 0; break;"
|
||||
" default: x = 1; discard;"
|
||||
" }"
|
||||
" sk_FragColor = half4(x);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
R"__GLSL__(#version 400
|
||||
void main() {
|
||||
{
|
||||
discard;
|
||||
}
|
||||
}
|
||||
)__GLSL__");
|
||||
}
|
||||
|
9
tests/sksl/glsl/Caps.sksl
Normal file
9
tests/sksl/glsl/Caps.sksl
Normal file
@ -0,0 +1,9 @@
|
||||
void main() {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
if (sk_Caps.externalTextureSupport) x = 1;
|
||||
if (sk_Caps.fbFetchSupport) y = 1;
|
||||
if (sk_Caps.canUseAnyFunctionInShader) z = 1;
|
||||
sk_FragColor.rgb = half3(x, y, z);
|
||||
}
|
11
tests/sksl/glsl/CastsRoundTowardZero.sksl
Normal file
11
tests/sksl/glsl/CastsRoundTowardZero.sksl
Normal file
@ -0,0 +1,11 @@
|
||||
void main() {
|
||||
if (half4(int4(0, 0, 1, 2)) == half4(int4(half4(0.01, 0.99, 1.49, 2.75))))
|
||||
sk_FragColor = half4(1);
|
||||
else
|
||||
sk_FragColor = half4(-1);
|
||||
|
||||
if (half4(int4(0, 0, -1, -2)) == half4(int4(half4(-0.01, -0.99, -1.49, -2.75))))
|
||||
sk_FragColor = half4(2);
|
||||
else
|
||||
sk_FragColor = half4(-2);
|
||||
}
|
8
tests/sksl/glsl/Discard.sksl
Normal file
8
tests/sksl/glsl/Discard.sksl
Normal file
@ -0,0 +1,8 @@
|
||||
void main() {
|
||||
half x;
|
||||
@switch (1) {
|
||||
case 0: x = 0; break;
|
||||
default: x = 1; discard;
|
||||
}
|
||||
sk_FragColor = half4(x);
|
||||
}
|
5
tests/sksl/glsl/FrExp.sksl
Normal file
5
tests/sksl/glsl/FrExp.sksl
Normal file
@ -0,0 +1,5 @@
|
||||
void main() {
|
||||
int exp;
|
||||
float foo = frexp(0.5, exp);
|
||||
sk_FragColor = half4(exp);
|
||||
}
|
3
tests/sksl/glsl/Height.sksl
Normal file
3
tests/sksl/glsl/Height.sksl
Normal file
@ -0,0 +1,3 @@
|
||||
void main() {
|
||||
sk_FragColor.r = half(sk_FragCoord.y / sk_Height);
|
||||
}
|
18
tests/sksl/glsl/ModifiersDeclaration.sksl
Normal file
18
tests/sksl/glsl/ModifiersDeclaration.sksl
Normal file
@ -0,0 +1,18 @@
|
||||
layout(blend_support_all_equations) out;
|
||||
layout(blend_support_all_equations) out;
|
||||
layout(blend_support_multiply) out;
|
||||
layout(blend_support_screen) out;
|
||||
layout(blend_support_overlay) out;
|
||||
layout(blend_support_darken) out;
|
||||
layout(blend_support_lighten) out;
|
||||
layout(blend_support_colordodge) out;
|
||||
layout(blend_support_colorburn) out;
|
||||
layout(blend_support_hardlight) out;
|
||||
layout(blend_support_softlight) out;
|
||||
layout(blend_support_difference) out;
|
||||
layout(blend_support_exclusion) out;
|
||||
layout(blend_support_hsl_hue) out;
|
||||
layout(blend_support_hsl_saturation) out;
|
||||
layout(blend_support_hsl_color) out;
|
||||
layout(blend_support_hsl_luminosity) out;
|
||||
void main() {}
|
6
tests/sksl/glsl/NegatedVectorLiteral.sksl
Normal file
6
tests/sksl/glsl/NegatedVectorLiteral.sksl
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
if (half4(1) == half4(-half2(-1), half2(1)))
|
||||
sk_FragColor = half4(1);
|
||||
else
|
||||
sk_FragColor = half4(-1);
|
||||
}
|
43
tests/sksl/glsl/NumberConversions.sksl
Normal file
43
tests/sksl/glsl/NumberConversions.sksl
Normal file
@ -0,0 +1,43 @@
|
||||
short s = short(sqrt(1));
|
||||
int i = int(sqrt(1));
|
||||
ushort us = ushort(sqrt(1));
|
||||
uint ui = uint(sqrt(1));
|
||||
half h = half(sqrt(1));
|
||||
float f = sqrt(1);
|
||||
short s2s = s;
|
||||
short i2s = short(i);
|
||||
short us2s = short(us);
|
||||
short ui2s = short(ui);
|
||||
short h2s = short(h);
|
||||
short f2s = short(f);
|
||||
int s2i = s;
|
||||
int i2i = i;
|
||||
int us2i = int(us);
|
||||
int ui2i = int(ui);
|
||||
int h2i = int(h);
|
||||
int f2i = int(f);
|
||||
ushort s2us = ushort(s);
|
||||
ushort i2us = ushort(i);
|
||||
ushort us2us = us;
|
||||
ushort ui2us = ushort(ui);
|
||||
ushort h2us = ushort(h);
|
||||
ushort f2us = ushort(f);
|
||||
uint s2ui = uint(s);
|
||||
uint i2ui = uint(i);
|
||||
uint us2ui = us;
|
||||
uint ui2ui = ui;
|
||||
uint h2ui = uint(h);
|
||||
uint f2ui = uint(f);
|
||||
float s2f = s;
|
||||
float i2f = i;
|
||||
float us2f = us;
|
||||
float ui2f = ui;
|
||||
float h2f = h;
|
||||
float f2f = f;
|
||||
|
||||
void main() {
|
||||
sk_FragColor.r = half(s + i + us + half(ui) + h + f + s2s + i2s + us2s + ui2s + h2s + f2s +
|
||||
s2i + i2i + us2i + ui2i + h2i + f2i + s2us + i2us + us2us);
|
||||
sk_FragColor.r += half(ui2us + h2us + f2us + half(s2ui) + half(i2ui) + half(us2ui) + half(ui2ui)
|
||||
+ half(h2ui) + half(f2ui) + s2f + i2f + us2f + ui2f + h2f + f2f);
|
||||
}
|
8
tests/sksl/glsl/RectangleTexture.sksl
Normal file
8
tests/sksl/glsl/RectangleTexture.sksl
Normal file
@ -0,0 +1,8 @@
|
||||
uniform sampler2D test2D;
|
||||
uniform sampler2D test2DRect;
|
||||
|
||||
void main() {
|
||||
sk_FragColor = sample(test2D, float2(0.5));
|
||||
sk_FragColor = sample(test2DRect, float2(0.5));
|
||||
sk_FragColor = sample(test2DRect, float3(0.5));
|
||||
}
|
6
tests/sksl/glsl/StackingVectorCasts.sksl
Normal file
6
tests/sksl/glsl/StackingVectorCasts.sksl
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
if (half4(0, 0, 1, 1) == half4(int4(0, 0, 1, 1)))
|
||||
sk_FragColor = half4(1);
|
||||
else
|
||||
sk_FragColor = half4(-1);
|
||||
}
|
3
tests/sksl/glsl/SwizzleLTRB.sksl
Normal file
3
tests/sksl/glsl/SwizzleLTRB.sksl
Normal file
@ -0,0 +1,3 @@
|
||||
void main() {
|
||||
sk_FragColor = sk_FragColor.BRTL;
|
||||
}
|
6
tests/sksl/glsl/TernaryAsLValueEntirelyFoldable.sksl
Normal file
6
tests/sksl/glsl/TernaryAsLValueEntirelyFoldable.sksl
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
int r, g;
|
||||
(true ? r : g) = 1;
|
||||
(false ? r : g) = 0;
|
||||
sk_FragColor = half4(r, g, 1, 1);
|
||||
}
|
6
tests/sksl/glsl/TernaryAsLValueFoldableTest.sksl
Normal file
6
tests/sksl/glsl/TernaryAsLValueFoldableTest.sksl
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
half r, g;
|
||||
(true ? r : g) = half(sqrt(1));
|
||||
(false ? r : g) = half(sqrt(0));
|
||||
sk_FragColor = half4(r, g, 1, 1);
|
||||
}
|
6
tests/sksl/glsl/TernaryAsLValueUnfoldable.sksl
Normal file
6
tests/sksl/glsl/TernaryAsLValueUnfoldable.sksl
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
half r, g;
|
||||
(sqrt(1) > 0 ? r : g) = half(sqrt(1));
|
||||
(sqrt(0) > 0 ? r : g) = half(sqrt(0));
|
||||
sk_FragColor = half4(r, g, 1, 1);
|
||||
}
|
3
tests/sksl/glsl/Width.sksl
Normal file
3
tests/sksl/glsl/Width.sksl
Normal file
@ -0,0 +1,3 @@
|
||||
void main() {
|
||||
sk_FragColor.r = half(sk_FragCoord.x / sk_Width);
|
||||
}
|
5
tests/sksl/glsl/golden/Caps.glsl
Normal file
5
tests/sksl/glsl/golden/Caps.glsl
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor.xyz = vec3(1.0, 1.0, 0.0);
|
||||
}
|
6
tests/sksl/glsl/golden/CastsRoundTowardZero.glsl
Normal file
6
tests/sksl/glsl/golden/CastsRoundTowardZero.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor = vec4(1.0);
|
||||
sk_FragColor = vec4(2.0);
|
||||
}
|
6
tests/sksl/glsl/golden/Discard.glsl
Normal file
6
tests/sksl/glsl/golden/Discard.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
void main() {
|
||||
{
|
||||
discard;
|
||||
}
|
||||
}
|
7
tests/sksl/glsl/golden/FrExp.glsl
Normal file
7
tests/sksl/glsl/golden/FrExp.glsl
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
int exp;
|
||||
float foo = frexp(0.5, exp);
|
||||
sk_FragColor = vec4(float(exp));
|
||||
}
|
6
tests/sksl/glsl/golden/Height.glsl
Normal file
6
tests/sksl/glsl/golden/Height.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
uniform float u_skRTHeight;
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor.x = gl_FragCoord.y / u_skRTHeight;
|
||||
}
|
20
tests/sksl/glsl/golden/ModifiersDeclaration.glsl
Normal file
20
tests/sksl/glsl/golden/ModifiersDeclaration.glsl
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
layout (blend_support_all_equations) out ;
|
||||
layout (blend_support_all_equations) out ;
|
||||
layout (blend_support_multiply) out ;
|
||||
layout (blend_support_screen) out ;
|
||||
layout (blend_support_overlay) out ;
|
||||
layout (blend_support_darken) out ;
|
||||
layout (blend_support_lighten) out ;
|
||||
layout (blend_support_colordodge) out ;
|
||||
layout (blend_support_colorburn) out ;
|
||||
layout (blend_support_hardlight) out ;
|
||||
layout (blend_support_softlight) out ;
|
||||
layout (blend_support_difference) out ;
|
||||
layout (blend_support_exclusion) out ;
|
||||
layout (blend_support_hsl_hue) out ;
|
||||
layout (blend_support_hsl_saturation) out ;
|
||||
layout (blend_support_hsl_color) out ;
|
||||
layout (blend_support_hsl_luminosity) out ;
|
||||
void main() {
|
||||
}
|
5
tests/sksl/glsl/golden/NegatedVectorLiteral.glsl
Normal file
5
tests/sksl/glsl/golden/NegatedVectorLiteral.glsl
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor = vec4(1.0);
|
||||
}
|
42
tests/sksl/glsl/golden/NumberConversions.glsl
Normal file
42
tests/sksl/glsl/golden/NumberConversions.glsl
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
int s = int(sqrt(1.0));
|
||||
int i = int(sqrt(1.0));
|
||||
uint us = uint(sqrt(1.0));
|
||||
uint ui = uint(sqrt(1.0));
|
||||
float h = sqrt(1.0);
|
||||
float f = sqrt(1.0);
|
||||
int s2s = s;
|
||||
int i2s = i;
|
||||
int us2s = int(us);
|
||||
int ui2s = int(ui);
|
||||
int h2s = int(h);
|
||||
int f2s = int(f);
|
||||
int s2i = s;
|
||||
int i2i = i;
|
||||
int us2i = int(us);
|
||||
int ui2i = int(ui);
|
||||
int h2i = int(h);
|
||||
int f2i = int(f);
|
||||
uint s2us = uint(s);
|
||||
uint i2us = uint(i);
|
||||
uint us2us = us;
|
||||
uint ui2us = ui;
|
||||
uint h2us = uint(h);
|
||||
uint f2us = uint(f);
|
||||
uint s2ui = uint(s);
|
||||
uint i2ui = uint(i);
|
||||
uint us2ui = us;
|
||||
uint ui2ui = ui;
|
||||
uint h2ui = uint(h);
|
||||
uint f2ui = uint(f);
|
||||
float s2f = float(s);
|
||||
float i2f = float(i);
|
||||
float us2f = float(us);
|
||||
float ui2f = float(ui);
|
||||
float h2f = h;
|
||||
float f2f = f;
|
||||
void main() {
|
||||
sk_FragColor.x = (((((((((((((((((float((s + i) + int(us)) + float(ui)) + h) + f) + float(s2s)) + float(i2s)) + float(us2s)) + float(ui2s)) + float(h2s)) + float(f2s)) + float(s2i)) + float(i2i)) + float(us2i)) + float(ui2i)) + float(h2i)) + float(f2i)) + float(s2us)) + float(i2us)) + float(us2us);
|
||||
sk_FragColor.x += (((((((((((float((ui2us + h2us) + f2us) + float(s2ui)) + float(i2ui)) + float(us2ui)) + float(ui2ui)) + float(h2ui)) + float(f2ui)) + s2f) + i2f) + us2f) + ui2f) + h2f) + f2f;
|
||||
}
|
9
tests/sksl/glsl/golden/RectangleTexture.glsl
Normal file
9
tests/sksl/glsl/golden/RectangleTexture.glsl
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
uniform sampler2D test2D;
|
||||
uniform sampler2D test2DRect;
|
||||
void main() {
|
||||
sk_FragColor = texture(test2D, vec2(0.5));
|
||||
sk_FragColor = texture(test2DRect, vec2(0.5));
|
||||
sk_FragColor = textureProj(test2DRect, vec3(0.5));
|
||||
}
|
5
tests/sksl/glsl/golden/StackingVectorCasts.glsl
Normal file
5
tests/sksl/glsl/golden/StackingVectorCasts.glsl
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor = vec4(1.0);
|
||||
}
|
5
tests/sksl/glsl/golden/SwizzleLTRB.glsl
Normal file
5
tests/sksl/glsl/golden/SwizzleLTRB.glsl
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor = sk_FragColor.wzyx;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
}
|
8
tests/sksl/glsl/golden/TernaryAsLValueFoldableTest.glsl
Normal file
8
tests/sksl/glsl/golden/TernaryAsLValueFoldableTest.glsl
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
float r, g;
|
||||
r = sqrt(1.0);
|
||||
g = sqrt(0.0);
|
||||
sk_FragColor = vec4(r, g, 1.0, 1.0);
|
||||
}
|
8
tests/sksl/glsl/golden/TernaryAsLValueUnfoldable.glsl
Normal file
8
tests/sksl/glsl/golden/TernaryAsLValueUnfoldable.glsl
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
float r, g;
|
||||
sqrt(1.0) > 0.0 ? r : g = sqrt(1.0);
|
||||
sqrt(0.0) > 0.0 ? r : g = sqrt(0.0);
|
||||
sk_FragColor = vec4(r, g, 1.0, 1.0);
|
||||
}
|
6
tests/sksl/glsl/golden/Width.glsl
Normal file
6
tests/sksl/glsl/golden/Width.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
uniform float u_skRTWidth;
|
||||
out vec4 sk_FragColor;
|
||||
void main() {
|
||||
sk_FragColor.x = gl_FragCoord.x / u_skRTWidth;
|
||||
}
|
Loading…
Reference in New Issue
Block a user