[Piglit] [PATCH 37/63] arb_gl_spirv: Add tests for the gl_FragCoord origin
Alejandro Piñeiro
apinheiro at igalia.com
Sat Feb 23 23:45:25 UTC 2019
From: Neil Roberts <nroberts at igalia.com>
Using OriginLowerLeft isn’t allowed on Vulkan but explicitly allowed
by ARB_gl_spirv so it’s probably worth testing.
---
.../execution/origin-lower-left.shader_test | 191 +++++++++++++++++
.../execution/origin-upper-left.shader_test | 192 ++++++++++++++++++
2 files changed, 383 insertions(+)
create mode 100644 tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test
create mode 100644 tests/spec/arb_gl_spirv/execution/origin-upper-left.shader_test
diff --git a/tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test b/tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test
new file mode 100644
index 000000000..4dc15256d
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test
@@ -0,0 +1,191 @@
+# Tests that OriginLowerLeft works. This isn’t allowed on Vulkan but
+# is explicitly allowed on ARB_gl_spirv so it’s probably worth
+# testing.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 26
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %main "main" %_ %pos_in %pos_out %gl_VertexID %gl_InstanceID
+ OpSource GLSL 450
+ OpName %main "main"
+ OpName %gl_PerVertex "gl_PerVertex"
+ OpMemberName %gl_PerVertex 0 "gl_Position"
+ OpMemberName %gl_PerVertex 1 "gl_PointSize"
+ OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+ OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+ OpName %_ ""
+ OpName %pos_in "pos_in"
+ OpName %pos_out "pos_out"
+ OpName %gl_VertexID "gl_VertexID"
+ OpName %gl_InstanceID "gl_InstanceID"
+ OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+ OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+ OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+ OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+ OpDecorate %gl_PerVertex Block
+ OpDecorate %pos_in Location 0
+ OpDecorate %pos_out Location 0
+ OpDecorate %gl_VertexID BuiltIn VertexId
+ OpDecorate %gl_InstanceID BuiltIn InstanceId
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+ %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+ %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+ %int = OpTypeInt 32 1
+ %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+ %pos_in = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %pos_out = OpVariable %_ptr_Output_v4float Output
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %18 = OpLoad %v4float %pos_in
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+ OpStore %20 %18
+ %22 = OpLoad %v4float %pos_in
+ OpStore %pos_out %22
+ OpReturn
+ OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 pos_in;
+layout(location = 0) out vec4 pos_out;
+
+void
+main()
+{
+ gl_Position = pos_in;
+ pos_out = pos_in;
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 51
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %main "main" %gl_FragCoord %pos_in %color_out
+ OpExecutionMode %main OriginLowerLeft
+ OpSource GLSL 450
+ OpName %main "main"
+ OpName %frag_coord "frag_coord"
+ OpName %gl_FragCoord "gl_FragCoord"
+ OpName %pos_in "pos_in"
+ OpName %color_out "color_out"
+ OpDecorate %gl_FragCoord BuiltIn FragCoord
+ OpDecorate %pos_in Location 0
+ OpDecorate %color_out Location 0
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %float = OpTypeFloat 32
+ %v2float = OpTypeVector %float 2
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %v4float = OpTypeVector %float 4
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%gl_FragCoord = OpVariable %_ptr_Input_v4float Input
+ %float_125 = OpConstant %float 125
+ %bool = OpTypeBool
+ %pos_in = OpVariable %_ptr_Input_v4float Input
+ %uint = OpTypeInt 32 0
+ %uint_0 = OpConstant %uint 0
+%_ptr_Input_float = OpTypePointer Input %float
+%_ptr_Function_float = OpTypePointer Function %float
+ %uint_1 = OpConstant %uint 1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %color_out = OpVariable %_ptr_Output_v4float Output
+ %float_0 = OpConstant %float 0
+ %float_1 = OpConstant %float 1
+ %48 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+ %50 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %frag_coord = OpVariable %_ptr_Function_v2float Function
+ %13 = OpLoad %v4float %gl_FragCoord
+ %14 = OpVectorShuffle %v2float %13 %13 0 1
+ %16 = OpCompositeConstruct %v2float %float_125 %float_125
+ %17 = OpFSub %v2float %14 %16
+ OpStore %frag_coord %17
+ %23 = OpAccessChain %_ptr_Input_float %pos_in %uint_0
+ %24 = OpLoad %float %23
+ %25 = OpExtInst %float %1 FSign %24
+ %27 = OpAccessChain %_ptr_Function_float %frag_coord %uint_0
+ %28 = OpLoad %float %27
+ %29 = OpExtInst %float %1 FSign %28
+ %30 = OpFOrdEqual %bool %25 %29
+ OpSelectionMerge %32 None
+ OpBranchConditional %30 %31 %32
+ %31 = OpLabel
+ %34 = OpAccessChain %_ptr_Input_float %pos_in %uint_1
+ %35 = OpLoad %float %34
+ %36 = OpExtInst %float %1 FSign %35
+ %37 = OpAccessChain %_ptr_Function_float %frag_coord %uint_1
+ %38 = OpLoad %float %37
+ %39 = OpExtInst %float %1 FSign %38
+ %40 = OpFOrdEqual %bool %36 %39
+ OpBranch %32
+ %32 = OpLabel
+ %41 = OpPhi %bool %30 %5 %40 %31
+ OpSelectionMerge %43 None
+ OpBranchConditional %41 %42 %49
+ %42 = OpLabel
+ OpStore %color_out %48
+ OpBranch %43
+ %49 = OpLabel
+ OpStore %color_out %50
+ OpBranch %43
+ %43 = OpLabel
+ OpReturn
+ OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) in vec4 pos_in;
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+ vec2 frag_coord = gl_FragCoord.xy - 125.0;
+
+ if (sign(pos_in.x) == sign(frag_coord.x) &&
+ sign(pos_in.y) == sign(frag_coord.y))
+ color_out = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ color_out = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+clear color 0.8 0.0 0.0 0.0
+clear
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_gl_spirv/execution/origin-upper-left.shader_test b/tests/spec/arb_gl_spirv/execution/origin-upper-left.shader_test
new file mode 100644
index 000000000..8af814d1a
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/origin-upper-left.shader_test
@@ -0,0 +1,192 @@
+# Tests that OriginUpperLeft works.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 26
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %main "main" %_ %pos_in %pos_out %gl_VertexID %gl_InstanceID
+ OpSource GLSL 450
+ OpName %main "main"
+ OpName %gl_PerVertex "gl_PerVertex"
+ OpMemberName %gl_PerVertex 0 "gl_Position"
+ OpMemberName %gl_PerVertex 1 "gl_PointSize"
+ OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+ OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+ OpName %_ ""
+ OpName %pos_in "pos_in"
+ OpName %pos_out "pos_out"
+ OpName %gl_VertexID "gl_VertexID"
+ OpName %gl_InstanceID "gl_InstanceID"
+ OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+ OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+ OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+ OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+ OpDecorate %gl_PerVertex Block
+ OpDecorate %pos_in Location 0
+ OpDecorate %pos_out Location 0
+ OpDecorate %gl_VertexID BuiltIn VertexId
+ OpDecorate %gl_InstanceID BuiltIn InstanceId
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+ %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+ %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+ %int = OpTypeInt 32 1
+ %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+ %pos_in = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %pos_out = OpVariable %_ptr_Output_v4float Output
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %18 = OpLoad %v4float %pos_in
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+ OpStore %20 %18
+ %22 = OpLoad %v4float %pos_in
+ OpStore %pos_out %22
+ OpReturn
+ OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 pos_in;
+layout(location = 0) out vec4 pos_out;
+
+void
+main()
+{
+ gl_Position = pos_in;
+ pos_out = pos_in;
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 52
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %main "main" %gl_FragCoord %pos_in %color_out
+ OpExecutionMode %main OriginUpperLeft
+ OpSource GLSL 450
+ OpName %main "main"
+ OpName %frag_coord "frag_coord"
+ OpName %gl_FragCoord "gl_FragCoord"
+ OpName %pos_in "pos_in"
+ OpName %color_out "color_out"
+ OpDecorate %gl_FragCoord BuiltIn FragCoord
+ OpDecorate %pos_in Location 0
+ OpDecorate %color_out Location 0
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %float = OpTypeFloat 32
+ %v2float = OpTypeVector %float 2
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %v4float = OpTypeVector %float 4
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%gl_FragCoord = OpVariable %_ptr_Input_v4float Input
+ %float_125 = OpConstant %float 125
+ %bool = OpTypeBool
+ %pos_in = OpVariable %_ptr_Input_v4float Input
+ %uint = OpTypeInt 32 0
+ %uint_0 = OpConstant %uint 0
+%_ptr_Input_float = OpTypePointer Input %float
+%_ptr_Function_float = OpTypePointer Function %float
+ %uint_1 = OpConstant %uint 1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %color_out = OpVariable %_ptr_Output_v4float Output
+ %float_0 = OpConstant %float 0
+ %float_1 = OpConstant %float 1
+ %49 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+ %51 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %frag_coord = OpVariable %_ptr_Function_v2float Function
+ %13 = OpLoad %v4float %gl_FragCoord
+ %14 = OpVectorShuffle %v2float %13 %13 0 1
+ %16 = OpCompositeConstruct %v2float %float_125 %float_125
+ %17 = OpFSub %v2float %14 %16
+ OpStore %frag_coord %17
+ %23 = OpAccessChain %_ptr_Input_float %pos_in %uint_0
+ %24 = OpLoad %float %23
+ %25 = OpExtInst %float %1 FSign %24
+ %27 = OpAccessChain %_ptr_Function_float %frag_coord %uint_0
+ %28 = OpLoad %float %27
+ %29 = OpExtInst %float %1 FSign %28
+ %30 = OpFOrdEqual %bool %25 %29
+ OpSelectionMerge %32 None
+ OpBranchConditional %30 %31 %32
+ %31 = OpLabel
+ %34 = OpAccessChain %_ptr_Input_float %pos_in %uint_1
+ %35 = OpLoad %float %34
+ %36 = OpExtInst %float %1 FSign %35
+ %37 = OpAccessChain %_ptr_Function_float %frag_coord %uint_1
+ %38 = OpLoad %float %37
+ %39 = OpExtInst %float %1 FSign %38
+ %40 = OpFNegate %float %39
+ %41 = OpFOrdEqual %bool %36 %40
+ OpBranch %32
+ %32 = OpLabel
+ %42 = OpPhi %bool %30 %5 %41 %31
+ OpSelectionMerge %44 None
+ OpBranchConditional %42 %43 %50
+ %43 = OpLabel
+ OpStore %color_out %49
+ OpBranch %44
+ %50 = OpLabel
+ OpStore %color_out %51
+ OpBranch %44
+ %44 = OpLabel
+ OpReturn
+ OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(origin_upper_left) in vec4 gl_FragCoord;
+
+layout(location = 0) in vec4 pos_in;
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+ vec2 frag_coord = gl_FragCoord.xy - 125.0;
+
+ if (sign(pos_in.x) == sign(frag_coord.x) &&
+ sign(pos_in.y) == -sign(frag_coord.y))
+ color_out = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ color_out = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+clear color 0.8 0.0 0.0 0.0
+clear
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
--
2.19.1
More information about the Piglit
mailing list