2 * Copyright (c) 2018 Timothy Arceri
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 * Tests dispatch of a compute shader via display lists
29 #include "cs-ids-common.h"
31 static struct piglit_gl_test_config
*piglit_config
;
33 PIGLIT_GL_TEST_CONFIG_BEGIN
34 piglit_config
= &config
;
35 config
.supports_gl_compat_version
= 33;
36 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
37 PIGLIT_GL_TEST_CONFIG_END
44 { { 2, 4, 8 }, { 8, 4, 2 } },
45 { { 4, 4, 4 }, { 4, 4, 10 } },
50 piglit_init(int argc
, char **argv
)
52 enum piglit_result result
= PIGLIT_PASS
;
54 GLuint list
= glGenLists(1);
58 uint32_t *local
= scenarios
[0].local
;
59 uint32_t *global
= scenarios
[0].global
;
61 cs_ids_set_local_size(local
[0], local
[1], local
[2]);
62 cs_ids_set_global_size(global
[0], global
[1], global
[2]);
64 cs_ids_set_local_id_test();
66 /* -----------------------------------------
67 * Test dispatch with display lists
68 * -----------------------------------------
71 cs_ids_setup_atomics_for_test();
73 glNewList(list
, GL_COMPILE
);
74 cs_ids_run_test_without_check();
77 /* Confirm atomic counters were not updated while compiling
80 result
= cs_ids_confirm_initial_atomic_counters();
81 if (result
!= PIGLIT_PASS
) {
82 printf("Compute dispatch shouldn't have been called at "
83 "display list compilation time\n");
84 piglit_report_result(result
);
89 /* Confirm dispatch compute worked correctly */
90 result
= cs_ids_confirm_size();
91 if (result
!= PIGLIT_PASS
) {
92 printf("Compute dispatch - unexpected results");
93 piglit_report_result(result
);
96 /* Reset atomic counters */
97 cs_ids_setup_atomics_for_test();
98 result
= cs_ids_confirm_initial_atomic_counters();
99 if (result
!= PIGLIT_PASS
)
100 piglit_report_result(result
);
102 glNewList(list
, GL_COMPILE_AND_EXECUTE
);
103 cs_ids_run_test_without_check();
106 /* Confirm dispatch compute worked correctly */
107 result
= cs_ids_confirm_size();
108 if (result
!= PIGLIT_PASS
) {
109 printf("Compute dispatch should have been called at "
110 "display list compilation time\n");
111 piglit_report_result(result
);
114 /* -----------------------------------------
115 * Test indirect dispatch with display lists
116 * -----------------------------------------
118 cs_ids_use_indirect_dispatch();
120 /* Reset atomic counters */
121 cs_ids_setup_atomics_for_test();
122 result
= cs_ids_confirm_initial_atomic_counters();
123 if (result
!= PIGLIT_PASS
)
124 piglit_report_result(result
);
126 if (!piglit_check_gl_error(GL_NO_ERROR
))
127 piglit_report_result(PIGLIT_FAIL
);
129 glNewList(list
, GL_COMPILE
);
130 cs_ids_run_test_without_check();
133 if (!piglit_check_gl_error(GL_INVALID_OPERATION
)) {
134 printf("Failed to generate error when calling "
135 "glDispatchComputeIndirect() in display list.");
136 piglit_report_result(PIGLIT_FAIL
);
139 /* Confirm atomic counters were not updated while compiling
142 result
= cs_ids_confirm_initial_atomic_counters();
143 if (result
!= PIGLIT_PASS
) {
144 printf("Indirect compute dispatch shouldn't have been called "
145 "at display list compilation time\n");
146 piglit_report_result(result
);
149 /* Reset atomic counters */
150 cs_ids_setup_atomics_for_test();
151 result
= cs_ids_confirm_initial_atomic_counters();
152 if (result
!= PIGLIT_PASS
)
153 piglit_report_result(result
);
155 if (!piglit_check_gl_error(GL_NO_ERROR
))
156 piglit_report_result(PIGLIT_FAIL
);
158 glNewList(list
, GL_COMPILE_AND_EXECUTE
);
159 cs_ids_run_test_without_check();
162 if (!piglit_check_gl_error(GL_INVALID_OPERATION
)) {
163 printf("Failed to generate error when calling "
164 "glDispatchComputeIndirect() in display list.");
165 piglit_report_result(PIGLIT_FAIL
);
168 /* Confirm atomic counters were not updated while compiling
171 result
= cs_ids_confirm_initial_atomic_counters();
172 if (result
!= PIGLIT_PASS
) {
173 printf("Indirect compute dispatch shouldn't have been called "
174 "at display list compilation time\n");
175 piglit_report_result(result
);
178 /* We are done start teardown */
179 glDeleteLists(list
, 1);
180 cs_ids_common_destroy();
182 piglit_report_result(result
);