[Piglit] [PATCH] arb_gpu_shader_int64: add bit-shift tests

Nicolai Hähnle nhaehnle at gmail.com
Thu Mar 30 15:27:56 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Exposes a bug in st/glsl_to_tgsi.
---
 .../fs-shift-scalar-by-scalar.shader_test          | 78 ++++++++++++++++++++++
 .../fs-shift-vector-by-scalar.shader_test          | 77 +++++++++++++++++++++
 .../fs-shift-vector-by-vector.shader_test          | 77 +++++++++++++++++++++
 3 files changed, 232 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader_int64/execution/fs-shift-scalar-by-scalar.shader_test
 create mode 100644 tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-scalar.shader_test
 create mode 100644 tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-vector.shader_test

diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-shift-scalar-by-scalar.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-shift-scalar-by-scalar.shader_test
new file mode 100644
index 0000000..e66798d
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_int64/execution/fs-shift-scalar-by-scalar.shader_test
@@ -0,0 +1,78 @@
+[require]
+GL >= 4.0
+GLSL >= 4.00
+GL_ARB_gpu_shader_int64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 400
+#extension GL_ARB_gpu_shader_int64 : require
+
+uniform int64_t ival;
+uniform uint64_t uval;
+uniform int shl, shr;
+
+uniform int64_t iexpected_shl;
+uniform int64_t iexpected_shr;
+uniform uint64_t uexpected_shl;
+uniform uint64_t uexpected_shr;
+
+out vec4 color;
+
+void main()
+{
+	int64_t iresult_shl = ival << shl;
+	uint64_t uresult_shl = uval << shl;
+	int64_t iresult_shr = ival >> shr;
+	uint64_t uresult_shr = uval >> shr;
+
+	if (iresult_shl != iexpected_shl)
+		color = vec4(1.0, 0.0, float(iresult_shl) / 255.0, 0.0);
+	else if (iresult_shr != iexpected_shr)
+		color = vec4(1.0, 0.1, float(iresult_shr) / 255.0, 0.0);
+	else if (uresult_shl != uexpected_shl)
+		color = vec4(1.0, 0.2, float(uresult_shl) / 255.0, 0.0);
+	else if (uresult_shr != uexpected_shr)
+		color = vec4(1.0, 0.3, float(uresult_shr) / 255.0, 0.0);
+	else
+		color = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform int64_t ival 3
+uniform uint64_t uval 3
+uniform int shl 1
+uniform int shr 1
+uniform int64_t iexpected_shl 6
+uniform int64_t iexpected_shr 1
+uniform uint64_t uexpected_shl 6
+uniform uint64_t uexpected_shr 1
+draw rect ortho 0 0 4 4
+
+uniform int64_t ival 0x7848302090a0b0c6
+uniform uint64_t uval 0xc01020308090a0b5
+uniform int shl 4
+uniform int shr 4
+uniform int64_t iexpected_shl -0x7b7cfdf6f5f4f3a0 # bit pattern: 0x848302090a0b0c60
+uniform int64_t iexpected_shr 0x07848302090a0b0c
+uniform uint64_t uexpected_shl 0x01020308090a0b50
+uniform uint64_t uexpected_shr 0x0c01020308090a0b
+draw rect ortho 4 0 4 4
+
+uniform int64_t ival -0x7dfcfefbdf6536ff # bit pattern: 0x82030104209ac901
+uniform uint64_t uval 0x1400000085010203
+uniform int shl 8
+uniform int shr 8
+uniform int64_t iexpected_shl 0x030104209ac90100
+uniform int64_t iexpected_shr -0x7dfcfefbdf6537 # bit pattern: 0xff82030104209ac9
+uniform uint64_t uexpected_shl 0x0000008501020300
+uniform uint64_t uexpected_shr 0x0014000000850102
+draw rect ortho 8 0 4 4
+
+probe rect rgba (0, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
+probe rect rgba (4, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
+probe rect rgba (8, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-scalar.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-scalar.shader_test
new file mode 100644
index 0000000..cd4f998
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-scalar.shader_test
@@ -0,0 +1,77 @@
+[require]
+GL >= 4.0
+GLSL >= 4.00
+GL_ARB_gpu_shader_int64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 400
+#extension GL_ARB_gpu_shader_int64 : require
+
+uniform i64vec4 ival;
+uniform u64vec4 uval;
+uniform int shl, shr;
+
+uniform i64vec4 iexpected_shl;
+uniform i64vec4 iexpected_shr;
+uniform u64vec4 uexpected_shl;
+uniform u64vec4 uexpected_shr;
+
+out vec4 color;
+
+void main()
+{
+	i64vec4 iresult_shl = ival << shl;
+	u64vec4 uresult_shl = uval << shl;
+	i64vec4 iresult_shr = ival >> shr;
+	u64vec4 uresult_shr = uval >> shr;
+
+	color = vec4(0.0, 1.0, 0.0, 1.0);
+
+	for (int i = 0; i < 4; ++i) {
+		if (iresult_shl[i] != iexpected_shl[i]) {
+			color = vec4(1.0, 0.0, i / 255.0, float(iresult_shl[i]) / 255.0);
+			break;
+		}
+		if (iresult_shr[i] != iexpected_shr[i]) {
+			color = vec4(1.0, 0.1, i / 255.0, float(iresult_shr[i]) / 255.0);
+			break;
+		}
+		if (uresult_shl[i] != uexpected_shl[i]) {
+			color = vec4(1.0, 0.2, i / 255.0, float(uresult_shl[i]) / 255.0);
+			break;
+		}
+		if (uresult_shr[i] != uexpected_shr[i]) {
+			color = vec4(1.0, 0.3, i / 255.0, float(uresult_shr[i]) / 255.0);
+			break;
+		}
+	}
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform i64vec4 ival 0x12 0x13 0x14 0x15
+uniform u64vec4 uval 0x23 0x24 0x25 0x26
+uniform int shl 2
+uniform int shr 2
+uniform i64vec4 iexpected_shl 0x48 0x4c 0x50 0x54
+uniform i64vec4 iexpected_shr 0x4 0x4 0x5 0x5
+uniform u64vec4 uexpected_shl 0x8c 0x90 0x94 0x98
+uniform u64vec4 uexpected_shr 0x8 0x9 0x9 0x9
+draw rect ortho 0 0 4 4
+
+uniform i64vec4 ival 0x7848302090a0b0c6 0x15 -0x15 0x123456789a
+uniform u64vec4 uval 0xc01020308090a0b5 0x15 0x4832 0x123456789a
+uniform int shl 4
+uniform int shr 4
+uniform i64vec4 iexpected_shl -0x7b7cfdf6f5f4f3a0 0x150 -0x150 0x123456789a0
+uniform i64vec4 iexpected_shr 0x07848302090a0b0c 0x1 -0x2 0x123456789
+uniform u64vec4 uexpected_shl 0x01020308090a0b50 0x150 0x48320 0x123456789a0
+uniform u64vec4 uexpected_shr 0x0c01020308090a0b 0x1 0x483 0x123456789
+draw rect ortho 4 0 4 4
+
+probe rect rgba (0, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
+probe rect rgba (4, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-vector.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-vector.shader_test
new file mode 100644
index 0000000..16b1fd3
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_int64/execution/fs-shift-vector-by-vector.shader_test
@@ -0,0 +1,77 @@
+[require]
+GL >= 4.0
+GLSL >= 4.00
+GL_ARB_gpu_shader_int64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 400
+#extension GL_ARB_gpu_shader_int64 : require
+
+uniform i64vec4 ival;
+uniform u64vec4 uval;
+uniform ivec4 shl, shr;
+
+uniform i64vec4 iexpected_shl;
+uniform i64vec4 iexpected_shr;
+uniform u64vec4 uexpected_shl;
+uniform u64vec4 uexpected_shr;
+
+out vec4 color;
+
+void main()
+{
+	i64vec4 iresult_shl = ival << shl;
+	u64vec4 uresult_shl = uval << shl;
+	i64vec4 iresult_shr = ival >> shr;
+	u64vec4 uresult_shr = uval >> shr;
+
+	color = vec4(0.0, 1.0, 0.0, 1.0);
+
+	for (int i = 0; i < 4; ++i) {
+		if (iresult_shl[i] != iexpected_shl[i]) {
+			color = vec4(1.0, 0.0, i / 255.0, float(iresult_shl[i]) / 255.0);
+			break;
+		}
+		if (iresult_shr[i] != iexpected_shr[i]) {
+			color = vec4(1.0, 0.1, i / 255.0, float(iresult_shr[i]) / 255.0);
+			break;
+		}
+		if (uresult_shl[i] != uexpected_shl[i]) {
+			color = vec4(1.0, 0.2, i / 255.0, float(uresult_shl[i]) / 255.0);
+			break;
+		}
+		if (uresult_shr[i] != uexpected_shr[i]) {
+			color = vec4(1.0, 0.3, i / 255.0, float(uresult_shr[i]) / 255.0);
+			break;
+		}
+	}
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform i64vec4 ival 0x12 0x13 0x14 0x15
+uniform u64vec4 uval 0x23 0x24 0x25 0x26
+uniform ivec4 shl 0 1 2 3
+uniform ivec4 shr 1 2 3 4
+uniform i64vec4 iexpected_shl 0x12 0x26 0x50 0xa8
+uniform i64vec4 iexpected_shr 0x9 0x4 0x2 0x1
+uniform u64vec4 uexpected_shl 0x23 0x48 0x94 0x130
+uniform u64vec4 uexpected_shr 0x11 0x9 0x4 0x2
+draw rect ortho 0 0 4 4
+
+uniform i64vec4 ival 0x7848302090a0b0c6 0x15 -0x15 0x123456789a
+uniform u64vec4 uval 0xc01020308090a0b5 0x15 0x4832 0x123456789a
+uniform ivec4 shl 0 4 8 12
+uniform ivec4 shr 4 8 12 16
+uniform i64vec4 iexpected_shl 0x7848302090a0b0c6 0x150 -0x1500 0x123456789a000
+uniform i64vec4 iexpected_shr 0x07848302090a0b0c 0 -1 0x123456
+uniform u64vec4 uexpected_shl 0xc01020308090a0b5 0x150 0x483200 0x123456789a000
+uniform u64vec4 uexpected_shr 0x0c01020308090a0b 0 0x4 0x123456
+draw rect ortho 4 0 4 4
+
+probe rect rgba (0, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
+probe rect rgba (4, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
-- 
2.9.3



More information about the Piglit mailing list