From: Neil Roberts <nrobe...@igalia.com> This is a somewhat convoluted test to catch a particular problem with the code we were using to assign a uniform index to a variable. A uniform’s location starts off being the explicit location. Previously while recursing through the uniform’s type, whenever the location matches the current calculated location we were setting it to the index. However, if the calculated index happens to match a calculated location then it would set the index a second time and get it wrong.
Note: This probably shouldn’t be merged into Piglit master because it’s a bit too specific to a temporary problem we had in Mesa. --- .../uniform/index-matches-location.shader_test | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test diff --git a/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test b/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test new file mode 100644 index 000000000..3b2e894cf --- /dev/null +++ b/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test @@ -0,0 +1,100 @@ +# This is a somewhat convoluted test to catch a particular problem +# with the code we were using to assign a uniform index to a variable. +# A uniform’s location starts off being the explicit location. +# Previously while recursing through the uniform’s type, whenever the +# location matches the current calculated location we were setting it +# to the index. However, if the calculated index happens to match a +# calculated location then it would set the index a second time and +# get it wrong. + +[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: 28 +; 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 %a "a" + OpName %_ "" + OpMemberName %_ 0 "b" + OpMemberName %_ 1 "c" + OpName %s "s" + OpDecorate %outcolor Location 0 + OpDecorate %a Location 2 + OpDecorate %s Location 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 + %float_0 = OpConstant %float 0 +%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float + %a = OpVariable %_ptr_UniformConstant_float UniformConstant + %_ = OpTypeStruct %float %float +%_ptr_UniformConstant__ = OpTypePointer UniformConstant %_ + %s = OpVariable %_ptr_UniformConstant__ UniformConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 + %main = OpFunction %void None %3 + %5 = OpLabel + %13 = OpLoad %float %a + %19 = OpAccessChain %_ptr_UniformConstant_float %s %int_0 + %20 = OpLoad %float %19 + %21 = OpFAdd %float %13 %20 + %23 = OpAccessChain %_ptr_UniformConstant_float %s %int_1 + %24 = OpLoad %float %23 + %25 = OpFAdd %float %21 %24 + %27 = OpCompositeConstruct %v4float %float_0 %25 %float_0 %float_1 + OpStore %outcolor %27 + OpReturn + OpFunctionEnd + +[fragment shader] +#version 450 + +// This ends up with index 0 +layout (location = 2) uniform float a; + +// This ends up with index 1 +layout (location = 0) uniform struct { + // index 1, location 0 + float b; + // index 2, location 1 + // -> this matches previous index, location gets set again + float c; +} s; + +layout(location = 0) out vec4 outcolor; + +void main() { + outcolor = vec4(0.0, a + s.b + s.c, 0.0, 1.0); +} + +[test] +clear color 1.0 0.0 0.0 0.0 +clear + +uniform float 0 0.1 +uniform float 1 0.6 +uniform float 2 0.25 + +draw rect -1 -1 2 2 +probe all rgba 0.0 0.95 0.0 1.0 -- 2.14.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit