glsl-1.30: add more loop unroll tests
[piglit.git] / tests / spec / arb_shader_objects / bindattriblocation-scratch-name.c
blob8ff42bf98e8a6bbbc300043ace4c174aba95be03
1 /*
2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 /**
25 * \file bindattriblocation-scratch-name.c
26 * Verify that glBindAttribLocation doesn't keep the applications name pointer.
28 * This reproduces Mesa bugzilla #41499 (bugzilla #41508 is a dup of the same
29 * issue).
31 * \author Ian Romanick <ian.d.romanick@intel.com>
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config.supports_gl_compat_version = 10;
40 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
42 config.khr_no_error_support = PIGLIT_NO_ERRORS;
44 PIGLIT_GL_TEST_CONFIG_END
46 static const GLchar *vertShaderText =
47 "attribute vec4 attrib;\n"
48 "void main() { gl_Position = attrib; }\n";
50 enum piglit_result
51 piglit_display(void)
53 return PIGLIT_FAIL;
56 void
57 piglit_init(int argc, char **argv)
59 static const char name[] = "attrib";
60 char alt_name[sizeof(name)];
61 GLint vs;
62 GLint prog;
63 GLint attrib_loc;
65 piglit_require_vertex_shader();
67 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vertShaderText);
68 if (vs == 0) {
69 piglit_report_result(PIGLIT_FAIL);
72 prog = glCreateProgram();
73 glAttachShader(prog, vs);
75 /* Bind "attrib" to location 3. Once the attribute is bound, smash
76 * the string containing the name. After smashing the name, link the
77 * shader. If the implementation kept our name pointer, there will be
78 * problems linking.
80 memcpy(alt_name, name, sizeof(name));
81 glBindAttribLocation(prog, 3, alt_name);
82 memset(alt_name, 0, sizeof(alt_name));
83 glLinkProgram(prog);
85 if (!piglit_link_check_status(prog))
86 piglit_report_result(PIGLIT_FAIL);
88 attrib_loc = glGetAttribLocation(prog, "attrib");
89 if (attrib_loc != 3) {
90 fprintf(stderr, "Expected location 3, got location %d\n",
91 attrib_loc);
92 piglit_report_result(PIGLIT_FAIL);
95 piglit_report_result(PIGLIT_PASS);