From 5f9b25c69ec13547bd9469b5f59826d1916ead2c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 2 Feb 2021 16:18:47 -0800 Subject: arb_gpu_shader_int64: test masking after addition There is an optimization in Mesa that tries to reassociate these operations to improve the chances of CSE. However, the base mask used is 0xffffffff. This is not correct (but should still work) for 16-bit and 8-bit values, but it means the high 32-bits of 64-bit values won't get chopped off. Part-of: --- .../fs-iand-of-iadd-int64.shader_test | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/spec/arb_gpu_shader_int64/fs-iand-of-iadd-int64.shader_test diff --git a/tests/spec/arb_gpu_shader_int64/fs-iand-of-iadd-int64.shader_test b/tests/spec/arb_gpu_shader_int64/fs-iand-of-iadd-int64.shader_test new file mode 100644 index 000000000..ac24421fe --- /dev/null +++ b/tests/spec/arb_gpu_shader_int64/fs-iand-of-iadd-int64.shader_test @@ -0,0 +1,36 @@ +[require] +GLSL >= 4.00 +GL_ARB_gpu_shader_int64 + +[vertex shader passthrough] + +[fragment shader] +#extension GL_ARB_gpu_shader_int64: require + +out vec4 piglit_fragcolor; + +void main() +{ + /* The scale factor and the bias values ensure that every fragment will + * generate a value larger than (1 << 32). + */ + uint64_t a = uint64_t(int(gl_FragCoord.x) + 8179) * + uint64_t(int(gl_FragCoord.y) + 9931) * 1693ul; + + /* Reassociating the addition and the masking will not have the + * same result. + */ + uint64_t b = (a + 0x0ffffffffffffff0ul) & 0x00000000fffffff0ul; + + if (b >= (1ul << 32)) + piglit_fragcolor = vec4(1.0, 0.0, 0.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