[1/4] shader_runner: add command 'probe atomic counter buffer'

Submitted by apinheiro on June 29, 2018, 2:30 p.m.

Details

Message ID 20180629143008.15578-2-apinheiro@igalia.com
State New
Headers show
Series "ARB_gl_spirv: atomic counters tests" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

apinheiro June 29, 2018, 2:30 p.m.
From: Antia Puentes <apuentes@igalia.com>

Extends the already existing 'probe atomic counter' command to allow comparing
the value of an atomic counter stored in an ATOMIC_COUNTER_BUFFER with a binding
different from zero, and at a chosen offset. In other words, adds support to
test the atomic counter layout qualifiers: binding and offset.

Usage: 'probe atomic counter buffer' <binding> <offset> <op> <value>

   * <binding> and <offset> are the atomic counter layout qualifiers.
   * <op> is the comparison operator.
   * <value> is the number to be compared with the atomic counter.
---
 tests/shaders/shader_runner.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 2c6837fb6..63cffdc19 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3419,7 +3419,8 @@  draw_arrays_common(int first, size_t count)
 }
 
 static bool
-probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op, uint32_t value)
+probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op,
+		     uint32_t value, bool uses_layout_qualifiers)
 {
         uint32_t *p;
 	uint32_t observed;
@@ -3430,7 +3431,8 @@  probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op, uin
 		"Invalid comparison operation at: %s\n", op);
 
 	glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomics_bos[buffer_num]);
-	p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, counter_num * sizeof(uint32_t),
+	p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER,
+			     uses_layout_qualifiers ? counter_num : counter_num * sizeof(uint32_t),
 			     sizeof(uint32_t), GL_MAP_READ_BIT);
 
         if (!p) {
@@ -3442,8 +3444,13 @@  probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op, uin
 	result = compare_uint(value, observed, cmp);
 
 	if (!result) {
-		printf("Atomic counter %d test failed: Reference %s Observed\n",
-		       counter_num, comparison_string(cmp));
+		if (uses_layout_qualifiers)
+			printf("Atomic counter (binding = %d, offset = %d) test failed: "
+			       "Reference %s Observed\n",
+			       buffer_num, counter_num, comparison_string(cmp));
+		else
+			printf("Atomic counter %d test failed: Reference %s Observed\n",
+			       counter_num, comparison_string(cmp));
 		printf("  Reference: %u\n", value);
 		printf("  Observed:  %u\n", observed);
 		glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
@@ -3510,7 +3517,7 @@  piglit_display(void)
 		float c[32];
 		double d[4];
 		int x, y, z, w, h, l, tex, level;
-		unsigned ux, uy;
+		unsigned ux, uy, uz;
 		char s[300]; // 300 for safety
 		enum piglit_result result = PIGLIT_PASS;
 
@@ -3958,10 +3965,16 @@  piglit_display(void)
 						      c[2])) {
 				result = PIGLIT_FAIL;
 			}
+		} else if (sscanf(line,
+				  "probe atomic counter buffer %u %u %s %u",
+				  &ux, &uy, s, &uz) == 4) {
+			if (!probe_atomic_counter(ux, uy, s, uz, true)) {
+				piglit_report_result(PIGLIT_FAIL);
+			}
 		} else if (sscanf(line,
 				  "probe atomic counter %u %s %u",
 				  &ux, s, &uy) == 3) {
-			if (!probe_atomic_counter(0, ux, s, uy)) {
+			if (!probe_atomic_counter(0, ux, s, uy, false)) {
 				piglit_report_result(PIGLIT_FAIL);
 			}
 		} else if (sscanf(line, "probe ssbo uint %d %d %s 0x%x",