From: Neil Roberts <nrobe...@igalia.com> Adds two tests, one which has an explicit offset in GLSL using the layout(offset) decoration on an interface member, and another which has a struct embedded in an interface. On SPIR-V it is possible to set an explicit offset even within this embedded struct (note that this test is SPIR-V ONLY). --- .../explicit-offset-nested-struct.shader_test | 83 +++++++++++++++++++ .../execution/ubo/explicit-offset.shader_test | 82 ++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test
diff --git a/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test new file mode 100644 index 000000000..a23ff21e4 --- /dev/null +++ b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test @@ -0,0 +1,83 @@ +# Test a UBO with a member at an explicit offset. The member is itself +# a struct with its own explicit offset. + +[require] +SPIRV ONLY +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, and then edited manually. DO NOT EDIT +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 20 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %outcolor + OpExecutionMode %main OriginLowerLeft + OpSource GLSL 450 + OpName %main "main" + OpName %outcolor "outcolor" + OpName %InnerThing "InnerThing" + OpMemberName %InnerThing 0 "ignored" + OpMemberName %InnerThing 1 "a" + OpName %Block "Block" + OpMemberName %Block 0 "thing" + OpName %_ "" + OpDecorate %outcolor Location 0 + OpMemberDecorate %InnerThing 0 Offset 0 + OpMemberDecorate %InnerThing 1 Offset 64 + OpMemberDecorate %Block 0 Offset 64 + OpDecorate %Block Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %outcolor = OpVariable %_ptr_Output_v4float Output + %InnerThing = OpTypeStruct %float %v4float + %Block = OpTypeStruct %InnerThing +%_ptr_Uniform_Block = OpTypePointer Uniform %Block + %_ = OpVariable %_ptr_Uniform_Block Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_1 + %19 = OpLoad %v4float %18 + OpStore %outcolor %19 + OpReturn + OpFunctionEnd + +[test] +clear color 0.8 0.0 0.0 1.0 + +# Set the value at a few locations. This shouldn’t affect the result +# unless the shader is ignoring the offset. +block binding 0 +block offset 0 +uniform vec4 a 0.9 0.0 0.0 1.0 +block offset 64 +uniform vec4 a 0.9 0.0 0.0 1.0 +block offset 80 +uniform vec4 a 0.9 0.0 0.0 1.0 + +block offset 128 +uniform vec4 a 0.0 1.0 0.0 1.0 + +verify program_interface_query GL_UNIFORM_BLOCK Block GL_BUFFER_DATA_SIZE 144 +verify program_query GL_ACTIVE_UNIFORMS 2 + +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 + diff --git a/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test new file mode 100644 index 000000000..a2d77fb62 --- /dev/null +++ b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test @@ -0,0 +1,82 @@ +# Test a UBO with a member at an explicit offset + +[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: 18 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %outcolor + OpExecutionMode %main OriginLowerLeft + OpSource GLSL 450 + OpName %_ "" + OpDecorate %outcolor Location 0 + OpMemberDecorate %Block 0 Offset 16 + OpDecorate %Block Block + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %outcolor = OpVariable %_ptr_Output_v4float Output + %Block = OpTypeStruct %v4float +%_ptr_Uniform_Block = OpTypePointer Uniform %Block + %_ = OpVariable %_ptr_Uniform_Block Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 + %17 = OpLoad %v4float %16 + OpStore %outcolor %17 + OpReturn + OpFunctionEnd + +[fragment shader] +#version 450 + +layout(std140, binding = 0) uniform Block { + layout(offset = 16) vec4 a; +}; + +out vec4 outcolor; + +void main() +{ + outcolor = a; +} + +[test] +clear color 0.8 0.0 0.0 1.0 + +# Set the offset at location 0. This shouldn’t affect the result +# unless the shader is ignoring the offset. +block binding 0 +block offset 0 +uniform vec4 a 0.9 0.0 0.0 1.0 + +block binding 0 +block offset 16 +uniform vec4 a 0.0 1.0 0.0 1.0 + +verify program_interface_query GL_UNIFORM_BLOCK Block GL_BUFFER_DATA_SIZE 32 +verify program_query GL_ACTIVE_UNIFORMS 1 + +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 + -- 2.19.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit