[Piglit] [PATCH 08/25] arb_gl_spirv: Add a test using specializations

Alejandro PiƱeiro apinheiro at igalia.com
Tue Apr 17 14:37:14 UTC 2018


From: Neil Roberts <nroberts at igalia.com>

---
 .../execution/vs-ps-specializations.shader_test    | 181 +++++++++++++++++++++
 1 file changed, 181 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test b/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test
new file mode 100644
index 000000000..7b3e7ee81
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test
@@ -0,0 +1,181 @@
+# Simple shader test using specialization constants
+
+[require]
+GL >= 3.3
+GLSL >= 4.50
+SPIRV ONLY
+
+[vertex shader specializations]
+uint 0 42
+float 1 0.42
+
+[fragment shader specializations]
+float 5 0.0
+float 6 1.0
+float 7 0.0
+
+[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; 4
+; Bound: 44
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %main "main" %_ %piglit_vertex %gl_VertexID %gl_InstanceID
+               OpSource GLSL 450
+               OpName %main "main"
+               OpName %magic_number "magic_number"
+               OpName %magic_float "magic_float"
+               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 %piglit_vertex "piglit_vertex"
+               OpName %gl_VertexID "gl_VertexID"
+               OpName %gl_InstanceID "gl_InstanceID"
+               OpDecorate %magic_number SpecId 0
+               OpDecorate %magic_float SpecId 1
+               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 %piglit_vertex Location 0
+               OpDecorate %gl_VertexID BuiltIn VertexId
+               OpDecorate %gl_InstanceID BuiltIn InstanceId
+       %void = OpTypeVoid
+          %3 = OpTypeFunction %void
+       %bool = OpTypeBool
+       %uint = OpTypeInt 32 0
+%magic_number = OpSpecConstant %uint 0
+    %uint_42 = OpConstant %uint 42
+         %10 = OpSpecConstantOp %bool INotEqual %magic_number %uint_42
+      %float = OpTypeFloat 32
+%magic_float = OpSpecConstant %float 0
+ %float_0_42 = OpConstant %float 0.42
+ %float_0_01 = OpConstant %float 0.01
+    %v4float = OpTypeVector %float 4
+     %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
+    %float_0 = OpConstant %float 0
+         %33 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_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
+         %11 = OpLogicalNot %bool %10
+               OpSelectionMerge %13 None
+               OpBranchConditional %11 %12 %13
+         %12 = OpLabel
+         %17 = OpFSub %float %magic_float %float_0_42
+         %18 = OpExtInst %float %1 FAbs %17
+         %20 = OpFOrdGreaterThan %bool %18 %float_0_01
+               OpBranch %13
+         %13 = OpLabel
+         %21 = OpPhi %bool %10 %5 %20 %12
+               OpSelectionMerge %23 None
+               OpBranchConditional %21 %22 %36
+         %22 = OpLabel
+         %35 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+               OpStore %35 %33
+               OpBranch %23
+         %36 = OpLabel
+         %39 = OpLoad %v4float %piglit_vertex
+         %40 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+               OpStore %40 %39
+               OpBranch %23
+         %23 = OpLabel
+               OpReturn
+               OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 piglit_vertex;
+
+layout(constant_id = 0) const uint magic_number = 0;
+layout(constant_id = 1) const float magic_float = 0;
+
+void main()
+{
+        if (magic_number != 42 ||
+            abs(magic_float - 0.42) > 0.01) {
+                gl_Position = vec4(0.0);
+        } else {
+                gl_Position = piglit_vertex;
+        }
+}
+
+[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; 4
+; Bound: 15
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %main "main" %out_color
+               OpExecutionMode %main OriginLowerLeft
+               OpSource GLSL 450
+               OpName %main "main"
+               OpName %out_color "out_color"
+               OpName %red "red"
+               OpName %green "green"
+               OpName %blue "blue"
+               OpDecorate %out_color Location 0
+               OpDecorate %red SpecId 5
+               OpDecorate %green SpecId 6
+               OpDecorate %blue SpecId 7
+       %void = OpTypeVoid
+          %3 = OpTypeFunction %void
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %out_color = OpVariable %_ptr_Output_v4float Output
+        %red = OpSpecConstant %float 1
+      %green = OpSpecConstant %float 0.3
+       %blue = OpSpecConstant %float 0.3
+    %float_1 = OpConstant %float 1
+       %main = OpFunction %void None %3
+          %5 = OpLabel
+         %14 = OpCompositeConstruct %v4float %red %green %blue %float_1
+               OpStore %out_color %14
+               OpReturn
+               OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(constant_id = 5) const float red = 1.0;
+layout(constant_id = 6) const float green = 0.3;
+layout(constant_id = 7) const float blue = 0.3;
+
+layout(location = 0) out vec4 out_color;
+
+void main()
+{
+        out_color = vec4(red, green, blue, 1.0);
+}
+
+[test]
+clear color 1.0 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.14.1



More information about the Piglit mailing list