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
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
;
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);
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);
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);
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);
87 pass
&= piglit_probe_pixel_rgba(piglit_width
* 1 / 8, piglit_height
/ 2,
89 pass
&= piglit_probe_pixel_rgba(piglit_width
* 3 / 8, piglit_height
/ 2,
91 pass
&= piglit_probe_pixel_rgba(piglit_width
* 5 / 8, piglit_height
/ 2,
93 pass
&= piglit_probe_pixel_rgba(piglit_width
* 7 / 8, piglit_height
/ 2,
96 piglit_present_results();
98 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
102 piglit_init(int argc
, char **argv
)
105 const char *vs_source
=
108 " gl_Position = gl_Vertex;\n"
110 const char *fs1_source
=
113 " gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
115 const char *fs2_source
=
118 " gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0);\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
);