summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2018-09-17 05:13:16 -0700
committerIan Romanick <ian.d.romanick@intel.com>2020-01-07 09:43:15 -0800
commit5ae9df2e9956ff932132e616a769c8a94b112f9b (patch)
treea304fdaf351c4084805b9f848664ab5b9151419c
parent652d68e155b26520010fa345f289a01600b37f66 (diff)
intel_shader_integer_functions2: Add generated execution tests for multiply32x16
v2: Python style changes suggested by Dylan. Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
-rw-r--r--generated_tests/CMakeLists.txt1
-rw-r--r--generated_tests/gen_intel_shader_integer_functions2_tests.py50
-rw-r--r--generated_tests/templates/gen_intel_shader_integer_functions2_tests/multiply32x16.shader_test.mako110
3 files changed, 161 insertions, 0 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 868715db0..87ce9ee5c 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -220,6 +220,7 @@ piglit_make_generated_tests(
templates/gen_intel_shader_integer_functions2_tests/absoluteDifference.shader_test.mako
templates/gen_intel_shader_integer_functions2_tests/addSaturate.shader_test.mako
templates/gen_intel_shader_integer_functions2_tests/countLeadingZeros.shader_test.mako
+ templates/gen_intel_shader_integer_functions2_tests/multiply32x16.shader_test.mako
templates/gen_intel_shader_integer_functions2_tests/subtractSaturate.shader_test.mako
)
diff --git a/generated_tests/gen_intel_shader_integer_functions2_tests.py b/generated_tests/gen_intel_shader_integer_functions2_tests.py
index 1c0eadd0b..c02765a2b 100644
--- a/generated_tests/gen_intel_shader_integer_functions2_tests.py
+++ b/generated_tests/gen_intel_shader_integer_functions2_tests.py
@@ -248,6 +248,14 @@ def s_rhadd64(_a, _b):
return (a >> np.int64(1)) + (b >> np.int64(1)) + ((a | b) & np.int64(1))
+def imul_32x16(a, b):
+ return np.int32(a) * ((np.int32(b) << 16) >> 16)
+
+
+def umul_32x16(a, b):
+ return np.uint32(np.uint32(a) * (np.uint32(b) & 0x0000ffff))
+
+
def absoluteDifference32_sources():
srcs = []
for x in range(0, 32, 4):
@@ -393,6 +401,26 @@ def countTrailingZeros_sources():
return sources
+def multiply32x16_int32_sources():
+ srcs = [0, 1, -1, np.int32(0x80000000), -0x7fffffff, 0x7fffffff ]
+
+ random.seed(0)
+ for i in range(2, 32, 3):
+ srcs.append(random.randint(0, 1 << i) | (1 << i))
+
+ srcs.append(random.randint(0, 1 << 30) | (1 << 30))
+
+ for i in range(2, 32, 3):
+ srcs.append(-(random.randint(0, 1 << i) | (1 << i)))
+
+ srcs.append(-(random.randint(0, 1 << 30) | (1 << 30)))
+
+ while len(srcs) < 512:
+ srcs.append(random.randint(-0x80000000, 0x7fffffff))
+
+ return srcs
+
+
def subtractSaturate_int32_sources():
srcs = [0, 1, -1, np.int32(0x80000000), -0x7fffffff, 0x7fffffff ]
@@ -656,6 +684,28 @@ FUNCS = {
'version': '4.00', # GL_ARB_gpu_shader_int64 requires 4.0.
'extensions': 'GL_ARB_gpu_shader_int64',
},
+ 'multiply32x16-int': {
+ 'input': 'int',
+ 'output': 'int',
+ 'sources': multiply32x16_int32_sources,
+ 'results': generate_results_empty,
+ 'template': 'multiply32x16.shader_test.mako',
+ 'func': 'multiply32x16',
+ 'operator': imul_32x16,
+ 'version': '1.30',
+ 'extensions': None,
+ },
+ 'multiply32x16-uint': {
+ 'input': 'uint',
+ 'output': 'uint',
+ 'sources': multiply32x16_int32_sources,
+ 'results': generate_results_empty,
+ 'template': 'multiply32x16.shader_test.mako',
+ 'func': 'multiply32x16',
+ 'operator': umul_32x16,
+ 'version': '1.30',
+ 'extensions': None,
+ },
'subtractSaturate-int': {
'input': 'int',
'output': 'int',
diff --git a/generated_tests/templates/gen_intel_shader_integer_functions2_tests/multiply32x16.shader_test.mako b/generated_tests/templates/gen_intel_shader_integer_functions2_tests/multiply32x16.shader_test.mako
new file mode 100644
index 000000000..e059f8296
--- /dev/null
+++ b/generated_tests/templates/gen_intel_shader_integer_functions2_tests/multiply32x16.shader_test.mako
@@ -0,0 +1,110 @@
+<%!
+import six
+import numpy as np
+%>
+[require]
+GL >= 3.0
+GLSL >= 1.30
+GL_INTEL_shader_integer_functions2
+
+% if execution_stage == 'vs':
+[vertex shader]
+#extension GL_INTEL_shader_integer_functions2: require
+
+/* OpenGL 3.0 only requires that implementations support 1024 uniform
+ * components per stage.
+ */
+uniform ${input_type} src[${len(sources)}];
+uniform ${input_type} src_as_16bits[src.length()];
+
+${output_type} get_expected_result(uint i, uint j)
+{
+ return src[i] * src_as_16bits[j];
+}
+
+const uvec4 ranges[] = uvec4[](uvec4(0, uint(src.length()) / 2u,
+ 0, uint(src.length()) / 2u),
+ uvec4(0, uint(src.length()) / 2u,
+ uint(src.length()) / 2u, src.length()),
+ uvec4(uint(src.length()) / 2u, src.length(),
+ 0, uint(src.length()) / 2u),
+ uvec4(uint(src.length()) / 2u, src.length(),
+ uint(src.length()) / 2u, src.length()));
+
+out vec4 color;
+in vec4 piglit_vertex;
+
+void main()
+{
+ gl_Position = piglit_vertex;
+
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+
+ uvec4 r = ranges[2u * uint(piglit_vertex.x > 0.0) +
+ uint(piglit_vertex.y > 0.0)];
+
+ for (uint i = r.x; i < r.y; i++) {
+ for (uint j = r.z; j < r.w; j++) {
+ if (multiply32x16(src[i], src[j]) != get_expected_result(i, j))
+ color = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+ }
+
+}
+% else:
+[vertex shader passthrough]
+% endif
+
+[fragment shader]
+% if execution_stage == 'fs':
+#extension GL_INTEL_shader_integer_functions2: require
+
+/* OpenGL 3.0 only requires that implementations support 1024 uniform
+ * components per stage.
+ */
+uniform ${input_type} src[${len(sources)}];
+uniform ${input_type} src_as_16bits[src.length()];
+
+${output_type} get_expected_result(uint i, uint j)
+{
+ return src[i] * src_as_16bits[j];
+}
+% else:
+in vec4 color;
+% endif
+
+out vec4 piglit_fragcolor;
+
+void main()
+{
+ % if execution_stage == 'fs':
+ const uint l = uint(src.length());
+ uint i = uint(gl_FragCoord.x) % l;
+ uint j = uint(gl_FragCoord.y) % l;
+
+ if (multiply32x16(src[i], src[j]) == get_expected_result(i, j))
+ piglit_fragcolor = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ piglit_fragcolor = vec4(1.0, 0.0, 0.0, 1.0);
+ % else:
+ piglit_fragcolor = color;
+ % endif
+}
+
+[test]
+% for i, s in enumerate(sources):
+uniform ${input_type} src[${i}] ${"{:#010x}".format(np.uint32(s))}
+% endfor
+
+% if input_type == "int":
+ % for i, s in enumerate(sources):
+uniform ${input_type} src_as_16bits[${i}] ${"{:#010x}".format(np.uint32((np.int32(s << 16) >> 16)))}
+ % endfor
+% else:
+ % for i, s in enumerate(sources):
+uniform ${input_type} src_as_16bits[${i}] ${"{:#010x}".format(np.uint32(s) & 0x0000ffff)}
+ % endfor
+% endif
+
+draw rect -1 -1 2 2
+probe all rgb 0.0 1.0 0.0