[Piglit] [PATCH 09/10] arb_draw_elements_base_vertex: move the drawelements test

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


---
 tests/all.py                                       |    5 +-
 tests/general/CMakeLists.gl.txt                    |    1 -
 tests/general/draw-elements-base-vertex.c          |  156 --------------------
 .../CMakeLists.gl.txt                              |    1 +
 .../arb_draw_elements_base_vertex/drawelements.c   |  156 ++++++++++++++++++++
 5 files changed, 159 insertions(+), 160 deletions(-)
 delete mode 100644 tests/general/draw-elements-base-vertex.c
 create mode 100644 tests/spec/arb_draw_elements_base_vertex/drawelements.c

diff --git a/tests/all.py b/tests/all.py
index 1c740c2..3283501 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1574,13 +1574,12 @@ add_plain_test(arb_depth_clamp, 'depth-clamp-status')
 arb_draw_elements_base_vertex = {}
 spec['ARB_draw_elements_base_vertex'] = arb_draw_elements_base_vertex
 arb_draw_elements_base_vertex['dlist'] = concurrent_test('arb_draw_elements_base_vertex-dlist')
-add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-base-vertex')
-arb_draw_elements_base_vertex['draw-elements-base-vertex-user_varrays'] = PiglitTest(['draw-elements-base-vertex', '-auto', 'user_varrays'])
+add_plain_test(arb_draw_elements_base_vertex, 'arb_draw_elements_base_vertex-drawelements')
+arb_draw_elements_base_vertex['arb_draw_elements_base_vertex-drawelements-user_varrays'] = PiglitTest(['arb_draw_elements_base_vertex-drawelements', '-auto', 'user_varrays'])
 add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-base-vertex-neg')
 add_plain_test(arb_draw_elements_base_vertex, 'arb_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, '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, 'arb_draw_elements_base_vertex-drawrangeelements')
 add_plain_test(arb_draw_elements_base_vertex, 'arb_draw_elements_base_vertex-multidrawelements')
 
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 3f22a86..2ccf4f5 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -40,7 +40,6 @@ piglit_add_executable (draw-arrays-colormaterial draw-arrays-colormaterial.c)
 piglit_add_executable (draw-batch draw-batch.c)
 piglit_add_executable (draw-copypixels-sync draw-copypixels-sync.c)
 piglit_add_executable (draw-elements draw-elements.c)
-piglit_add_executable (draw-elements-base-vertex draw-elements-base-vertex.c)
 piglit_add_executable (draw-elements-base-vertex-neg draw-elements-base-vertex-neg.c)
 IF (UNIX)
 	target_link_libraries (draw-elements-base-vertex-neg m)
diff --git a/tests/general/draw-elements-base-vertex.c b/tests/general/draw-elements-base-vertex.c
deleted file mode 100644
index a5e8e2a..0000000
--- a/tests/general/draw-elements-base-vertex.c
+++ /dev/null
@@ -1,156 +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:
- *    Eric Anholt <eric at anholt.net>
- */
-
-/** @file draw-elements-base-vertex.c
- * Tests ARB_draw_elements_base_vertex functionality by drawing a series of
- * pairs of quads using different base vertices, using the same vertex and
- * index buffers.
- */
-
-#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 uintptr_t ib_offset;
-
-void
-piglit_init(int argc, char **argv)
-{
-	GLfloat *vb;
-	GLuint *ib;
-	GLuint vbo;
-	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.");
-		}
-	}
-
-	if (!user_va)
-		piglit_require_extension("GL_ARB_vertex_buffer_object");
-	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);
-}
-
-enum piglit_result
-piglit_display(void)
-{
-	GLboolean pass = GL_TRUE;
-	float white[3] = {1.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);
-
-		glDrawElementsBaseVertex(GL_QUADS, 8, GL_UNSIGNED_INT,
-					  (void *)(uintptr_t)ib_offset, 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 || j == i + 1)
-				expected = white;
-			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/CMakeLists.gl.txt b/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt
index 56d3f56..70884b3 100644
--- a/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt
+++ b/tests/spec/arb_draw_elements_base_vertex/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ link_libraries (
 )
 
 piglit_add_executable (arb_draw_elements_base_vertex-bounds bounds.c)
+piglit_add_executable (arb_draw_elements_base_vertex-drawelements drawelements.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 (arb_draw_elements_base_vertex-multidrawelements multidrawelements.c)
diff --git a/tests/spec/arb_draw_elements_base_vertex/drawelements.c b/tests/spec/arb_draw_elements_base_vertex/drawelements.c
new file mode 100644
index 0000000..a5e8e2a
--- /dev/null
+++ b/tests/spec/arb_draw_elements_base_vertex/drawelements.c
@@ -0,0 +1,156 @@
+/*
+ * 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:
+ *    Eric Anholt <eric at anholt.net>
+ */
+
+/** @file draw-elements-base-vertex.c
+ * Tests ARB_draw_elements_base_vertex functionality by drawing a series of
+ * pairs of quads using different base vertices, using the same vertex and
+ * index buffers.
+ */
+
+#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 uintptr_t ib_offset;
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLfloat *vb;
+	GLuint *ib;
+	GLuint vbo;
+	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.");
+		}
+	}
+
+	if (!user_va)
+		piglit_require_extension("GL_ARB_vertex_buffer_object");
+	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);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	GLboolean pass = GL_TRUE;
+	float white[3] = {1.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);
+
+		glDrawElementsBaseVertex(GL_QUADS, 8, GL_UNSIGNED_INT,
+					  (void *)(uintptr_t)ib_offset, 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 || j == i + 1)
+				expected = white;
+			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