Migrate geometry SkSL tests to golden outputs.

Change-Id: I01c150d6bfcdd1500033521a87c058c7428c3521
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317769
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-09-18 12:04:04 -04:00 committed by Skia Commit-Bot
parent c884631f99
commit 87e6ccde21
16 changed files with 168 additions and 157 deletions

View File

@ -62,7 +62,7 @@ for input in inputs:
# The CPP generated an error. We didn't actually generate a header at all, but Ninja
# expects an output file to exist or it won't reach steady-state.
makeEmptyFile(target + ".h")
elif ext == ".sksl" or ext == ".vert":
elif ext == ".sksl" or ext == ".vert" or ext == ".geom":
compile(skslc, input, target, ".glsl")
else:
print("### Unrecognized file type for " + input + ", skipped")

View File

@ -133,6 +133,10 @@ sksl_glsl_tests_sources = [
"$_tests/sksl/glsl/FunctionArgumentMatch.sksl",
"$_tests/sksl/glsl/FunctionPrototype.sksl",
"$_tests/sksl/glsl/Functions.sksl",
"$_tests/sksl/glsl/Geometry.geom",
"$_tests/sksl/glsl/GeometryExtension.geom",
"$_tests/sksl/glsl/GeometryGSInvocations.geom",
"$_tests/sksl/glsl/GeometryNoGSInvocations.geom",
"$_tests/sksl/glsl/Height.sksl",
"$_tests/sksl/glsl/HelloWorld.sksl",
"$_tests/sksl/glsl/Hex.sksl",
@ -146,6 +150,8 @@ sksl_glsl_tests_sources = [
"$_tests/sksl/glsl/ModifiersDeclaration.sksl",
"$_tests/sksl/glsl/MultipleAssignments.sksl",
"$_tests/sksl/glsl/NegatedVectorLiteral.sksl",
"$_tests/sksl/glsl/NormalizationGeo.geom",
"$_tests/sksl/glsl/NormalizationVert.vert",
"$_tests/sksl/glsl/NumberConversions.sksl",
"$_tests/sksl/glsl/Offset.sksl",
"$_tests/sksl/glsl/Operators.sksl",

View File

@ -76,10 +76,26 @@ static void detect_shader_settings(const SkSL::String& text, SkSL::Program::Sett
static auto s_emulateAbsIntCaps = Factory::EmulateAbsIntFunction();
settings->fCaps = s_emulateAbsIntCaps.get();
}
if (settingsText.consumeSuffix(" GeometryShaderExtensionString")) {
static auto s_geometryExtCaps = Factory::GeometryShaderExtensionString();
settings->fCaps = s_geometryExtCaps.get();
}
if (settingsText.consumeSuffix(" GeometryShaderSupport")) {
static auto s_geometryShaderCaps = Factory::GeometryShaderSupport();
settings->fCaps = s_geometryShaderCaps.get();
}
if (settingsText.consumeSuffix(" GSInvocationsExtensionString")) {
static auto s_gsInvocationCaps = Factory::GSInvocationsExtensionString();
settings->fCaps = s_gsInvocationCaps.get();
}
if (settingsText.consumeSuffix(" MustForceNegatedAtanParamToFloat")) {
static auto s_negativeAtanCaps = Factory::MustForceNegatedAtanParamToFloat();
settings->fCaps = s_negativeAtanCaps.get();
}
if (settingsText.consumeSuffix(" NoGSInvocationsSupport")) {
static auto s_noGSInvocations = Factory::NoGSInvocationsSupport();
settings->fCaps = s_noGSInvocations.get();
}
if (settingsText.consumeSuffix(" RemovePowWithConstantExponent")) {
static auto s_powCaps = Factory::RemovePowWithConstantExponent();
settings->fCaps = s_powCaps.get();

View File

@ -149,162 +149,6 @@ DEF_TEST(SkSLFragCoord, r) {
"}\n");
}
DEF_TEST(SkSLGeometry, r) {
test(r,
"layout(points) in;"
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void main() {"
"sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"EndPrimitive();"
"}",
*SkSL::ShaderCapsFactory::GeometryShaderSupport(),
"#version 400\n"
"layout (points) in ;\n"
"layout (invocations = 2) in ;\n"
"layout (line_strip, max_vertices = 2) out ;\n"
"void main() {\n"
" gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));\n"
" EmitVertex();\n"
" gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(gl_InvocationID));\n"
" EmitVertex();\n"
" EndPrimitive();\n"
"}\n",
SkSL::Program::kGeometry_Kind);
}
DEF_TEST(SkSLGeometryShaders, r) {
test(r,
"layout(points) in;"
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void test() {"
"sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"}"
"void main() {"
"test();"
"sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"}",
*SkSL::ShaderCapsFactory::NoGSInvocationsSupport(),
R"__GLSL__(#version 400
int sk_InvocationID;
layout (points) in ;
layout (line_strip, max_vertices = 4) out ;
void _invoke() {
{
gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(sk_InvocationID));
EmitVertex();
}
gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(sk_InvocationID));
EmitVertex();
}
void main() {
for (sk_InvocationID = 0;sk_InvocationID < 2; sk_InvocationID++) {
_invoke();
EndPrimitive();
}
}
)__GLSL__",
SkSL::Program::kGeometry_Kind);
test(r,
"layout(points, invocations = 2) in;"
"layout(invocations = 3) in;"
"layout(line_strip, max_vertices = 2) out;"
"void main() {"
"sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"EndPrimitive();"
"}",
*SkSL::ShaderCapsFactory::GSInvocationsExtensionString(),
"#version 400\n"
"#extension GL_ARB_gpu_shader5 : require\n"
"layout (points, invocations = 2) in ;\n"
"layout (invocations = 3) in ;\n"
"layout (line_strip, max_vertices = 2) out ;\n"
"void main() {\n"
" gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));\n"
" EmitVertex();\n"
" EndPrimitive();\n"
"}\n",
SkSL::Program::kGeometry_Kind);
test(r,
"layout(points, invocations = 2) in;"
"layout(invocations = 3) in;"
"layout(line_strip, max_vertices = 2) out;"
"void main() {"
"sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"EndPrimitive();"
"}",
*SkSL::ShaderCapsFactory::GeometryShaderExtensionString(),
"#version 310es\n"
"#extension GL_EXT_geometry_shader : require\n"
"layout (points, invocations = 2) in ;\n"
"layout (invocations = 3) in ;\n"
"layout (line_strip, max_vertices = 2) out ;\n"
"void main() {\n"
" gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));\n"
" EmitVertex();\n"
" EndPrimitive();\n"
"}\n",
SkSL::Program::kGeometry_Kind);
}
DEF_TEST(SkSLNormalization, r) {
test(r,
"uniform float4 sk_RTAdjust; void main() { sk_Position = half4(1); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"uniform vec4 sk_RTAdjust;\n"
"void main() {\n"
" gl_Position = vec4(1.0);\n"
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * "
"sk_RTAdjust.yw, 0.0, gl_Position.w);\n"
"}\n",
SkSL::Program::kVertex_Kind);
test(r,
"uniform float4 sk_RTAdjust;"
"layout(points) in;"
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void main() {"
"sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"EndPrimitive();"
"}",
*SkSL::ShaderCapsFactory::GeometryShaderSupport(),
"#version 400\n"
"uniform vec4 sk_RTAdjust;\n"
"layout (points) in ;\n"
"layout (invocations = 2) in ;\n"
"layout (line_strip, max_vertices = 2) out ;\n"
"void main() {\n"
" gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));\n"
" {\n"
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * "
"sk_RTAdjust.yw, 0.0, gl_Position.w);\n"
" EmitVertex();\n"
" }\n"
" gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(gl_InvocationID));\n"
" {\n"
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * "
"sk_RTAdjust.yw, 0.0, gl_Position.w);\n"
" EmitVertex();\n"
" }\n"
" EndPrimitive();\n"
"}\n",
SkSL::Program::kGeometry_Kind);
}
DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
test(r,
"uniform sampler2D tex;"

View File

@ -0,0 +1,13 @@
/*#pragma settings GeometryShaderSupport*/
layout(points) in;
layout(invocations = 2) in;
layout(line_strip, max_vertices = 2) out;
void main() {
sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);
EmitVertex();
sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,11 @@
/*#pragma settings GeometryShaderExtensionString*/
layout(points, invocations = 2) in;
layout(invocations = 3) in;
layout(line_strip, max_vertices = 2) out;
void main() {
sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,11 @@
/*#pragma settings GSInvocationsExtensionString*/
layout(points, invocations = 2) in;
layout(invocations = 3) in;
layout(line_strip, max_vertices = 2) out;
void main() {
sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,16 @@
/*#pragma settings NoGSInvocationsSupport*/
layout(points) in;
layout(invocations = 2) in;
layout(line_strip, max_vertices = 2) out;
void test() {
sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);
EmitVertex();
}
void main() {
test();
sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);
EmitVertex();
}

View File

@ -0,0 +1,14 @@
/*#pragma settings GeometryShaderSupport*/
uniform float4 sk_RTAdjust;
layout(points) in;
layout(invocations = 2) in;
layout(line_strip, max_vertices = 2) out;
void main() {
sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);
EmitVertex();
sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,5 @@
uniform float4 sk_RTAdjust;
void main() {
sk_Position = half4(1);
}

View File

@ -0,0 +1,11 @@
#version 400
layout (points) in ;
layout (invocations = 2) in ;
layout (line_strip, max_vertices = 2) out ;
void main() {
gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(gl_InvocationID));
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,10 @@
#version 310es
#extension GL_EXT_geometry_shader : require
layout (points, invocations = 2) in ;
layout (invocations = 3) in ;
layout (line_strip, max_vertices = 2) out ;
void main() {
gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,10 @@
#version 400
#extension GL_ARB_gpu_shader5 : require
layout (points, invocations = 2) in ;
layout (invocations = 3) in ;
layout (line_strip, max_vertices = 2) out ;
void main() {
gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,20 @@
#version 400
int sk_InvocationID;
layout (points) in ;
layout (line_strip, max_vertices = 4) out ;
void _invoke() {
{
gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(sk_InvocationID));
EmitVertex();
}
gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(sk_InvocationID));
EmitVertex();
}
void main() {
for (sk_InvocationID = 0;sk_InvocationID < 2; sk_InvocationID++) {
_invoke();
EndPrimitive();
}
}

View File

@ -0,0 +1,18 @@
#version 400
uniform vec4 sk_RTAdjust;
layout (points) in ;
layout (invocations = 2) in ;
layout (line_strip, max_vertices = 2) out ;
void main() {
gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));
{
gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
EmitVertex();
}
gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(gl_InvocationID));
{
gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
EmitVertex();
}
EndPrimitive();
}

View File

@ -0,0 +1,6 @@
uniform vec4 sk_RTAdjust;
void main() {
gl_Position = vec4(1.0);
gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
}