glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / shaders / glsl-invalid-asm-02.c
blob108b7948894fabb67745d7d931a68f7042920343
1 /*
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
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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * \file glsl-invalid-asm-02.c
26 * Attempting to render with an invalid ARB_vp 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 vertex program.
33 #include "piglit-util-gl.h"
35 static const char fs_text[] =
36 "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }";
38 static const char vp_text[] =
39 "this won't compile";
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config.supports_gl_compat_version = 10;
45 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
47 PIGLIT_GL_TEST_CONFIG_END
49 enum piglit_result
50 piglit_display(void)
52 static GLboolean logged = GL_FALSE;
53 GLboolean pass = GL_TRUE;
54 GLenum err;
56 glClearColor(0.5, 0.5, 0.5, 0.0);
57 glClear(GL_COLOR_BUFFER_BIT);
59 piglit_draw_rect(-1.0, -1.0, 2.0, 2.0);
61 err = glGetError();
62 if (err != GL_INVALID_OPERATION) {
63 if (!logged) {
64 printf("Unexpected OpenGL error state 0x%04x with bad "
65 "vertex program at draw (expected 0x%04x).\n",
66 err, GL_INVALID_OPERATION);
67 logged = GL_TRUE;
70 pass = GL_FALSE;
72 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
75 void
76 piglit_init(int argc, char **argv)
78 GLuint fs;
79 GLuint vp;
80 GLuint prog;
81 GLenum err;
83 piglit_require_gl_version(20);
85 piglit_require_extension("GL_ARB_vertex_program");
87 fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
88 prog = piglit_link_simple_program(fs, 0);
89 glUseProgram(prog);
91 glGenProgramsARB(1, &vp);
92 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vp);
93 glProgramStringARB(GL_VERTEX_PROGRAM_ARB,
94 GL_PROGRAM_FORMAT_ASCII_ARB,
95 strlen(vp_text),
96 (const GLubyte *) vp_text);
98 err = glGetError();
99 if (err != GL_INVALID_OPERATION) {
100 printf("Unexpected OpenGL error state 0x%04x with bad "
101 "vertex program (expected 0x%04x).\n",
102 err, GL_INVALID_OPERATION);
103 piglit_report_result(PIGLIT_FAIL);
106 glEnable(GL_VERTEX_PROGRAM_ARB);
108 /* Clear all GL error state.
110 while (glGetError() != 0)
111 /* empty */ ;