cl: Don't use device_infos if num_device_infos == 0
[piglit.git] / tests / shaders / useprogram-flushverts-1.c
blob9259031b811f844c791514b851fb0c1504832223
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 useprogram-flushverts-2.c
30 * Tests that a change in the shader results in previous vertices
31 * 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 prog1, prog2;
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 glUseProgram(prog1);
54 glBegin(GL_TRIANGLE_FAN);
55 glVertex2f(-1.0, -1.0);
56 glVertex2f(-0.5, -1.0);
57 glVertex2f(-0.5, 1.0);
58 glVertex2f(-1.0, 1.0);
59 glEnd();
61 glUseProgram(prog2);
62 glBegin(GL_TRIANGLE_FAN);
63 glVertex2f(-0.5, -1.0);
64 glVertex2f( 0.0, -1.0);
65 glVertex2f( 0.0, 1.0);
66 glVertex2f(-0.5, 1.0);
67 glEnd();
69 glUseProgram(prog1);
70 glBegin(GL_TRIANGLE_FAN);
71 glVertex2f(0.0, -1.0);
72 glVertex2f(0.5, -1.0);
73 glVertex2f(0.5, 1.0);
74 glVertex2f(0.0, 1.0);
75 glEnd();
77 glUseProgram(prog2);
78 glBegin(GL_TRIANGLE_FAN);
79 glVertex2f(0.5, -1.0);
80 glVertex2f(1.0, -1.0);
81 glVertex2f(1.0, 1.0);
82 glVertex2f(0.5, 1.0);
83 glEnd();
85 pass &= piglit_probe_pixel_rgba(piglit_width * 1 / 8, piglit_height / 2,
86 green);
87 pass &= piglit_probe_pixel_rgba(piglit_width * 3 / 8, piglit_height / 2,
88 blue);
89 pass &= piglit_probe_pixel_rgba(piglit_width * 5 / 8, piglit_height / 2,
90 green);
91 pass &= piglit_probe_pixel_rgba(piglit_width * 7 / 8, piglit_height / 2,
92 blue);
94 piglit_present_results();
96 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
99 void
100 piglit_init(int argc, char **argv)
102 GLint vs, fs1, fs2;
103 const char *vs_source =
104 "void main()\n"
105 "{\n"
106 " gl_Position = gl_Vertex;\n"
107 "}\n";
108 const char *fs1_source =
109 "void main()\n"
110 "{\n"
111 " gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
112 "}\n";
113 const char *fs2_source =
114 "void main()\n"
115 "{\n"
116 " gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0);\n"
117 "}\n";
119 piglit_require_gl_version(20);
121 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
122 fs1 = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs1_source);
123 fs2 = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs2_source);
124 prog1 = piglit_link_simple_program(vs, fs1);
125 prog2 = piglit_link_simple_program(vs, fs2);