diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2021-02-02 15:52:44 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2021-03-26 15:50:01 -0700 |
commit | 8acd9d0833065b4c5dae92e1c7dd5e320e108eca (patch) | |
tree | 585c5d381bef7766e87170cd4deb0a0221da2a20 | |
parent | d2431a1d9cca62565a16bd5e8f810cef0228593d (diff) | |
download | piglit-8acd9d0833065b4c5dae92e1c7dd5e320e108eca.tar.gz |
arb_gpu_shader_int64: test shift-left of shift-right with same count
There is an optimization in Mesa that converts this to a mask operation.
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 will get chopped off.
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/469>
-rw-r--r-- | tests/spec/arb_gpu_shader_int64/fs-shl-of-shr-int64.shader_test | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/spec/arb_gpu_shader_int64/fs-shl-of-shr-int64.shader_test b/tests/spec/arb_gpu_shader_int64/fs-shl-of-shr-int64.shader_test new file mode 100644 index 000000000..63806d045 --- /dev/null +++ b/tests/spec/arb_gpu_shader_int64/fs-shl-of-shr-int64.shader_test @@ -0,0 +1,43 @@ +[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). It also ensures that at least + * some fragments will have some of the low four bits set. + */ + uint64_t a = uint64_t(int(gl_FragCoord.x) + 8179) * + uint64_t(int(gl_FragCoord.y) + 9931) * 1693ul; + + /* This should effectively mask off the low four bits, but leave + * the bits about the 32-bit boundary intact. + */ + uint64_t b = (a >> 4) << 4; + + if (b < (1ul << 32)) + piglit_fragcolor = vec4(1.0, 0.0, 0.0, 1.0); + else { + /* This tries to avoid a possible optimization of (x & y) & ~y -> 0 */ + uint64_t c = b & 31ul; + if (c != 0ul && c != 16ul) + 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 |