[Piglit] [PATCH] arb_shader_objects: Verify that glBindAttribLocation doesn't keep the name ptr
Ian Romanick
idr at freedesktop.org
Fri Oct 7 14:50:33 PDT 2011
From: Ian Romanick <ian.d.romanick at intel.com>
Reproduces Mesa bugzilla #41499.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/all.tests | 1 +
tests/spec/arb_shader_objects/CMakeLists.gl.txt | 1 +
.../bindattriblocation-scratch-name.c | 91 ++++++++++++++++++++
3 files changed, 93 insertions(+), 0 deletions(-)
create mode 100644 tests/spec/arb_shader_objects/bindattriblocation-scratch-name.c
diff --git a/tests/all.tests b/tests/all.tests
index 5407c95..593906d 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['getuniformlocation-array-of-struct-of-array'] = concurrent_test('arb_shader_objects-getuniformlocation-array-of-struct-of-array')
+arb_shader_objects['bindattriblocation-scratch-name'] = concurrent_test('arb_shader_objects-bindattriblocation-scratch-name')
arb_shader_objects['clear-with-deleted'] = concurrent_test('arb_shader_objects-clear-with-deleted')
# Group ARB_explicit_attrib_location
diff --git a/tests/spec/arb_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_shader_objects/CMakeLists.gl.txt
index 84e877c..0c6bfe1 100644
--- a/tests/spec/arb_shader_objects/CMakeLists.gl.txt
+++ b/tests/spec/arb_shader_objects/CMakeLists.gl.txt
@@ -11,6 +11,7 @@ link_libraries (
${GLUT_glut_LIBRARY}
)
+add_executable (arb_shader_objects-bindattriblocation-scratch-name bindattriblocation-scratch-name.c)
add_executable (arb_shader_objects-getuniform getuniform.c)
add_executable (arb_shader_objects-getuniformlocation-array-of-struct-of-array getuniformlocation-array-of-struct-of-array.c)
add_executable (arb_shader_objects-clear-with-deleted clear-with-deleted.c)
diff --git a/tests/spec/arb_shader_objects/bindattriblocation-scratch-name.c b/tests/spec/arb_shader_objects/bindattriblocation-scratch-name.c
new file mode 100644
index 0000000..1f386ba
--- /dev/null
+++ b/tests/spec/arb_shader_objects/bindattriblocation-scratch-name.c
@@ -0,0 +1,91 @@
+/*
+ * 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 bindattriblocation-scratch-name.c
+ * Verify that glBindAttribLocation doesn't keep the applications name pointer.
+ *
+ * This reproduces Mesa bugzilla #41499 (bugzilla #41508 is a dup of the same
+ * issue).
+ *
+ * \author Ian Romanick <ian.d.romanick at intel.com>
+ */
+
+#include "piglit-util.h"
+#include "piglit-framework.h"
+
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+int piglit_width = 10;
+int piglit_height = 10;
+
+static const GLchar *vertShaderText =
+ "attribute vec4 attrib;\n"
+ "void main() { gl_Position = attrib; }\n";
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ static const char name[] = "attrib";
+ char alt_name[sizeof(name)];
+ GLint vs;
+ GLint prog;
+ GLint attrib_loc;
+
+ piglit_require_vertex_shader();
+
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vertShaderText);
+ if (vs == 0) {
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ prog = piglit_CreateProgram();
+ piglit_AttachShader(prog, vs);
+
+ /* Bind "attrib" to location 3. Once the attribute is bound, smash
+ * the string containing the name. After smashing the name, link the
+ * shader. If the implementation kept our name pointer, there will be
+ * problems linking.
+ */
+ memcpy(alt_name, name, sizeof(name));
+ piglit_BindAttribLocation(prog, 3, alt_name);
+ memset(alt_name, 0, sizeof(alt_name));
+ piglit_LinkProgram(prog);
+
+ if (!piglit_link_check_status(prog))
+ piglit_report_result(PIGLIT_FAIL);
+
+ attrib_loc = piglit_GetAttribLocation(prog, "attrib");
+ if (attrib_loc != 3) {
+ fprintf(stderr, "Expected location 3, got location %d\n",
+ attrib_loc);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ piglit_report_result(PIGLIT_PASS);
+}
--
1.7.6
More information about the Piglit
mailing list