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>2019-12-04 12:31:37 -0800
commit94e65bfe577db81f1e63612375f6dad591f97b4a (patch)
treec71a458ccf08a4d69daa0e4f7aacd048511620ee
parentd913db615755aee7d54381447e560aea0777a22b (diff)
intel_shader_integer_functions2: Add generated execution tests for multiply32x16
-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.mako108
3 files changed, 159 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..151ee9b8c
--- /dev/null
+++ b/generated_tests/templates/gen_intel_shader_integer_functions2_tests/multiply32x16.shader_test.mako
@@ -0,0 +1,108 @@
+<%! 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 in range(len(sources)):
+uniform ${input_type} src[${i}] ${"{:#010x}".format(np.uint32(sources[i]))}
+% endfor
+
+% if input_type == "int":
+ % for i in range(len(sources)):
+uniform ${input_type} src_as_16bits[${i}] ${"{:#010x}".format(np.uint32((np.int32(sources[i] << 16) >> 16)))}
+ % endfor
+% else:
+ % for i in range(len(sources)):
+uniform ${input_type} src_as_16bits[${i}] ${"{:#010x}".format(np.uint32(sources[i]) & 0x0000ffff)}
+ % endfor
+% endif
+
+draw rect -1 -1 2 2
+probe all rgb 0.0 1.0 0.0