glx: don't fail test if the X server is inconsistent
[piglit.git] / tests / shaders / useshaderprogram-flushverts-1.c
blob9c5e812ad728ff1f22a69b9e0b85c95f9ff647ed
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.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file useshaderprogram-flushverts-1.c
30 * Tests that a change in the shader program results in previous
31 * vertices getting flushed correctly with the previous shader.
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_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
42 PIGLIT_GL_TEST_CONFIG_END
44 static GLint vs_prog, fs_prog_1, fs_prog_2;
46 enum piglit_result
47 piglit_display(void)
49 GLboolean pass = GL_TRUE;
50 float green[4] = {0.0, 1.0, 0.0, 0.0};
51 float blue[4] = {0.0, 0.0, 1.0, 0.0};
53 glUseShaderProgramEXT(GL_VERTEX_SHADER, vs_prog);
55 glUseShaderProgramEXT(GL_FRAGMENT_SHADER, fs_prog_1);
56 glBegin(GL_TRIANGLE_FAN);
57 glVertex2f(-1.0, -1.0);
58 glVertex2f(-0.5, -1.0);
59 glVertex2f(-0.5, 1.0);
60 glVertex2f(-1.0, 1.0);
61 glEnd();
63 glUseShaderProgramEXT(GL_FRAGMENT_SHADER, fs_prog_2);
64 glBegin(GL_TRIANGLE_FAN);
65 glVertex2f(-0.5, -1.0);
66 glVertex2f( 0.0, -1.0);
67 glVertex2f( 0.0, 1.0);
68 glVertex2f(-0.5, 1.0);
69 glEnd();
71 glUseShaderProgramEXT(GL_FRAGMENT_SHADER, fs_prog_1);
72 glBegin(GL_TRIANGLE_FAN);
73 glVertex2f(0.0, -1.0);
74 glVertex2f(0.5, -1.0);
75 glVertex2f(0.5, 1.0);
76 glVertex2f(0.0, 1.0);
77 glEnd();
79 glUseShaderProgramEXT(GL_FRAGMENT_SHADER, fs_prog_2);
80 glBegin(GL_TRIANGLE_FAN);
81 glVertex2f(0.5, -1.0);
82 glVertex2f(1.0, -1.0);
83 glVertex2f(1.0, 1.0);
84 glVertex2f(0.5, 1.0);
85 glEnd();
87 pass &= piglit_probe_pixel_rgba(piglit_width * 1 / 8, piglit_height / 2,
88 green);
89 pass &= piglit_probe_pixel_rgba(piglit_width * 3 / 8, piglit_height / 2,
90 blue);
91 pass &= piglit_probe_pixel_rgba(piglit_width * 5 / 8, piglit_height / 2,
92 green);
93 pass &= piglit_probe_pixel_rgba(piglit_width * 7 / 8, piglit_height / 2,
94 blue);
96 piglit_present_results();
98 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
101 void
102 piglit_init(int argc, char **argv)
104 GLint vs, fs1, fs2;
105 const char *vs_source =
106 "void main()\n"
107 "{\n"
108 " gl_Position = gl_Vertex;\n"
109 "}\n";
110 const char *fs1_source =
111 "void main()\n"
112 "{\n"
113 " gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
114 "}\n";
115 const char *fs2_source =
116 "void main()\n"
117 "{\n"
118 " gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0);\n"
119 "}\n";
121 piglit_require_gl_version(20);
122 piglit_require_extension("GL_EXT_separate_shader_objects");
124 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
125 fs1 = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs1_source);
126 fs2 = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs2_source);
127 vs_prog = piglit_link_simple_program(vs, 0);
128 fs_prog_1 = piglit_link_simple_program(0, fs1);
129 fs_prog_2 = piglit_link_simple_program(0, fs2);