For tests that triggered the lowering nir_split_vars to split arrays, we found some crashes on ARB_gl_spirv if we didn't take into account the explicit array stride on the splitted type. This is basically a regression catching test.
This test is based on spec/glsl-1.40/uniform_buffer/fs-array-copy test that was crashing when converted to a SPIR-V shader during the development of ARB_gl_spirv support. --- .../ubo/array-inside-ubo-copy.shader_test | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test 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..14ba9955f --- /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 a temporal array that +# copy from it. + + +[require] +SPIRV YES +GL >= 3.3 +GLSL >= 4.50 +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 -- 2.19.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit