diff options
author | Danylo Piliaiev <danylo.piliaiev@globallogic.com> | 2020-08-21 13:33:55 +0300 |
---|---|---|
committer | Danylo Piliaiev <dpiliaiev@igalia.com> | 2022-03-17 15:09:42 +0200 |
commit | 1cceaf58e12ecf8d0ffbc55e5fcd93c11e992f27 (patch) | |
tree | 4458dfb78b88854302d020c6adb78404810835bd /tests/spec | |
parent | 7891265d8f0e9012d44225d99d5d5011669439c3 (diff) |
arb_gpu_shader5: Test out-of-bounds access to gl_SampleMaskIn
From section 5.7 "Structure and Array Operations" of the GLSL 1.30 spec:
"Behavior is undefined if a shader subscripts an array with an index less
than 0 or greater than or equal to the size the array was declared with."
The behaviour becomes defined only in robustness extensions, however even
if driver is technically allowed to crash or hang, it most likely
doesn't want to.
gl_SampleMaskIn may be handled differently in a driver than ordinary arrays.
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/373>
Diffstat (limited to 'tests/spec')
-rw-r--r-- | tests/spec/arb_gpu_shader5/execution/samplemaskin-out-of-bounds.shader_test | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/spec/arb_gpu_shader5/execution/samplemaskin-out-of-bounds.shader_test b/tests/spec/arb_gpu_shader5/execution/samplemaskin-out-of-bounds.shader_test new file mode 100644 index 000000000..024ebae8e --- /dev/null +++ b/tests/spec/arb_gpu_shader5/execution/samplemaskin-out-of-bounds.shader_test @@ -0,0 +1,44 @@ +/* From section 5.7 "Structure and Array Operations" of the GLSL 1.50 spec: + * + * "Behavior is undefined if a shader subscripts an array with an index less + * than 0 or greater than or equal to the size the array was declared with." + * + * The behaviour becomes defined only in robustness extensions, however even + * if driver is technically allowed to crash or hang, it most likely + * doesn't want to. + * + * gl_SampleMaskIn may be handled differently in a driver than ordinary arrays. + */ + +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader5 + +[vertex shader passthrough] + +[fragment shader] +#extension GL_ARB_gpu_shader5 : enable + +out vec4 color; + +void main() +{ + int x = 0; + + int idx1 = -1; + x += gl_SampleMaskIn[idx1]; + + int idx2 = 2147483647; + x += gl_SampleMaskIn[idx2]; + + int idx3 = 2147483647; + x += gl_SampleMaskIn[idx3 > 0 ? idx3 : -1]; + + int idx4 = -1; + x += gl_SampleMaskIn[idx4 * idx4 * idx4]; + + color = vec4(x); +} + +[test] +draw rect -1 -1 2 2 |