framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / gl-3.0 / api / bindfragdata-nonexistent-variable.c
blob1cae692b49c3442a924c08041d6f0fecf3e5117c
1 /* Copyright © 2011 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 /**
24 * \file bindfragdata-nonexistent-variable.c
25 * Test the behavior of glBindFragDataLocation on a non-existent variable
27 * \author Ian Romanick
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.supports_gl_compat_version = 10;
34 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
35 config.khr_no_error_support = PIGLIT_NO_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
39 static const char *vs_text =
40 "#version 130\n"
41 "in vec4 vertex;\n"
42 "void main() { gl_Position = vertex; }\n"
45 static const char *fs_text =
46 "#version 130\n"
47 "out vec4 v;\n"
48 "void main() {\n"
49 " v = vec4(0.0);\n"
50 "}\n"
53 enum piglit_result
54 piglit_display(void)
56 return PIGLIT_FAIL;
59 void piglit_init(int argc, char **argv)
61 GLint max_draw_buffers;
62 GLuint prog;
63 GLuint vs;
64 GLuint fs;
65 GLint loc;
67 piglit_require_gl_version(30);
69 /* This test needs some number of draw buffers, so make sure the
70 * implementation isn't broken. This enables the test to generate a
71 * useful failure message.
73 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
74 if (max_draw_buffers < 8) {
75 fprintf(stderr,
76 "OpenGL 3.0 requires GL_MAX_DRAW_BUFFERS >= 8. "
77 "Only got %d!\n",
78 max_draw_buffers);
79 piglit_report_result(PIGLIT_FAIL);
82 prog = glCreateProgram();
83 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
84 fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
85 if (!piglit_check_gl_error(GL_NO_ERROR))
86 piglit_report_result(PIGLIT_FAIL);
88 /* First, verify that the program will link without making any
89 * location assignments through the API.
91 printf("Basic test...\n");
93 glAttachShader(prog, vs);
94 glAttachShader(prog, fs);
95 glLinkProgram(prog);
96 if (!piglit_check_gl_error(GL_NO_ERROR))
97 piglit_report_result(PIGLIT_FAIL);
99 if (!piglit_link_check_status(prog)) {
100 piglit_report_result(PIGLIT_FAIL);
103 /* Page 237 (page 253 of the PDF) of the OpenGL 3.0 spec says:
105 * "Assigned bindings for variables that do not exist are
106 * ignored."
108 printf("Binding `unicorn' to a non-conflicting location...\n");
110 glBindFragDataLocation(prog, 0, "v");
111 if (!piglit_check_gl_error(GL_NO_ERROR))
112 piglit_report_result(PIGLIT_FAIL);
113 glBindFragDataLocation(prog, 1, "unicorn");
114 if (!piglit_check_gl_error(GL_NO_ERROR))
115 piglit_report_result(PIGLIT_FAIL);
117 glLinkProgram(prog);
118 if (!piglit_check_gl_error(GL_NO_ERROR))
119 piglit_report_result(PIGLIT_FAIL);
121 if (!piglit_link_check_status(prog)) {
122 fprintf(stderr,
123 "Linking failed when it should have been "
124 "successful.\n");
125 piglit_report_result(PIGLIT_FAIL);
128 loc = glGetFragDataLocation(prog, "unicorn");
129 if (!piglit_check_gl_error(GL_NO_ERROR))
130 piglit_report_result(PIGLIT_FAIL);
132 if (loc != -1) {
133 fprintf(stderr, "Expected location = -1, got %d\n", loc);
134 piglit_report_result(PIGLIT_FAIL);
137 printf("Binding `unicorn' to a conflicting location...\n");
139 glBindFragDataLocation(prog, 0, "v");
140 if (!piglit_check_gl_error(GL_NO_ERROR))
141 piglit_report_result(PIGLIT_FAIL);
142 glBindFragDataLocation(prog, 0, "unicorn");
143 if (!piglit_check_gl_error(GL_NO_ERROR))
144 piglit_report_result(PIGLIT_FAIL);
146 glLinkProgram(prog);
147 if (!piglit_check_gl_error(GL_NO_ERROR))
148 piglit_report_result(PIGLIT_FAIL);
150 if (!piglit_link_check_status(prog)) {
151 fprintf(stderr,
152 "Linking failed when it should have been "
153 "successful.\n");
154 piglit_report_result(PIGLIT_FAIL);
157 loc = glGetFragDataLocation(prog, "unicorn");
158 if (!piglit_check_gl_error(GL_NO_ERROR))
159 piglit_report_result(PIGLIT_FAIL);
161 if (loc != -1) {
162 fprintf(stderr, "Expected location = -1, got %d\n", loc);
163 piglit_report_result(PIGLIT_FAIL);
166 piglit_report_result(PIGLIT_PASS);