[Piglit] [PATCH 05/10] arb_draw_elements_base_vertex: rename instanced drawelements test

Brian Paul brianp at vmware.com
Tue May 20 16:19:24 PDT 2014


---
 tests/all.py                                       |    2 +-
 .../CMakeLists.gl.txt                              |    2 +-
 .../draw-elements-instanced-base-vertex.c          |  191 --------------------
 .../drawelements-instanced.c                       |  191 ++++++++++++++++++++
 4 files changed, 193 insertions(+), 193 deletions(-)
 delete mode 100644 tests/spec/arb_draw_elements_base_vertex/draw-elements-instanced-base-vertex.c
 create mode 100644 tests/spec/arb_draw_elements_base_vertex/drawelements-instanced.c

diff --git a/tests/all.py b/tests/all.py
index c1d7d67..273bcf4 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1579,7 +1579,7 @@ arb_draw_elements_base_vertex['draw-elements-base-vertex-user_varrays'] = Piglit
 add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-base-vertex-neg')
 add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-base-vertex-bounds')
 arb_draw_elements_base_vertex['draw-elements-base-vertex-neg-user_varrays'] = PiglitTest(['draw-elements-base-vertex-neg', '-auto', 'user_varrays'])
-add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-instanced-base-vertex')
+add_plain_test(arb_draw_elements_base_vertex, 'arb_draw_elements_base_vertex-drawelements-instanced')
 arb_draw_elements_base_vertex['draw-elements-instanced-base-vertex-user_varrays'] = PiglitTest(['draw-elements-instanced-base-vertex', '-auto', 'user_varrays'])
 add_plain_test(arb_draw_elements_base_vertex, 'draw-range-elements-base-vertex')
 add_plain_test(arb_draw_elements_base_vertex, 'multi-draw-elements-base-vertex')
diff --git a/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt b/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt
index f649ece..7895c44 100644
--- a/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt
+++ b/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt
@@ -9,7 +9,7 @@ link_libraries (
 	${OPENGL_glu_LIBRARY}
 )
 
-piglit_add_executable (draw-elements-instanced-base-vertex draw-elements-instanced-base-vertex.c)
+piglit_add_executable (arb_draw_elements_base_vertex-drawelements-instanced drawelements-instanced.c)
 piglit_add_executable (arb_draw_elements_base_vertex-dlist dlist.c)
 piglit_add_executable (multi-draw-elements-base-vertex multi-draw-elements-base-vertex.c)
 piglit_add_executable (draw-range-elements-base-vertex draw-range-elements-base-vertex.c)
