[Piglit] [PATCH v3] arb_compute_shader: test dispatch functions with display lists
Timothy Arceri
tarceri at itsqueeze.com
Thu Jun 28 00:54:42 UTC 2018
This change also splits apart some of the compute test common
functions to make them easier to use with display lists.
---
V3: I submitted a spec bug and it was decided the indirect dispatch
should generate an error when called during display list
compilation.
tests/opengl.py | 1 +
.../spec/arb_compute_shader/CMakeLists.gl.txt | 1 +
tests/spec/arb_compute_shader/cs-ids-common.c | 126 +++++++-----
tests/spec/arb_compute_shader/cs-ids-common.h | 12 ++
tests/spec/arb_compute_shader/dlist.c | 189 ++++++++++++++++++
5 files changed, 283 insertions(+), 46 deletions(-)
create mode 100644 tests/spec/arb_compute_shader/dlist.c
diff --git a/tests/opengl.py b/tests/opengl.py
index 18ba228a1..669d9055b 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -4217,6 +4217,7 @@ with profile.test_list.group_manager(
override_class=BuiltInConstantsTest)
g(['arb_compute_shader-work_group_size_too_large'],
grouptools.join('compiler', 'work_group_size_too_large'))
+ g(['arb_compute_shader-dlist'], 'display-list')
g(['arb_compute_shader-indirect-compute'], 'indirect-compute')
g(['arb_compute_shader-local-id'], 'local-id' + '-explosion')
g(['arb_compute_shader-render-and-compute'], 'render-and-compute')
diff --git a/tests/spec/arb_compute_shader/CMakeLists.gl.txt b/tests/spec/arb_compute_shader/CMakeLists.gl.txt
index d7b98123a..2258ae88e 100644
--- a/tests/spec/arb_compute_shader/CMakeLists.gl.txt
+++ b/tests/spec/arb_compute_shader/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ piglit_add_executable (arb_compute_shader-minmax minmax.c)
set(depends cs-ids-common.c common.c)
+piglit_add_executable (arb_compute_shader-dlist dlist.c ${depends})
piglit_add_executable (arb_compute_shader-indirect-compute indirect-compute.c ${depends})
piglit_add_executable (arb_compute_shader-local-id local-id.c ${depends})
piglit_add_executable (arb_compute_shader-render-and-compute render-and-compute.c ${depends})
diff --git a/tests/spec/arb_compute_shader/cs-ids-common.c b/tests/spec/arb_compute_shader/cs-ids-common.c
index fc25986fa..c07705b8a 100644
--- a/tests/spec/arb_compute_shader/cs-ids-common.c
+++ b/tests/spec/arb_compute_shader/cs-ids-common.c
@@ -104,14 +104,61 @@ clear_program()
}
static enum piglit_result
-confirm_size()
+compare_atomic_counters(uint32_t *values, uint32_t xs, uint32_t ys,
+ uint32_t zs)
{
+ bool pass = true;
uint32_t *p;
+
+ glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomics_bo);
+ p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER,
+ 0,
+ NUM_ATOMIC_COUNTERS * sizeof(uint32_t),
+ GL_MAP_READ_BIT);
+
+ if (!p) {
+ printf("Couldn't map atomic counter to verify expected value.\n");
+ return PIGLIT_FAIL;
+ }
+
+ for (unsigned i = 0; i < NUM_ATOMIC_COUNTERS; i++) {
+ uint32_t found = p[i];
+ if (verbose)
+ printf("Atomic counter %d\n"
+ " Reference: %u\n"
+ " Observed: %u\n"
+ " Result: %s\n",
+ i, values[i], found,
+ values[i] == found ? "pass" : "fail");
+ if (values[i] != found) {
+ printf("Atomic counter test %d failed for (%d, %d, %d)\n",
+ i, xs, ys, zs);
+ printf(" Reference: %u\n", values[i]);
+ printf(" Observed: %u\n", found);
+ pass = false;
+ break;
+ }
+ }
+
+ glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+enum piglit_result
+cs_ids_confirm_initial_atomic_counters()
+{
+ uint32_t atomics_init[NUM_ATOMIC_COUNTERS] = { 0 };
+ return compare_atomic_counters(atomics_init, 0, 0, 0);
+}
+
+enum piglit_result
+cs_ids_confirm_size()
+{
uint32_t values[NUM_ATOMIC_COUNTERS];
uint32_t i, x, y, z;
uint32_t xs, ys, zs;
uint32_t hx, hy, hz;
- bool pass = true;
xs = local_x;
ys = local_y;
@@ -158,39 +205,7 @@ confirm_size()
values[i] *= global_x * global_y * global_z;
}
- glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomics_bo);
- p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER,
- 0,
- NUM_ATOMIC_COUNTERS * sizeof(uint32_t),
- GL_MAP_READ_BIT);
-
- if (!p) {
- printf("Couldn't map atomic counter to verify expected value.\n");
- return PIGLIT_FAIL;
- }
-
- for (i = 0; i < NUM_ATOMIC_COUNTERS; i++) {
- uint32_t found = p[i];
- if (verbose)
- printf("Atomic counter %d\n"
- " Reference: %u\n"
- " Observed: %u\n"
- " Result: %s\n",
- i, values[i], found,
- values[i] == found ? "pass" : "fail");
- if (values[i] != found) {
- printf("Atomic counter test %d failed for (%d, %d, %d)\n",
- i, xs, ys, zs);
- printf(" Reference: %u\n", values[i]);
- printf(" Observed: %u\n", found);
- pass = false;
- break;
- }
- }
-
- glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
-
- return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+ return compare_atomic_counters(values, xs, ys, zs);
}
@@ -263,25 +278,34 @@ cs_ids_set_global_size(uint32_t x, uint32_t y, uint32_t z)
}
-enum piglit_result
-cs_ids_run_test()
+void
+cs_ids_setup_atomics_for_test()
{
- enum piglit_result result;
uint32_t atomics_init[NUM_ATOMIC_COUNTERS] = { 0 };
+ glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomics_bo);
+ glBufferData(GL_ATOMIC_COUNTER_BUFFER,
+ sizeof(atomics_init),
+ atomics_init, GL_STATIC_DRAW);
+}
+
+
+/* Running the test without checking the result is useful for creating display
+ * list tests.
+ */
+void
+cs_ids_run_test_without_check()
+{
if (verbose)
printf("Testing local dim = %dx%dx%d; "
"global dim = %dx%dx%d\n",
local_x, local_y, local_z,
global_x, global_y, global_z);
- if (local_x == 0 || local_y == 0 || local_z == 0)
- return PIGLIT_FAIL;
-
- glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomics_bo);
- glBufferData(GL_ATOMIC_COUNTER_BUFFER,
- sizeof(atomics_init),
- atomics_init, GL_STATIC_DRAW);
+ if (local_x == 0 || local_y == 0 || local_z == 0) {
+ fprintf(stderr, "Internal error: local size not set\n");
+ return;
+ }
glUseProgram(prog);
@@ -293,8 +317,18 @@ cs_ids_run_test()
glDispatchCompute(global_x, global_y, global_z);
}
glMemoryBarrier(GL_ALL_BARRIER_BITS);
+}
+
+
+enum piglit_result
+cs_ids_run_test()
+{
+ enum piglit_result result;
+
+ cs_ids_setup_atomics_for_test();
+ cs_ids_run_test_without_check();
- result = confirm_size();
+ result = cs_ids_confirm_size();
if (result != PIGLIT_PASS)
piglit_report_result(result);
diff --git a/tests/spec/arb_compute_shader/cs-ids-common.h b/tests/spec/arb_compute_shader/cs-ids-common.h
index e7530e0d3..4879e855d 100644
--- a/tests/spec/arb_compute_shader/cs-ids-common.h
+++ b/tests/spec/arb_compute_shader/cs-ids-common.h
@@ -64,4 +64,16 @@ cs_ids_set_global_size(uint32_t x, uint32_t y, uint32_t z);
enum piglit_result
cs_ids_run_test();
+void
+cs_ids_run_test_without_check();
+
+void
+cs_ids_setup_atomics_for_test();
+
+enum piglit_result
+cs_ids_confirm_initial_atomic_counters();
+
+enum piglit_result
+cs_ids_confirm_size();
+
#endif
diff --git a/tests/spec/arb_compute_shader/dlist.c b/tests/spec/arb_compute_shader/dlist.c
new file mode 100644
index 000000000..fe2262a3d
--- /dev/null
+++ b/tests/spec/arb_compute_shader/dlist.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2018 Timothy Arceri
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** \file
+ *
+ * Tests dispatch of a compute shader via display lists
+ */
+
+#include "cs-ids-common.h"
+
+static struct piglit_gl_test_config *piglit_config;
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+ piglit_config = &config;
+ config.supports_gl_compat_version = 33;
+ config.khr_no_error_support = PIGLIT_NO_ERRORS;
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static struct {
+ uint32_t local[3];
+ uint32_t global[3];
+} scenarios[] = {
+ { { 2, 4, 8 }, { 8, 4, 2 } },
+ { { 4, 4, 4 }, { 4, 4, 10 } },
+};
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ enum piglit_result result = PIGLIT_PASS;
+
+ GLuint list = glGenLists(1);
+
+ cs_ids_common_init();
+
+ uint32_t *local = scenarios[0].local;
+ uint32_t *global = scenarios[0].global;
+
+ cs_ids_set_local_size(local[0], local[1], local[2]);
+ cs_ids_set_global_size(global[0], global[1], global[2]);
+
+ cs_ids_set_local_id_test();
+
+ /* -----------------------------------------
+ * Test dispatch with display lists
+ * -----------------------------------------
+ */
+
+ cs_ids_setup_atomics_for_test();
+
+ glNewList(list, GL_COMPILE);
+ cs_ids_run_test_without_check();
+ glEndList();
+
+ /* Confirm atomic counters were not updated while compiling
+ * the display list.
+ */
+ result = cs_ids_confirm_initial_atomic_counters();
+ if (result != PIGLIT_PASS) {
+ printf("Compute dispatch shouldn't have been called at "
+ "display list compilation time\n");
+ piglit_report_result(result);
+ }
+
+ glCallList(list);
+
+ /* Confirm dispatch compute worked correctly */
+ result = cs_ids_confirm_size();
+ if (result != PIGLIT_PASS) {
+ printf("Compute dispatch - unexpected results");
+ piglit_report_result(result);
+ }
+
+ /* Reset atomic counters */
+ cs_ids_setup_atomics_for_test();
+ result = cs_ids_confirm_initial_atomic_counters();
+ if (result != PIGLIT_PASS)
+ piglit_report_result(result);
+
+ glNewList(list, GL_COMPILE_AND_EXECUTE);
+ cs_ids_run_test_without_check();
+ glEndList();
+
+ /* Confirm dispatch compute worked correctly */
+ result = cs_ids_confirm_size();
+ if (result != PIGLIT_PASS) {
+ printf("Compute dispatch should have been called at "
+ "display list compilation time\n");
+ piglit_report_result(result);
+ }
+
+ /* -----------------------------------------
+ * Test indirect dispatch with display lists
+ * -----------------------------------------
+ */
+ cs_ids_use_indirect_dispatch();
+
+ /* Reset atomic counters */
+ cs_ids_setup_atomics_for_test();
+ result = cs_ids_confirm_initial_atomic_counters();
+ if (result != PIGLIT_PASS)
+ piglit_report_result(result);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glNewList(list, GL_COMPILE);
+ cs_ids_run_test_without_check();
+ glEndList();
+
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+ printf("Failed to generate error when calling "
+ "glDispatchComputeIndirect() in display list.");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* Confirm atomic counters were not updated while compiling
+ * the display list.
+ */
+ result = cs_ids_confirm_initial_atomic_counters();
+ if (result != PIGLIT_PASS) {
+ printf("Indirect compute dispatch shouldn't have been called "
+ "at display list compilation time\n");
+ piglit_report_result(result);
+ }
+
+ /* Reset atomic counters */
+ cs_ids_setup_atomics_for_test();
+ result = cs_ids_confirm_initial_atomic_counters();
+ if (result != PIGLIT_PASS)
+ piglit_report_result(result);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glNewList(list, GL_COMPILE_AND_EXECUTE);
+ cs_ids_run_test_without_check();
+ glEndList();
+
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+ printf("Failed to generate error when calling "
+ "glDispatchComputeIndirect() in display list.");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* Confirm atomic counters were not updated while compiling
+ * the display list.
+ */
+ result = cs_ids_confirm_initial_atomic_counters();
+ if (result != PIGLIT_PASS) {
+ printf("Indirect compute dispatch shouldn't have been called "
+ "at display list compilation time\n");
+ piglit_report_result(result);
+ }
+
+ /* We are done start teardown */
+ glDeleteLists(list, 1);
+ cs_ids_common_destroy();
+
+ piglit_report_result(result);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
--
2.17.1
More information about the Piglit
mailing list