[Piglit] [PATCH 1/2] Test glMultiDrawArraysIndirect with non-VBO attribs

Marek Olšák maraeo at gmail.com
Tue Jul 24 04:11:22 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 tests/opengl.py                              |  6 ++
 tests/spec/gl-3.0/multidrawarrays-vertexid.c | 64 +++++++++++++++-----
 2 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/tests/opengl.py b/tests/opengl.py
index 6944fd79d..ce67d485b 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -1746,20 +1746,26 @@ with profile.test_list.group_manager(
     g(['arb_draw_indirect-draw-elements-prim-restart'])
     g(['arb_draw_indirect-draw-elements-prim-restart-ugly'])
     g(['arb_draw_indirect-draw-arrays-instances'])
     g(['arb_draw_indirect-draw-arrays-shared-binding'])
     g(['arb_draw_indirect-transform-feedback'])
     g(['arb_draw_indirect-vertexid'],
       'gl_VertexID used with glDrawArraysIndirect')
     g(['arb_draw_indirect-vertexid', 'elements'],
       'gl_VertexID used with glDrawElementsIndirect')
 
+# Group ARB_draw_indirect
+with profile.test_list.group_manager(
+        PiglitGLTest,
+        grouptools.join('spec', 'ARB_multi_draw_indirect')) as g:
+    g(['gl-3.0-multidrawarrays-vertexid', '-indirect'],
+
 # Group ARB_fragment_program
 with profile.test_list.group_manager(
         PiglitGLTest,
         grouptools.join('spec', 'ARB_fragment_program')) as g:
     g(['arb_fragment_program-minmax'], 'minmax')
     g(['fp-abs-01'])
     g(['fp-fog'])
     g(['fp-formats'])
     g(['fp-fragment-position'])
     g(['fp-incomplete-tex'])
diff --git a/tests/spec/gl-3.0/multidrawarrays-vertexid.c b/tests/spec/gl-3.0/multidrawarrays-vertexid.c
index 47ee89e78..099cc44c7 100644
--- a/tests/spec/gl-3.0/multidrawarrays-vertexid.c
+++ b/tests/spec/gl-3.0/multidrawarrays-vertexid.c
@@ -35,35 +35,58 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
 	config.khr_no_error_support = PIGLIT_NO_ERRORS;
 
 PIGLIT_GL_TEST_CONFIG_END
 
 static const float green[]   = { 0, 1, 0, 1 };
 static const float blue[]    = { 0, 0, 1, 1 };
 static const float gold[]    = { 1, 1, 0, 1 };
 static const float magenta[] = { 1, 0, 1, 1 };
 
+static bool indirect;
+
 enum piglit_result
 piglit_display(void)
 {
 	bool pass = true;
 	static const GLint first[] = { 4, 8, 12, 16 };
 	static const GLsizei count[ARRAY_SIZE(first)] = { 4, 4, 4, 4 };
 
 	glViewport(0, 0, piglit_width, piglit_height);
 	glClearColor(0.2, 0.2, 0.2, 0.2);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	glMultiDrawArrays(GL_TRIANGLE_FAN,
-			  first,
-			  count,
-			  ARRAY_SIZE(count));
+	if (indirect) {
+		unsigned data[ARRAY_SIZE(count) * 4];
+
+		for (unsigned i = 0; i < ARRAY_SIZE(count); i++) {
+			data[i*4+0] = count[i];
+			data[i*4+1] = 1;
+			data[i*4+2] = first[i];
+			data[i*4+3] = 0;
+		}
+		GLuint ib;
+
+		glGenBuffers(1, &ib);
+		glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ib);
+		glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(data), data,
+			     GL_STATIC_DRAW);
+
+		glMultiDrawArraysIndirect(GL_TRIANGLE_FAN, NULL,
+					  ARRAY_SIZE(count), 0);
+		glDeleteBuffers(1, &ib);
+	} else {
+		glMultiDrawArrays(GL_TRIANGLE_FAN,
+				  first,
+				  count,
+				  ARRAY_SIZE(count));
+	}
 
 	pass = piglit_probe_rect_rgba(0, 0,
 				      piglit_width / 2, piglit_height /2,
 				      green)
 		&& pass;
 	pass = piglit_probe_rect_rgba(piglit_width / 2, 0,
 				      piglit_width / 2, piglit_height / 2,
 				      blue)
 		&& pass;
 	pass = piglit_probe_rect_rgba(0, piglit_height /2,
@@ -76,20 +99,28 @@ piglit_display(void)
 		&& pass;
 
 	piglit_present_results();
 
 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
 
 void
 piglit_init(int argc, char **argv)
 {
+	for (int i = 1; i < argc; i++) {
+		if (strcmp(argv[i], "-indirect") == 0) {
+			piglit_require_extension("GL_ARB_multi_draw_indirect");
+			puts("Testing GL_ARB_multi_draw_indirect");
+			indirect = true;
+		}
+	}
+
 	static const GLfloat verts[] = {
 		/* These vertices should never be accessed due to the way
 		 * glMultiDrawArrays is called.
 		 */
 		-1.0, -1.0,
 		 1.0, -1.0,
 		 1.0,  1.0,
 		-1.0,  1.0,
 
 		-1.0, -1.0,
@@ -150,26 +181,31 @@ piglit_init(int argc, char **argv)
 		"	gl_Position = piglit_vertex;\n"
 		"}\n",
 
 		"#version 130\n"
 		"in vec3 c;\n"
 		"\n"
 		"void main() {\n"
 		"	gl_FragColor = vec4(c, 1);\n"
 		"}\n");
 
-	GLuint vao;
-	GLuint buf;
-
 	glUseProgram(prog);
 
-	glGenVertexArrays(1, &vao);
-	glBindVertexArray(vao);
+	if (indirect) {
+		/* Use non-VBO attributes to test this codepath. */
+		glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	} else {
+		GLuint vao;
+		GLuint buf;
+
+		glGenVertexArrays(1, &vao);
+		glBindVertexArray(vao);
 
-	glGenBuffers(1, &buf);
-	glBindBuffer(GL_ARRAY_BUFFER, buf);
-	glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts,
-		     GL_STATIC_DRAW);
+		glGenBuffers(1, &buf);
+		glBindBuffer(GL_ARRAY_BUFFER, buf);
+		glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts,
+			     GL_STATIC_DRAW);
 
-	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (void *) 0);
+		glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (void *) 0);
+	}
 	glEnableVertexAttribArray(0);
 }
-- 
2.17.1



More information about the Piglit mailing list