[Piglit] [PATCH 3/4] delete-repeat: New test for mismatched glDeleteProgram().
Eric Anholt
eric at anholt.net
Wed Oct 5 12:59:31 PDT 2011
---
tests/all.tests | 1 +
tests/spec/arb_shader_objects/CMakeLists.gl.txt | 1 +
tests/spec/arb_shader_objects/delete-repeat.c | 109 +++++++++++++++++++++++
3 files changed, 111 insertions(+), 0 deletions(-)
create mode 100644 tests/spec/arb_shader_objects/delete-repeat.c
diff --git a/tests/all.tests b/tests/all.tests
index 840d2c9..7944364 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -941,6 +941,7 @@ spec['ARB_shader_objects'] = arb_shader_objects
arb_shader_objects['getuniform'] = PlainExecTest(['arb_shader_objects-getuniform', '-auto'])
arb_shader_objects['getuniform'].runConcurrent = True
arb_shader_objects['clear-with-deleted'] = concurrent_test('arb_shader_objects-clear-with-deleted')
+arb_shader_objects['delete-repeat'] = concurrent_test('arb_shader_objects-delete-repeat')
# Group ARB_explicit_attrib_location
arb_explicit_attrib_location = Group()
diff --git a/tests/spec/arb_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_shader_objects/CMakeLists.gl.txt
index 6c2bdc6..0b5c9bf 100644
--- a/tests/spec/arb_shader_objects/CMakeLists.gl.txt
+++ b/tests/spec/arb_shader_objects/CMakeLists.gl.txt
@@ -13,3 +13,4 @@ link_libraries (
add_executable (arb_shader_objects-getuniform getuniform.c)
add_executable (arb_shader_objects-clear-with-deleted clear-with-deleted.c)
+add_executable (arb_shader_objects-delete-repeat delete-repeat.c)
diff --git a/tests/spec/arb_shader_objects/delete-repeat.c b/tests/spec/arb_shader_objects/delete-repeat.c
new file mode 100644
index 0000000..e19aa1c
--- /dev/null
+++ b/tests/spec/arb_shader_objects/delete-repeat.c
@@ -0,0 +1,109 @@
+/* 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.
+ */
+
+#include "piglit-util.h"
+
+/**
+ * @file delete-repeat.c
+ *
+ * Tests that refcounting of deleted shader objects is correct when
+ * glDeleteProgram() is called multiple times.
+ */
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+static const char *vs_source =
+ "void main()\n"
+ "{"
+ " gl_Position = gl_Vertex;\n"
+ "}\n";
+
+static const char *fs_source =
+ "void main()\n"
+ "{"
+ " gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
+ "}\n";
+
+enum piglit_result
+piglit_display(void)
+{
+ GLuint vs, fs;
+ bool pass = true;
+ GLuint prog;
+ float green[] = {0.0, 1.0, 0.0, 0.0};
+ GLint status;
+
+ /* Initial buffer clear. */
+ glClearColor(1.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
+ prog = piglit_link_simple_program(vs, fs);
+
+ if (!vs || !fs || !prog)
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_DeleteShader(vs);
+ piglit_DeleteShader(fs);
+ piglit_UseProgram(prog);
+ piglit_DeleteProgram(prog);
+
+ /* Try to blow out the refcount */
+ piglit_DeleteProgram(prog);
+ piglit_DeleteProgram(prog);
+ piglit_DeleteProgram(prog);
+
+ /* Sanity check: deleting didn't already unbind our shader program. */
+ piglit_draw_rect(-1, -1, 2, 2);
+ pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+ green) && pass;
+
+ /* The program should still report being deleted. */
+ piglit_GetProgramiv(prog, GL_DELETE_STATUS, &status);
+ piglit_check_gl_error(0, PIGLIT_FAIL);
+ if (status != GL_TRUE) {
+ fprintf(stderr,
+ "GL_DELETE_STATUS after a clear reported non-true %d\n",
+ status);
+ pass = false;
+ }
+
+ /* Now, disable the program and it should be finally deleted. */
+ piglit_UseProgram(0);
+
+ piglit_GetProgramiv(prog, GL_DELETE_STATUS, &status);
+ piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_vertex_shader();
+ piglit_require_fragment_shader();
+}
--
1.7.6.3
More information about the Piglit
mailing list