[Mesa-dev] [PATCH] arb_vertex_buffer_object-elements-negative-offset: New test.

Eric Anholt eric at anholt.net
Sat Jun 11 11:11:44 PDT 2011


This tests for a bug in moving VBO offsets in the i965 driver.
---
 tests/all.tests                                    |    4 +
 tests/spec/CMakeLists.txt                          |    1 +
 .../arb_vertex_buffer_object/CMakeLists.gl.txt     |   16 +++
 tests/spec/arb_vertex_buffer_object/CMakeLists.txt |    1 +
 .../elements-negative-offset.c                     |  112 ++++++++++++++++++++
 5 files changed, 134 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_vertex_buffer_object/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_vertex_buffer_object/CMakeLists.txt
 create mode 100644 tests/spec/arb_vertex_buffer_object/elements-negative-offset.c

diff --git a/tests/all.tests b/tests/all.tests
index 58c6d0f..af94f68 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -867,6 +867,10 @@ add_texwrap_test2(arb_texture_compression, '2D', 'GL_COMPRESSED_INTENSITY')
 add_texwrap_test2(arb_texture_compression, '2D', 'GL_COMPRESSED_RGB')
 add_texwrap_test2(arb_texture_compression, '2D', 'GL_COMPRESSED_RGBA')
 
+arb_vertex_buffer_object = Group()
+spec['ARB_vertex_buffer_object'] = arb_vertex_buffer_object
+add_plain_test(arb_vertex_buffer_object, 'arb_vertex_buffer_object-elements-negative-offset')
+
 ext_packed_depth_stencil = Group()
 spec['EXT_packed_depth_stencil'] = ext_packed_depth_stencil
 add_fbo_depth_test(ext_packed_depth_stencil, 'GL_DEPTH24_STENCIL8')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 253544a..3b57487 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -13,3 +13,4 @@ add_subdirectory (ext_fog_coord)
 add_subdirectory (nv_conditional_render)
 add_subdirectory (nv_texture_barrier)
 add_subdirectory (arb_draw_elements_base_vertex)
+add_subdirectory (arb_vertex_buffer_object)
diff --git a/tests/spec/arb_vertex_buffer_object/CMakeLists.gl.txt b/tests/spec/arb_vertex_buffer_object/CMakeLists.gl.txt
new file mode 100644
index 0000000..6ec96d6
--- /dev/null
+++ b/tests/spec/arb_vertex_buffer_object/CMakeLists.gl.txt
@@ -0,0 +1,16 @@
+include_directories(
+	${OPENGL_INCLUDE_PATH}
+	${GLUT_INCLUDE_DIR}
+	${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+	piglitutil
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+	${GLUT_glut_LIBRARY}
+)
+
+add_executable (arb_vertex_buffer_object-elements-negative-offset elements-negative-offset.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_vertex_buffer_object/CMakeLists.txt b/tests/spec/arb_vertex_buffer_object/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_vertex_buffer_object/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_vertex_buffer_object/elements-negative-offset.c b/tests/spec/arb_vertex_buffer_object/elements-negative-offset.c
new file mode 100644
index 0000000..1b34fb4
--- /dev/null
+++ b/tests/spec/arb_vertex_buffer_object/elements-negative-offset.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright © 2011 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.
+ */
+
+/** @file elements-negative-offset.c
+ *
+ * Tests for a bug in the i965 driver.  When moving all VBO pointers
+ * down by the same offset in the same batchbuffer, it would be unable
+ * to access the new vertex data.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 64, piglit_height = 64;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA;
+
+static GLuint vbo;
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_vertex_buffer_object");
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[] = {0.0, 1.0, 0.0, 0.0};
+	float blue[] = {0.0, 0.0, 1.0, 0.0};
+	float vertex_data[] = {
+		/* quad 1 position */
+		-1.0, -1.0, 0.0, 1.0,
+		 0.0, -1.0, 0.0, 1.0,
+		 0.0,  1.0, 0.0, 1.0,
+		-1.0,  1.0, 0.0, 1.0,
+
+		/* quad 1 color */
+		0.0, 1.0, 0.0, 0.0,
+		0.0, 1.0, 0.0, 0.0,
+		0.0, 1.0, 0.0, 0.0,
+		0.0, 1.0, 0.0, 0.0,
+
+		/* quad 0 position */
+		 0.0, -1.0, 0.0, 1.0,
+		 1.0, -1.0, 0.0, 1.0,
+		 1.0,  1.0, 0.0, 1.0,
+		 0.0,  1.0, 0.0, 1.0,
+
+		/* quad 0 color */
+		0.0, 0.0, 1.0, 0.0,
+		0.0, 0.0, 1.0, 0.0,
+		0.0, 0.0, 1.0, 0.0,
+		0.0, 0.0, 1.0, 0.0,
+	};
+	intptr_t quad0_pos_offset = 8 * 4 * sizeof(float);
+	intptr_t quad0_color_offset = 12 * 4 * sizeof(float);
+	intptr_t quad1_pos_offset = 0;
+	intptr_t quad1_color_offset = 4 * 4 * sizeof(float);
+
+	glClearColor(1.0, 0.0, 0.0, 0.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glGenBuffersARB(1, &vbo);
+	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
+	glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertex_data),
+			vertex_data, GL_DYNAMIC_DRAW);
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glEnableClientState(GL_COLOR_ARRAY);
+
+	glVertexPointer(4, GL_FLOAT, 0, (void *)quad0_pos_offset);
+	glColorPointer(4, GL_FLOAT, 0, (void *)quad0_color_offset);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+	glVertexPointer(4, GL_FLOAT, 0, (void *)quad1_pos_offset);
+	glColorPointer(4, GL_FLOAT, 0, (void *)quad1_color_offset);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+	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;
+
+	glutSwapBuffers();
+
+	glDisableClientState(GL_VERTEX_ARRAY);
+	glDisableClientState(GL_COLOR_ARRAY);
+	glDeleteBuffersARB(1, &vbo);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
1.7.5.3



More information about the mesa-dev mailing list