arb_gl_spirv: add array test with copy between arrays

Submitted by apinheiro on Oct. 1, 2018, 4:20 p.m.

Details

Message ID 20181001162031.8581-1-apinheiro@igalia.com
State New
Headers show

Not browsing as part of any series.

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test b/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test
new file mode 100644
index 000000000..f8ed845eb
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test
@@ -0,0 +1,137 @@ 
+# UBO test using an array inside an ubos, and an temporal array that
+# copy from it.
+
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[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; 7
+; Bound: 45
+; Schema: 0
+               OpCapability Shader
+          %1 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %main "main" %color
+               OpExecutionMode %main OriginLowerLeft
+               OpSource GLSL 450
+               OpName %_ ""
+               OpDecorate %_arr_v4float_uint_4_0 ArrayStride 16
+               OpMemberDecorate %Block 0 Offset 0
+               OpDecorate %Block Block
+               OpDecorate %_ DescriptorSet 0
+               OpDecorate %_ Binding 6
+               OpDecorate %color Location 0
+               OpDecorate %index Location 4
+               OpDecorate %index DescriptorSet 0
+               OpDecorate %index Binding 0
+       %void = OpTypeVoid
+          %3 = OpTypeFunction %void
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+       %uint = OpTypeInt 32 0
+     %uint_4 = OpConstant %uint 4
+%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
+%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function %_arr_v4float_uint_4
+%_arr_v4float_uint_4_0 = OpTypeArray %v4float %uint_4
+      %Block = OpTypeStruct %_arr_v4float_uint_4_0
+%_ptr_Uniform_Block = OpTypePointer Uniform %Block
+          %_ = OpVariable %_ptr_Uniform_Block Uniform
+        %int = OpTypeInt 32 1
+      %int_0 = OpConstant %int 0
+%_ptr_Uniform__arr_v4float_uint_4_0 = OpTypePointer Uniform %_arr_v4float_uint_4_0
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+      %int_1 = OpConstant %int 1
+      %int_2 = OpConstant %int 2
+      %int_3 = OpConstant %int 3
+    %float_1 = OpConstant %float 1
+    %float_0 = OpConstant %float 0
+         %36 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+      %color = OpVariable %_ptr_Output_v4float Output
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+      %index = OpVariable %_ptr_UniformConstant_int UniformConstant
+       %main = OpFunction %void None %3
+          %5 = OpLabel
+       %temp = OpVariable %_ptr_Function__arr_v4float_uint_4 Function
+         %20 = OpAccessChain %_ptr_Uniform__arr_v4float_uint_4_0 %_ %int_0
+         %21 = OpLoad %_arr_v4float_uint_4_0 %20
+         %22 = OpCompositeExtract %v4float %21 0
+         %24 = OpAccessChain %_ptr_Function_v4float %temp %int_0
+               OpStore %24 %22
+         %25 = OpCompositeExtract %v4float %21 1
+         %27 = OpAccessChain %_ptr_Function_v4float %temp %int_1
+               OpStore %27 %25
+         %28 = OpCompositeExtract %v4float %21 2
+         %30 = OpAccessChain %_ptr_Function_v4float %temp %int_2
+               OpStore %30 %28
+         %31 = OpCompositeExtract %v4float %21 3
+         %33 = OpAccessChain %_ptr_Function_v4float %temp %int_3
+               OpStore %33 %31
+         %37 = OpAccessChain %_ptr_Function_v4float %temp %int_0
+               OpStore %37 %36
+         %42 = OpLoad %int %index
+         %43 = OpAccessChain %_ptr_Function_v4float %temp %42
+         %44 = OpLoad %v4float %43
+               OpStore %color %44
+               OpReturn
+               OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 4) uniform int index;
+
+layout (location = 0) out vec4 color;
+
+layout (std140, binding = 6) uniform Block {
+	vec4 colors[4];
+};
+
+void main()
+{
+	vec4 temp[4] = colors;
+	temp[0] = vec4(1.0, 0.0, 0.0, 0.0);
+	color = temp[index];
+}
+
+[test]
+
+block binding 6
+block offset 0
+uniform vec4 colors[0] 0.0 0.0 0.0 0.0
+block offset 16
+uniform vec4 colors[1] 0.0 1.0 0.0 0.0
+block offset 32
+uniform vec4 colors[2] 0.0 1.0 1.0 0.0
+block offset 48
+uniform vec4 colors[3] 1.0 0.0 1.0 0.0
+
+#index
+uniform int 4 0
+
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 0.0
+
+uniform int 4 1
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 0.0
+
+uniform int 4 2
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 1.0 0.0
+
+uniform int 4 3
+
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 1.0 0.0