[Piglit] [PATCH 1/4] shader_runner: add "draw arrays instanced" command

Nicolai Hähnle nhaehnle at gmail.com
Wed May 3 09:52:20 UTC 2017


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

---
 tests/shaders/shader_runner.c | 54 +++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 6ac5f98..39922d3 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2782,20 +2782,46 @@ program_must_be_in_use(void)
 
 static void
 bind_vao_if_supported()
 {
 	if (vao == 0 && gl_version.num >= 31) {
 		glGenVertexArrays(1, &vao);
 		glBindVertexArray(vao);
 	}
 }
 
+static enum piglit_result
+draw_arrays_common(int first, size_t count)
+{
+	enum piglit_result result = program_must_be_in_use();
+	if (first < 0) {
+		printf("draw arrays 'first' must be >= 0\n");
+		piglit_report_result(PIGLIT_FAIL);
+	} else if (vbo_present &&
+			(size_t) first >= num_vbo_rows) {
+		printf("draw arrays 'first' must be < %lu\n",
+			(unsigned long) num_vbo_rows);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	if (count <= 0) {
+		printf("draw arrays 'count' must be > 0\n");
+		piglit_report_result(PIGLIT_FAIL);
+	} else if (vbo_present &&
+			count > num_vbo_rows - (size_t) first) {
+		printf("draw arrays cannot draw beyond %lu\n",
+			(unsigned long) num_vbo_rows);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	bind_vao_if_supported();
+	return result;
+}
+
 static bool
 probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op, uint32_t value)
 {
         uint32_t *p;
 	uint32_t observed;
 	enum comparison cmp;
 	bool result;
 
 	REQUIRE(parse_comparison_op(op, &cmp, NULL),
 		"Invalid comparison operation at: %s\n", op);
@@ -3002,44 +3028,32 @@ piglit_display(void)
 			parse_floats(rest, c, 4, NULL);
 			piglit_draw_rect(c[0], c[1], c[2], c[3]);
 		} else if (parse_str(line, "draw instanced rect ", &rest)) {
 			int primcount;
 
 			result = program_must_be_in_use();
 			sscanf(rest, "%d %f %f %f %f",
 			       &primcount,
 			       c + 0, c + 1, c + 2, c + 3);
 			draw_instanced_rect(primcount, c[0], c[1], c[2], c[3]);
+		} else if (sscanf(line, "draw arrays instanced %31s %d %d %d", s, &x, &y, &z) == 4) {
+			GLenum mode = decode_drawing_mode(s);
+			int first = x;
+			size_t count = (size_t) y;
+			size_t primcount = (size_t) z;
+			draw_arrays_common(first, count);
+			glDrawArraysInstanced(mode, first, count, primcount);
 		} else if (sscanf(line, "draw arrays %31s %d %d", s, &x, &y) == 3) {
 			GLenum mode = decode_drawing_mode(s);
 			int first = x;
 			size_t count = (size_t) y;
-			result = program_must_be_in_use();
-			if (first < 0) {
-				printf("draw arrays 'first' must be >= 0\n");
-				piglit_report_result(PIGLIT_FAIL);
-			} else if (vbo_present &&
-				   (size_t) first >= num_vbo_rows) {
-				printf("draw arrays 'first' must be < %lu\n",
-				       (unsigned long) num_vbo_rows);
-				piglit_report_result(PIGLIT_FAIL);
-			}
-			if (count <= 0) {
-				printf("draw arrays 'count' must be > 0\n");
-				piglit_report_result(PIGLIT_FAIL);
-			} else if (vbo_present &&
-				   count > num_vbo_rows - (size_t) first) {
-				printf("draw arrays cannot draw beyond %lu\n",
-				       (unsigned long) num_vbo_rows);
-				piglit_report_result(PIGLIT_FAIL);
-			}
-			bind_vao_if_supported();
+			result = draw_arrays_common(first, count);
 			glDrawArrays(mode, first, count);
 		} else if (parse_str(line, "disable ", &rest)) {
 			do_enable_disable(rest, false);
 		} else if (parse_str(line, "enable ", &rest)) {
 			do_enable_disable(rest, true);
 		} else if (sscanf(line, "depthfunc %31s", s) == 1) {
 			glDepthFunc(piglit_get_gl_enum_from_name(s));
 		} else if (parse_str(line, "fb ", &rest)) {
 			const GLenum target =
 				parse_str(rest, "draw ", &rest) ? GL_DRAW_FRAMEBUFFER :
-- 
2.9.3



More information about the Piglit mailing list