aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2021-02-02 16:18:47 -0800
committerIan Romanick <ian.d.romanick@intel.com>2021-03-26 15:50:01 -0700
commit5f9b25c69ec13547bd9469b5f59826d1916ead2c (patch)
tree8f11b26244fb9f1bbbf74acb4759e1bf55d31a6f
parent8acd9d0833065b4c5dae92e1c7dd5e320e108eca (diff)
downloadpiglit-5f9b25c69ec13547bd9469b5f59826d1916ead2c.tar.gz
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: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/469>
-rw-r--r--tests/spec/arb_gpu_shader_int64/fs-iand-of-iadd-int64.shader_test36
1 files changed, 36 insertions, 0 deletions
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