From b85ddb8d7de79bb956ac7399a22767e19e866caf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 7 Jan 2020 10:27:36 -0800 Subject: arb_shader_atomic_counters: Add a test for sparsely-used bindings. Derived from fs-layout, this should hopefully catch the regression I temporarily had in the ssbo-numbering series on the old CTS, which the new CTS didn't find. Reviewed-by: Ian Romanick Tested-by: Marge Bot Part-of: --- .../execution/sparse-binding.shader_test | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/spec/arb_shader_atomic_counters/execution/sparse-binding.shader_test diff --git a/tests/spec/arb_shader_atomic_counters/execution/sparse-binding.shader_test b/tests/spec/arb_shader_atomic_counters/execution/sparse-binding.shader_test new file mode 100644 index 000000000..0ac55c394 --- /dev/null +++ b/tests/spec/arb_shader_atomic_counters/execution/sparse-binding.shader_test @@ -0,0 +1,66 @@ +# Test handling of atomic counters with sparse and reordered bindings. +# Drivers may compact sparse bindings in their descriptors or not, and it's +# easy to break since sparse bindings are uncommon (the CTS used to incidentally +# test this, but in 1d7f9648eada ("Use binding 0 for atomic counter buffers") +# it stopped). + +[require] +GLSL >= 1.40 +GL_ARB_shader_atomic_counters +INT GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS >= 3 + +[vertex shader passthrough] + +[fragment shader] +#version 140 +#extension GL_ARB_shader_atomic_counters: require + +layout(binding = 2, offset = 4) uniform atomic_uint b; +layout(binding = 1, offset = 0) uniform atomic_uint a[2]; + +uniform uint a0_expected; +uniform uint a1_expected; +uniform uint b_expected; +uniform uint idx; + +out vec4 color; + +void main() +{ + uint old_a0 = atomicCounterIncrement(a[0]); + uint old_a1 = atomicCounterIncrement(a[idx]); + uint old_b = atomicCounterIncrement(b); + + if (old_a0 != a0_expected) { + color = vec4(1.0, 0.0, float(old_a0) / 255.0, 1.0); + return; + } + if (old_a1 != a1_expected) { + color = vec4(1.0, 0.1, float(old_a1) / 255.0, 1.0); + return; + } + if (old_b != b_expected) { + color = vec4(1.0, 0.2, float(old_b) / 255.0, 1.0); + return; + } + color = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +atomic counter buffer 1 2 +atomic counter buffer 2 2 + +clear color 0.0 0.0 0.0 0.0 +clear + +atomic counter 1 0 17 +atomic counter 1 1 31 +atomic counter 2 1 4 + +uniform uint a0_expected 17 +uniform uint a1_expected 31 +uniform uint b_expected 4 +uniform uint idx 1 + +draw rect ortho 0 0 1 1 +probe rgba 0 0 0.0 1.0 0.0 1.0 -- cgit v1.2.3