[23/35] arb_gl_spirv: Add a test for an array of structs uniform

Submitted by apinheiro on Aug. 9, 2018, 11:36 a.m.

Details

Message ID 20180809113614.5122-24-apinheiro@igalia.com
State New
Headers show
Series "ARB_gl_spirv: all tests so far" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

apinheiro Aug. 9, 2018, 11:36 a.m.
From: Neil Roberts <nroberts@igalia.com>

---
 .../execution/uniform/struct-array.shader_test     | 140 +++++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test b/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test
new file mode 100644
index 000000000..b237c1c77
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test
@@ -0,0 +1,140 @@ 
+# Tests an array of structs with an explicit uniform location
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[vertex shader passthrough]
+
+[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: 60
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %main "main" %color
+               OpExecutionMode %main OriginLowerLeft
+               OpSource GLSL 450
+               OpName %main "main"
+               OpName %color "color"
+               OpName %i "i"
+               OpName %_ ""
+               OpMemberName %_ 0 "r"
+               OpMemberName %_ 1 "g"
+               OpMemberName %_ 2 "b"
+               OpName %parts "parts"
+               OpDecorate %color Location 0
+               OpDecorate %parts Location 0
+       %void = OpTypeVoid
+          %3 = OpTypeFunction %void
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+      %color = OpVariable %_ptr_Output_v4float Output
+    %float_0 = OpConstant %float 0
+    %float_1 = OpConstant %float 1
+         %12 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
+        %int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+      %int_0 = OpConstant %int 0
+      %int_2 = OpConstant %int 2
+       %bool = OpTypeBool
+          %_ = OpTypeStruct %float %float %float
+       %uint = OpTypeInt 32 0
+     %uint_2 = OpConstant %uint 2
+%_arr___uint_2 = OpTypeArray %_ %uint_2
+%_ptr_UniformConstant__arr___uint_2 = OpTypePointer UniformConstant %_arr___uint_2
+      %parts = OpVariable %_ptr_UniformConstant__arr___uint_2 UniformConstant
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+     %uint_0 = OpConstant %uint 0
+%_ptr_Output_float = OpTypePointer Output %float
+      %int_1 = OpConstant %int 1
+     %uint_1 = OpConstant %uint 1
+       %main = OpFunction %void None %3
+          %5 = OpLabel
+          %i = OpVariable %_ptr_Function_int Function
+               OpStore %color %12
+               OpStore %i %int_0
+               OpBranch %17
+         %17 = OpLabel
+               OpLoopMerge %19 %20 None
+               OpBranch %21
+         %21 = OpLabel
+         %22 = OpLoad %int %i
+         %25 = OpSLessThan %bool %22 %int_2
+               OpBranchConditional %25 %18 %19
+         %18 = OpLabel
+         %32 = OpLoad %int %i
+         %34 = OpAccessChain %_ptr_UniformConstant_float %parts %32 %int_0
+         %35 = OpLoad %float %34
+         %38 = OpAccessChain %_ptr_Output_float %color %uint_0
+         %39 = OpLoad %float %38
+         %40 = OpFAdd %float %39 %35
+         %41 = OpAccessChain %_ptr_Output_float %color %uint_0
+               OpStore %41 %40
+         %42 = OpLoad %int %i
+         %44 = OpAccessChain %_ptr_UniformConstant_float %parts %42 %int_1
+         %45 = OpLoad %float %44
+         %47 = OpAccessChain %_ptr_Output_float %color %uint_1
+         %48 = OpLoad %float %47
+         %49 = OpFAdd %float %48 %45
+         %50 = OpAccessChain %_ptr_Output_float %color %uint_1
+               OpStore %50 %49
+         %51 = OpLoad %int %i
+         %52 = OpAccessChain %_ptr_UniformConstant_float %parts %51 %int_2
+         %53 = OpLoad %float %52
+         %54 = OpAccessChain %_ptr_Output_float %color %uint_2
+         %55 = OpLoad %float %54
+         %56 = OpFAdd %float %55 %53
+         %57 = OpAccessChain %_ptr_Output_float %color %uint_2
+               OpStore %57 %56
+               OpBranch %20
+         %20 = OpLabel
+         %58 = OpLoad %int %i
+         %59 = OpIAdd %int %58 %int_1
+               OpStore %i %59
+               OpBranch %17
+         %19 = OpLabel
+               OpReturn
+               OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform struct {
+	float r;
+	float g;
+	float b;
+} parts[2];
+
+out vec4 color;
+
+void main()
+{
+	color = vec4(0.0, 0.0, 0.0, 1.0);
+
+	for (int i = 0; i < 2; i++) {
+	    color.r += parts[i].r;
+	    color.g += parts[i].g;
+	    color.b += parts[i].b;
+	}
+}
+
+[test]
+clear color 0.2 0.2 0.2 0.2
+clear
+
+uniform float 0 0.1
+uniform float 1 0.2
+uniform float 2 0.3
+uniform float 3 0.4
+uniform float 4 0.5
+uniform float 5 0.6
+
+draw rect -1 -1 2 2
+probe all rgba 0.5 0.7 0.9 1.0