From bed16d2f32096a17e12ed55799a99fcb9a5d7208 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 4 Feb 2021 18:03:07 -0800 Subject: glsl-1.30: test right-shift of a left-shift This catches a bug in the original version of mesa!8852. Part-of: --- .../fs-shift-right-of-shift-left.shader_test | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/spec/glsl-1.30/execution/fs-shift-right-of-shift-left.shader_test diff --git a/tests/spec/glsl-1.30/execution/fs-shift-right-of-shift-left.shader_test b/tests/spec/glsl-1.30/execution/fs-shift-right-of-shift-left.shader_test new file mode 100644 index 000000000..c70caa145 --- /dev/null +++ b/tests/spec/glsl-1.30/execution/fs-shift-right-of-shift-left.shader_test @@ -0,0 +1,40 @@ +[require] +GLSL >= 1.30 + +[vertex shader passthrough] + +[fragment shader] +out vec4 piglit_fragcolor; + +void main() +{ + /* The scale factor and the bias values ensure that every fragment will + * generate a value larger than (1 << 26). This is crafted fairly + * carefully to avoid other algebraic optimizations getting in the way. + */ + uint a = (uint(gl_FragCoord.x) + 9011u) * + (uint(gl_FragCoord.y) + 9013u); + + /* This should effectively mask off the high six bits, but leave + * the remaining bits intact. + */ + uint b = (a << 6u) >> 6u; + + if (b > (1u << 26)) + piglit_fragcolor = vec4(1.0, 0.0, 0.0, 1.0); + else { + /* (a ^ b) should result in the high 6-bits from a. */ + uint c = (a ^ b) % (1u << 26); + if (c != 0u) + piglit_fragcolor = vec4(0.0, 0.0, 1.0, 1.0); + else + piglit_fragcolor = vec4(0.0, 1.0, 0.0, 1.0); + } +} + +[test] +clear color 0.3 0.3 0.3 0.0 +clear + +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 -- cgit v1.2.3