2 * Copyright © 2012 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
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 DEALINGS
24 * Eric Anholt <eric@anholt.net>
28 /** @file glsl-render-bad-attach.c
30 * Tests that rendering with a good program after attaching a bad
31 * shader to it still works.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 10;
39 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
41 PIGLIT_GL_TEST_CONFIG_END
43 const char *vs_source
=
46 " gl_Position = gl_Vertex;\n"
49 const char *good_fs_source
=
52 " gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
55 const char *bad_fs_source
=
66 float green
[4] = {0, 1, 0, 0};
67 GLuint good_fs
, bad_fs
, vs
, prog
;
69 glClearColor(0.0, 1.0, 0.0, 0.0);
70 glClear(GL_COLOR_BUFFER_BIT
);
72 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_source
);
73 good_fs
= piglit_compile_shader_text(GL_FRAGMENT_SHADER
,
75 prog
= piglit_link_simple_program(vs
, good_fs
);
76 if (!vs
|| !good_fs
|| !prog
)
77 piglit_report_result(PIGLIT_FAIL
);
81 piglit_draw_rect(-1, -1, 1, 2);
83 bad_fs
= glCreateShader(GL_FRAGMENT_SHADER
);
84 glShaderSource(bad_fs
, 1, (const GLchar
**) &bad_fs_source
, NULL
);
85 glCompileShader(bad_fs
);
86 glGetShaderiv(bad_fs
, GL_COMPILE_STATUS
, &ok
);
88 piglit_report_result(PIGLIT_FAIL
);
89 glAttachShader(prog
, bad_fs
);
91 piglit_draw_rect(0, -1, 1, 2);
93 pass
= piglit_probe_rect_rgba(0, 0,
94 piglit_width
, piglit_height
,
97 piglit_present_results();
99 glDeleteShader(good_fs
);
100 glDeleteShader(bad_fs
);
102 glDeleteProgram(prog
);
104 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
108 piglit_init(int argc
, char **argv
)
110 piglit_require_GLSL();