[Piglit] [PATCH 3/8] shader_runner: allow multiple ssbo bindings and add ssbo subdata command

Nicolai Hähnle nhaehnle at gmail.com
Thu Apr 7 01:10:47 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 tests/shaders/shader_runner.c                      | 31 ++++++++++++----------
 .../execution/basic-ssbo.shader_test               |  2 +-
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 2d127e2..fb0a1f3 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -113,7 +113,7 @@ GLenum geometry_layout_input_type = GL_TRIANGLES;
 GLenum geometry_layout_output_type = GL_TRIANGLE_STRIP;
 GLint geometry_layout_vertices_out = 0;
 GLuint atomics_bo = 0;
-GLuint ssbo = 0;
+GLuint ssbo[32];
 
 #define SHADER_TYPES 6
 static GLuint *subuniform_locations[SHADER_TYPES];
@@ -2704,7 +2704,7 @@ probe_atomic_counter(GLint counter_num, const char *op, uint32_t value)
 }
 
 static bool
-probe_ssbo_uint(GLint ssbo_offset, const char *op, uint32_t value)
+probe_ssbo_uint(GLint ssbo_index, GLint ssbo_offset, const char *op, uint32_t value)
 {
 	uint32_t *p;
 	uint32_t observed;
@@ -2713,7 +2713,7 @@ probe_ssbo_uint(GLint ssbo_offset, const char *op, uint32_t value)
 
 	process_comparison(op, &cmp);
 
-	glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, ssbo);
+	glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, ssbo[ssbo_index]);
 	p = glMapBufferRange(GL_SHADER_STORAGE_BUFFER, ssbo_offset,
 			     sizeof(uint32_t), GL_MAP_READ_BIT);
 
@@ -2995,13 +2995,13 @@ piglit_display(void)
 			if (!probe_atomic_counter(x, s, y)) {
 				piglit_report_result(PIGLIT_FAIL);
 			}
-		} else if (sscanf(line, "probe ssbo uint %d %s 0x%x",
-				  &x, s, &y) == 3) {
-			if (!probe_ssbo_uint(x, s, y))
+		} else if (sscanf(line, "probe ssbo uint %d %d %s 0x%x",
+				  &x, &y, s, &z) == 4) {
+			if (!probe_ssbo_uint(x, y, s, z))
 				pass = false;
-		} else if (sscanf(line, "probe ssbo uint %d %s %d",
-				  &x, s, &y) == 3) {
-			if (!probe_ssbo_uint(x, s, y))
+		} else if (sscanf(line, "probe ssbo uint %d %d %s %d",
+				  &x, &y, s, &z) == 4) {
+			if (!probe_ssbo_uint(x, y, s, z))
 				pass = false;
 		} else if (sscanf(line,
 				  "relative probe rgba ( %f , %f ) "
@@ -3076,13 +3076,16 @@ piglit_display(void)
 			glShadeModel(GL_SMOOTH);
 		} else if (string_match("shade model flat", line)) {
 			glShadeModel(GL_FLAT);
-		} else if (sscanf(line, "ssbo %d", &x) == 1) {
-			GLuint *ssbo_init = calloc(x, 1);
-			glGenBuffers(1, &ssbo);
-			glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, ssbo);
-			glBufferData(GL_SHADER_STORAGE_BUFFER, x,
+		} else if (sscanf(line, "ssbo %d %d", &x, &y) == 2) {
+			GLuint *ssbo_init = calloc(y, 1);
+			glGenBuffers(1, &ssbo[x]);
+			glBindBufferBase(GL_SHADER_STORAGE_BUFFER, x, ssbo[x]);
+			glBufferData(GL_SHADER_STORAGE_BUFFER, y,
 				     ssbo_init, GL_DYNAMIC_DRAW);
 			free(ssbo_init);
+		} else if (sscanf(line, "ssbo %d subdata float %d %f", &x, &y, &c[0]) == 3) {
+			glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo[x]);
+			glBufferSubData(GL_SHADER_STORAGE_BUFFER, y, 4, &c[0]);
 		} else if (sscanf(line, "texture rgbw %d ( %d", &tex, &w) == 2) {
 			GLenum int_fmt = GL_RGBA;
 			int num_scanned =
diff --git a/tests/spec/arb_compute_shader/execution/basic-ssbo.shader_test b/tests/spec/arb_compute_shader/execution/basic-ssbo.shader_test
index 4bf7e1c..f73d84f 100644
--- a/tests/spec/arb_compute_shader/execution/basic-ssbo.shader_test
+++ b/tests/spec/arb_compute_shader/execution/basic-ssbo.shader_test
@@ -47,7 +47,7 @@ void main()
 
 [test]
 atomic counters 1
-ssbo 1024
+ssbo 0 1024
 
 uniform uint mode 0
 compute 1 1 1
-- 
2.5.0



More information about the Piglit mailing list