[Piglit] [PATCH 31/63] arb_gl_spirv: Add a test for matching a block by location with SSOs

Alejandro PiƱeiro apinheiro at igalia.com
Sat Feb 23 23:45:19 UTC 2019


From: Neil Roberts <nroberts at igalia.com>

This is copied from
arb_enhanced_layouts/execution/block-member-locations
---
 ...o-block-member-layout-location.shader_test | 257 ++++++++++++++++++
 1 file changed, 257 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test b/tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test
new file mode 100644
index 000000000..a796252c8
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test
@@ -0,0 +1,257 @@
+// Test that interface block members are correctly matched by explicit
+// location.
+//
+// This is copied from arb_enhanced_layouts/execution/block-member-locations/
+
+[require]
+SPIRV YES
+GLSL >= 4.40
+SSO ENABLED
+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: 40
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %main "main" %name %_ %piglit_vertex %gl_VertexID %gl_InstanceID
+               OpSource GLSL 450
+               OpName %main "main"
+               OpName %block "block"
+               OpMemberName %block 0 "c"
+               OpMemberName %block 1 "d"
+               OpMemberName %block 2 "a"
+               OpMemberName %block 3 "b"
+               OpName %name "name"
+               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"
+               OpMemberDecorate %block 0 Location 2
+               OpMemberDecorate %block 1 Location 3
+               OpMemberDecorate %block 2 Location 0
+               OpMemberDecorate %block 3 Location 1
+               OpDecorate %block Block
+               OpDecorate %name Location 0
+               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
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+      %block = OpTypeStruct %v4float %v4float %v4float %v4float
+%_ptr_Output_block = OpTypePointer Output %block
+       %name = OpVariable %_ptr_Output_block Output
+        %int = OpTypeInt 32 1
+      %int_2 = OpConstant %int 2
+    %float_1 = OpConstant %float 1
+    %float_0 = OpConstant %float 0
+         %15 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+      %int_3 = OpConstant %int 3
+         %19 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+      %int_0 = OpConstant %int 0
+         %22 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
+      %int_1 = OpConstant %int 1
+         %25 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+       %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
+%_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
+         %17 = OpAccessChain %_ptr_Output_v4float %name %int_2
+               OpStore %17 %15
+         %20 = OpAccessChain %_ptr_Output_v4float %name %int_3
+               OpStore %20 %19
+         %23 = OpAccessChain %_ptr_Output_v4float %name %int_0
+               OpStore %23 %22
+         %26 = OpAccessChain %_ptr_Output_v4float %name %int_1
+               OpStore %26 %25
+         %35 = OpLoad %v4float %piglit_vertex
+         %36 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+               OpStore %36 %35
+               OpReturn
+               OpFunctionEnd
+
+[vertex shader]
+#version 440
+
+in vec4 piglit_vertex;
+
+layout(location = 0) out block {
+	layout(location = 2) vec4 c;
+	vec4 d;
+	layout(location = 0) vec4 a;
+	vec4 b;
+} name;
+
+void main()
+{
+	name.a = vec4(1.0, 0.0, 0.0, 1.0);
+	name.b = vec4(0.0, 1.0, 0.0, 1.0);
+	name.c = vec4(0.0, 0.0, 1.0, 1.0);
+	name.d = vec4(1.0, 1.0, 1.0, 1.0);
+
+	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; 6
+; Bound: 46
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %main "main" %color %a %b %c %d
+               OpExecutionMode %main OriginLowerLeft
+               OpSource GLSL 450
+               OpName %main "main"
+               OpName %i "i"
+               OpName %color "color"
+               OpName %a "a"
+               OpName %b "b"
+               OpName %c "c"
+               OpName %d "d"
+               OpDecorate %i Location 0
+               OpDecorate %i DescriptorSet 0
+               OpDecorate %color Location 0
+               OpDecorate %a Location 0
+               OpDecorate %b Location 1
+               OpDecorate %c Location 2
+               OpDecorate %d Location 3
+       %void = OpTypeVoid
+          %3 = OpTypeFunction %void
+        %int = OpTypeInt 32 1
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+          %i = OpVariable %_ptr_UniformConstant_int UniformConstant
+      %int_0 = OpConstant %int 0
+       %bool = OpTypeBool
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+      %color = OpVariable %_ptr_Output_v4float Output
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+          %a = OpVariable %_ptr_Input_v4float Input
+      %int_1 = OpConstant %int 1
+          %b = OpVariable %_ptr_Input_v4float Input
+      %int_2 = OpConstant %int 2
+          %c = OpVariable %_ptr_Input_v4float Input
+      %int_3 = OpConstant %int 3
+          %d = OpVariable %_ptr_Input_v4float Input
+       %main = OpFunction %void None %3
+          %5 = OpLabel
+          %9 = OpLoad %int %i
+         %12 = OpIEqual %bool %9 %int_0
+               OpSelectionMerge %14 None
+               OpBranchConditional %12 %13 %22
+         %13 = OpLabel
+         %21 = OpLoad %v4float %a
+               OpStore %color %21
+               OpBranch %14
+         %22 = OpLabel
+         %23 = OpLoad %int %i
+         %25 = OpIEqual %bool %23 %int_1
+               OpSelectionMerge %27 None
+               OpBranchConditional %25 %26 %30
+         %26 = OpLabel
+         %29 = OpLoad %v4float %b
+               OpStore %color %29
+               OpBranch %27
+         %30 = OpLabel
+         %31 = OpLoad %int %i
+         %33 = OpIEqual %bool %31 %int_2
+               OpSelectionMerge %35 None
+               OpBranchConditional %33 %34 %38
+         %34 = OpLabel
+         %37 = OpLoad %v4float %c
+               OpStore %color %37
+               OpBranch %35
+         %38 = OpLabel
+         %39 = OpLoad %int %i
+         %41 = OpIEqual %bool %39 %int_3
+               OpSelectionMerge %43 None
+               OpBranchConditional %41 %42 %43
+         %42 = OpLabel
+         %45 = OpLoad %v4float %d
+               OpStore %color %45
+               OpBranch %43
+         %43 = OpLabel
+               OpBranch %35
+         %35 = OpLabel
+               OpBranch %27
+         %27 = OpLabel
+               OpBranch %14
+         %14 = OpLabel
+               OpReturn
+               OpFunctionEnd
+
+[fragment shader]
+#version 440
+
+layout(location = 0) in vec4 a;
+layout(location = 1) in vec4 b;
+layout(location = 2) in vec4 c;
+layout(location = 3) in vec4 d;
+
+layout(location = 0) uniform int i;
+
+out vec4 color;
+
+void main()
+{
+	if (i == 0) {
+		color = a;
+	} else if (i == 1) {
+		color = b;
+	} else if (i == 2) {
+		color = c;
+	} else if (i == 3) {
+		color = d;
+	}
+}
+
+[test]
+active shader program GL_FRAGMENT_SHADER
+
+uniform int 0 0
+draw rect -1 -1 1 1
+relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (1.0, 0.0, 0.0)
+
+uniform int 0 1
+draw rect 0 -1 1 1
+relative probe rect rgb (0.5, 0.0, 0.5, 0.5) (0.0, 1.0, 0.0)
+
+uniform int 0 2
+draw rect -1 0 1 1
+relative probe rect rgb (0.0, 0.5, 0.5, 0.5) (0.0, 0.0, 1.0)
+
+uniform int 0 3
+draw rect 0 0 1 1
+relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (1.0, 1.0, 1.0)
-- 
2.19.1



More information about the Piglit mailing list