[Piglit] [PATCH] vbo-too-small: test drawing from a VBO that's too small
Brian Paul
brianp at vmware.com
Sat Nov 12 12:20:51 PST 2011
This exercises a failed assertion hit with softpipe and llvmpipe.
---
tests/all.tests | 1 +
tests/general/CMakeLists.gl.txt | 1 +
tests/general/vbo-too-small.c | 103 +++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 0 deletions(-)
create mode 100644 tests/general/vbo-too-small.c
diff --git a/tests/all.tests b/tests/all.tests
index 6bcd3d9..a22c409 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -308,6 +308,7 @@ add_plain_test(general, 'vbo-bufferdata')
add_plain_test(general, 'vbo-map-remap')
add_plain_test(general, 'vbo-subdata-sync')
add_plain_test(general, 'vbo-subdata-zero')
+add_plain_test(general, 'vbo-too-small')
add_plain_test(general, 'windowoverlap')
add_fbo_depthstencil_tests(general, 'default_fb')
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 8ff3771..5985eae 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -113,6 +113,7 @@ add_executable (vbo-map-remap vbo-map-remap.c)
add_executable (vbo-bufferdata vbo-bufferdata.c)
add_executable (vbo-subdata-zero vbo-subdata-zero.c)
add_executable (vbo-subdata-sync vbo-subdata-sync.c)
+add_executable (vbo-too-small vbo-too-small.c)
add_executable (windowoverlap windowoverlap.c)
add_executable (object_purgeable-api-pbo object_purgeable-api-pbo.c object_purgeable.c)
add_executable (object_purgeable-api-texture object_purgeable-api-texture.c object_purgeable.c)
diff --git a/tests/general/vbo-too-small.c b/tests/general/vbo-too-small.c
new file mode 100644
index 0000000..da302e0
--- /dev/null
+++ b/tests/general/vbo-too-small.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2011 VMware, Inc.
+ *
+ * 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.
+ */
+
+/**
+ * Test drawing with too small of VBO. We shouldn't crash.
+ *
+ * Brian Paul
+ * 11/11/11
+ */
+
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+
+static const GLfloat verts[4][2] = {
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 1 },
+ { 0, 1 }
+};
+
+
+enum piglit_result
+piglit_display(void)
+{
+ static const GLfloat black[3] = { 0, 0, 0 };
+ GLuint vbo;
+ GLboolean pass = GL_TRUE;
+ int size;
+
+ glColor3f(1, 1, 1);
+
+ glGenBuffersARB(1, &vbo);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ /* try drawing from VBOs all of which are too small */
+ for (size = 0; size < sizeof(verts); size++) {
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, verts, GL_STATIC_DRAW_ARB);
+
+ glVertexPointer(2, GL_FLOAT, 0, NULL);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+ /* Probe the upper-left corner where the second triangle of the fan
+ * would be drawn if the VBO was large enough. It should never be drawn.
+ */
+ if (!piglit_probe_pixel_rgb(piglit_width / 4,
+ piglit_height * 3 /4,
+ black)) {
+ /* something was drawn */
+ printf("vbo-too-small: failed for buffer size %d\n", size);
+ pass = GL_FALSE;
+ }
+
+ glutSwapBuffers();
+ }
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+ glVertexPointer(2, GL_FLOAT, 0, NULL);
+
+ glDeleteBuffersARB(1, &vbo);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_ARB_vertex_buffer_object");
+
+ piglit_gen_ortho_projection(0.0, 1.0, 0.0, 1.0,
+ -1.0, 1.0, GL_FALSE);
+}
--
1.7.3.4
More information about the Piglit
mailing list