diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2021-02-04 18:03:07 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2021-03-26 15:50:01 -0700 |
commit | bed16d2f32096a17e12ed55799a99fcb9a5d7208 (patch) | |
tree | 25fcf6b3bb247503b4b419d395928ace15db23f3 | |
parent | 5f9b25c69ec13547bd9469b5f59826d1916ead2c (diff) | |
download | piglit-bed16d2f32096a17e12ed55799a99fcb9a5d7208.tar.gz |
glsl-1.30: test right-shift of a left-shift
This catches a bug in the original version of mesa!8852.
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/469>
-rw-r--r-- | tests/spec/glsl-1.30/execution/fs-shift-right-of-shift-left.shader_test | 40 |
1 files changed, 40 insertions, 0 deletions
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 |