diff --git a/tests/spec/arb_draw_elements_base_vertex/draw-elements-instanced-base-vertex.c b/tests/spec/arb_draw_elements_base_vertex/draw-elements-instanced-base-vertex.c
deleted file mode 100644
index e8399a9..0000000
--- a/tests/spec/arb_draw_elements_base_vertex/draw-elements-instanced-base-vertex.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Pierre-Eric Pelloux-Prayer <pelloux at gmail.com>
- */
-
-/** @file draw-elements-instanced-base-vertex.c
- * (Heavily based on draw-elements-base-vertex.c)
- * Tests ARB_draw_elements_instanced_base_vertex functionality by drawing a series of
- * pairs of quads using different base vertices, using the same vertex and
- * index buffers.
- * Each pair of quads is drawn using 2 instances, and gl_InstanceID is used as a
- * color modifier and an y offset.
- */
-
-#include "piglit-util-gl-common.h"
-
-PIGLIT_GL_TEST_CONFIG_BEGIN
-
-	config.supports_gl_compat_version = 10;
-
-	config.window_width = 300;
-	config.window_height = 300;
-	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
-
-PIGLIT_GL_TEST_CONFIG_END
-
-#define NUM_QUADS  10
-
-static const char *VertShaderText =
-	"#extension GL_ARB_draw_instanced : enable\n"
-	"attribute float yOffsetPerInstance; \n"
-	"void main() \n"
-	"{\n"
-	"	vec4 p = gl_Vertex;\n"
-	"	p.y += yOffsetPerInstance * float(gl_InstanceIDARB);\n"
-	"	gl_Position = gl_ModelViewProjectionMatrix * p; \n"
-	"	gl_FrontColor = vec4(1.0-float(gl_InstanceIDARB), 1.0, 1.0, 1.0); \n"
-	"}\n";
-
-static const char *FragShaderText =
-	"void main() \n"
-	"{ \n"
-	"	gl_FragColor = gl_Color; \n"
-	"}\n";
-
-static GLuint Program;
-
-static uintptr_t ib_offset;
-
-void
-piglit_init(int argc, char **argv)
-{
-	GLfloat *vb;
-	GLuint *ib;
-	GLuint vbo;
-	GLint OffsetAttrib;
-	GLboolean user_va = GL_FALSE;
-	int i;
-
-	for (i = 1; i < argc; i++) {
-		if (!strcmp(argv[i], "user_varrays")) {
-			user_va = GL_TRUE;
-			puts("Testing user vertex arrays.");
-		}
-	}
-
-	piglit_require_GLSL();
-	if (!user_va)
-		piglit_require_extension("GL_ARB_vertex_buffer_object");
-	piglit_require_extension("GL_ARB_draw_instanced");
-	piglit_require_extension("GL_ARB_draw_elements_base_vertex");
-
-	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	glLoadIdentity();
-
-	if (!user_va) {
-		glGenBuffersARB(1, &vbo);
-		glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
-		glBufferDataARB(GL_ARRAY_BUFFER_ARB,
-				NUM_QUADS * 8 * sizeof(GLfloat) +
-				2 * 4 * sizeof(GLuint),
-				NULL, GL_DYNAMIC_DRAW);
-		vb = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
-	} else {
-		vb = malloc(NUM_QUADS * 8 * sizeof(GLfloat) +
-			    2 * 4 * sizeof(GLuint));
-	}
-
-	for (i = 0; i < NUM_QUADS; i++) {
-		float x1 = 10;
-		float y1 = 10 + i * 20;
-		float x2 = 20;
-		float y2 = 20 + i * 20;
-
-		vb[i * 8 + 0] = x1; vb[i * 8 + 1] = y1;
-		vb[i * 8 + 2] = x2; vb[i * 8 + 3] = y1;
-		vb[i * 8 + 4] = x2; vb[i * 8 + 5] = y2;
-		vb[i * 8 + 6] = x1; vb[i * 8 + 7] = y2;
-	}
-	ib_offset = NUM_QUADS * 8 * sizeof(GLfloat);
-	ib = (GLuint *)((char *)vb + ib_offset);
-	for (i = 0; i < 8; i++)
-		ib[i] = i;
-
-	if (user_va) {
-		ib_offset = (uintptr_t)ib;
-	} else {
-		glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
-		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo);
-	}
-
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glVertexPointer(2, GL_FLOAT, 0, user_va ? vb : NULL);
-
-	Program = piglit_build_simple_program(VertShaderText, FragShaderText);
-
-	glUseProgram(Program);
-
-	OffsetAttrib = glGetAttribLocation(Program, "yOffsetPerInstance");
-	glVertexAttrib1f(OffsetAttrib, 20);
-}
-
-enum piglit_result
-piglit_display(void)
-{
-	GLboolean pass = GL_TRUE;
-	float white[3] = {1.0, 1.0, 1.0};
-	float blue[3]  = {0.0, 1.0, 1.0};
-	float clear[3] = {0.0, 0.0, 0.0};
-	int i, j;
-
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-	glColor3fv(white);
-	/* Draw columns with each successive pair of the quads. */
-	for (i = 0; i < NUM_QUADS - 1; i++) {
-		glMatrixMode(GL_PROJECTION);
-		glPushMatrix();
-		glLoadIdentity();
-		glOrtho(0, piglit_width, 0, piglit_height, -1, 1);
-		glTranslatef(i * 20, 0, 0);
-
-		glDrawElementsInstancedBaseVertex(GL_QUADS, 4, GL_UNSIGNED_INT,
-						(void *)(uintptr_t)ib_offset, 2, i * 4);
-
-		glPopMatrix();
-	}
-
-	for (i = 0; i < NUM_QUADS - 1; i++) {
-		for (j = 0; j < NUM_QUADS; j++) {
-			float *expected;
-
-			int x = 15 + i * 20;
-			int y = 15 + j * 20;
-
-			if (j == i)
-				expected = white;
-			else if (j == i + 1)
-				expected = blue;
-			else
-				expected = clear;
-			pass = piglit_probe_pixel_rgb(x, y, expected) && pass;
-		}
-	}
-
-	piglit_present_results();
-
-	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
-}
diff --git a/tests/spec/arb_draw_elements_base_vertex/drawelements-instanced.c b/tests/spec/arb_draw_elements_base_vertex/drawelements-instanced.c
new file mode 100644
index 0000000..e8399a9
--- /dev/null
+++ b/tests/spec/arb_draw_elements_base_vertex/drawelements-instanced.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Pierre-Eric Pelloux-Prayer <pelloux at gmail.com>
+ */
+
+/** @file draw-elements-instanced-base-vertex.c
+ * (Heavily based on draw-elements-base-vertex.c)
+ * Tests ARB_draw_elements_instanced_base_vertex functionality by drawing a series of
+ * pairs of quads using different base vertices, using the same vertex and
+ * index buffers.
+ * Each pair of quads is drawn using 2 instances, and gl_InstanceID is used as a
+ * color modifier and an y offset.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+
+	config.window_width = 300;
+	config.window_height = 300;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#define NUM_QUADS  10
+
+static const char *VertShaderText =
+	"#extension GL_ARB_draw_instanced : enable\n"
+	"attribute float yOffsetPerInstance; \n"
+	"void main() \n"
+	"{\n"
+	"	vec4 p = gl_Vertex;\n"
+	"	p.y += yOffsetPerInstance * float(gl_InstanceIDARB);\n"
+	"	gl_Position = gl_ModelViewProjectionMatrix * p; \n"
+	"	gl_FrontColor = vec4(1.0-float(gl_InstanceIDARB), 1.0, 1.0, 1.0); \n"
+	"}\n";
+
+static const char *FragShaderText =
+	"void main() \n"
+	"{ \n"
+	"	gl_FragColor = gl_Color; \n"
+	"}\n";
+
+static GLuint Program;
+
+static uintptr_t ib_offset;
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLfloat *vb;
+	GLuint *ib;
+	GLuint vbo;
+	GLint OffsetAttrib;
+	GLboolean user_va = GL_FALSE;
+	int i;
+
+	for (i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "user_varrays")) {
+			user_va = GL_TRUE;
+			puts("Testing user vertex arrays.");
+		}
+	}
+
+	piglit_require_GLSL();
+	if (!user_va)
+		piglit_require_extension("GL_ARB_vertex_buffer_object");
+	piglit_require_extension("GL_ARB_draw_instanced");
+	piglit_require_extension("GL_ARB_draw_elements_base_vertex");
+
+	glMatrixMode(GL_MODELVIEW);
+	glPushMatrix();
+	glLoadIdentity();
+
+	if (!user_va) {
+		glGenBuffersARB(1, &vbo);
+		glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
+		glBufferDataARB(GL_ARRAY_BUFFER_ARB,
+				NUM_QUADS * 8 * sizeof(GLfloat) +
+				2 * 4 * sizeof(GLuint),
+				NULL, GL_DYNAMIC_DRAW);
+		vb = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+	} else {
+		vb = malloc(NUM_QUADS * 8 * sizeof(GLfloat) +
+			    2 * 4 * sizeof(GLuint));
+	}
+
+	for (i = 0; i < NUM_QUADS; i++) {
+		float x1 = 10;
+		float y1 = 10 + i * 20;
+		float x2 = 20;
+		float y2 = 20 + i * 20;
+
+		vb[i * 8 + 0] = x1; vb[i * 8 + 1] = y1;
+		vb[i * 8 + 2] = x2; vb[i * 8 + 3] = y1;
+		vb[i * 8 + 4] = x2; vb[i * 8 + 5] = y2;
+		vb[i * 8 + 6] = x1; vb[i * 8 + 7] = y2;
+	}
+	ib_offset = NUM_QUADS * 8 * sizeof(GLfloat);
+	ib = (GLuint *)((char *)vb + ib_offset);
+	for (i = 0; i < 8; i++)
+		ib[i] = i;
+
+	if (user_va) {
+		ib_offset = (uintptr_t)ib;
+	} else {
+		glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo);
+	}
+
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glVertexPointer(2, GL_FLOAT, 0, user_va ? vb : NULL);
+
+	Program = piglit_build_simple_program(VertShaderText, FragShaderText);
+
+	glUseProgram(Program);
+
+	OffsetAttrib = glGetAttribLocation(Program, "yOffsetPerInstance");
+	glVertexAttrib1f(OffsetAttrib, 20);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	GLboolean pass = GL_TRUE;
+	float white[3] = {1.0, 1.0, 1.0};
+	float blue[3]  = {0.0, 1.0, 1.0};
+	float clear[3] = {0.0, 0.0, 0.0};
+	int i, j;
+
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	glColor3fv(white);
+	/* Draw columns with each successive pair of the quads. */
+	for (i = 0; i < NUM_QUADS - 1; i++) {
+		glMatrixMode(GL_PROJECTION);
+		glPushMatrix();
+		glLoadIdentity();
+		glOrtho(0, piglit_width, 0, piglit_height, -1, 1);
+		glTranslatef(i * 20, 0, 0);
+
+		glDrawElementsInstancedBaseVertex(GL_QUADS, 4, GL_UNSIGNED_INT,
+						(void *)(uintptr_t)ib_offset, 2, i * 4);
+
+		glPopMatrix();
+	}
+
+	for (i = 0; i < NUM_QUADS - 1; i++) {
+		for (j = 0; j < NUM_QUADS; j++) {
+			float *expected;
+
+			int x = 15 + i * 20;
+			int y = 15 + j * 20;
+
+			if (j == i)
+				expected = white;
+			else if (j == i + 1)
+				expected = blue;
+			else
+				expected = clear;
+			pass = piglit_probe_pixel_rgb(x, y, expected) && pass;
+		}
+	}
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
1.7.10.4



More information about the Piglit mailing list