2 * Copyright © 2010 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
25 * \file glsl-invalid-asm-01.c
26 * Attempting to render with an invalid ARB_fp shader should generate an error.
28 * Based on code inspection it was found that Mesa does not correctly generate
29 * the draw-time error if a GLSL shader is used with an invalid assembly
30 * (GL_ARB_vertex_program or GL_ARB_fragment_program) program. This test
31 * attempts to reproduce this failure using an assembly fragment program.
33 #include "piglit-util-gl.h"
35 static const char vs_text
[] =
36 "void main() { gl_Position = gl_Vertex;"
37 "gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0); }";
39 static const char fp_text
[] =
42 PIGLIT_GL_TEST_CONFIG_BEGIN
44 config
.supports_gl_compat_version
= 10;
46 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
48 PIGLIT_GL_TEST_CONFIG_END
53 static GLboolean logged
= GL_FALSE
;
54 GLboolean pass
= GL_TRUE
;
57 glClearColor(0.5, 0.5, 0.5, 0.0);
58 glClear(GL_COLOR_BUFFER_BIT
);
60 piglit_draw_rect(-1.0, -1.0, 2.0, 2.0);
63 if (err
!= GL_INVALID_OPERATION
) {
65 printf("Unexpected OpenGL error state 0x%04x with bad "
66 "fragment program at draw (expected 0x%04x).\n",
67 err
, GL_INVALID_OPERATION
);
73 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
77 piglit_init(int argc
, char **argv
)
84 piglit_require_gl_version(20);
86 piglit_require_extension("GL_ARB_fragment_program");
88 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_text
);
89 prog
= piglit_link_simple_program(vs
, 0);
92 glGenProgramsARB(1, &fp
);
93 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, fp
);
94 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
,
95 GL_PROGRAM_FORMAT_ASCII_ARB
,
97 (const GLubyte
*) fp_text
);
100 if (err
!= GL_INVALID_OPERATION
) {
101 printf("Unexpected OpenGL error state 0x%04x with bad "
102 "fragment program (expected 0x%04x).\n",
103 err
, GL_INVALID_OPERATION
);
104 piglit_report_result(PIGLIT_FAIL
);
107 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
109 /* Clear all GL error state.
111 while (glGetError() != 0)