2 * Copyright (c) The Piglit project 2007
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Test KIL instruction.
28 #include "piglit-util-gl.h"
30 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config
.supports_gl_compat_version
= 10;
34 config
.window_width
= 200;
35 config
.window_height
= 200;
36 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_DEPTH
;
38 PIGLIT_GL_TEST_CONFIG_END
40 #define NUM_PROGRAMS 2
42 static GLuint FragProg
[NUM_PROGRAMS
];
44 static const char* const ProgramText
[NUM_PROGRAMS
] = {
47 "MOV result.color, fragment.color;\n"
48 "KIL fragment.texcoord[0];\n"
53 "TEX r0, fragment.texcoord[0], texture[0], 2D;\n"
55 "MOV result.color, fragment.color;\n"
59 static void DoFrame(void)
61 glClearColor(0.0, 0.0, 0.0, 1.0);
62 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
64 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
66 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, FragProg
[0]);
68 glColor3f(0.0, 1.0, 0.0);
80 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, FragProg
[1]);
103 { 0.0, 0.0, 0.0, 1.0 }
108 { 0.0, 0.0, 0.0, 1.0 }
113 { 0.0, 1.0, 0.0, 1.0 }
118 { 0.0, 0.0, 0.0, 1.0 }
125 { 0.0, 1.0, 0.0, 1.0 }
130 { 0.0, 0.0, 0.0, 1.0 }
135 { 0.0, 0.0, 0.0, 1.0 }
140 { 0.0, 0.0, 0.0, 1.0 }
145 { 0.0, 0.0, 0.0, 1.0 }
150 { 0.0, 0.0, 0.0, 1.0 }
155 { 0.0, 0.0, 0.0, 1.0 }
160 { 0.0, 0.0, 0.0, 1.0 }
165 { 0.0, 0.0, 0.0, 1.0 }
170 { 0.0, 0.0, 0.0, 1.0 }
175 { 0.0, 0.0, 0.0, 1.0 }
180 { 0.0, 0.0, 0.0, 1.0 }
185 { 0.0, 0.0, 0.0, 1.0 }
190 { 0.0, 0.0, 0.0, 1.0 }
195 { 0.0, 0.0, 0.0, 1.0 }
200 { 0.0, 0.0, 0.0, 1.0 }
211 static bool DoTest( void )
216 while(Probes
[idx
].name
) {
217 pass
= piglit_probe_pixel_rgba(
218 (int)(Probes
[idx
].x
*piglit_width
/2),
219 (int)(Probes
[idx
].y
*piglit_height
/2),
220 Probes
[idx
].expected
) && pass
;
232 piglit_gen_ortho_projection(0.0, 2.0, 0.0, 2.0, -2.0, 6.0, GL_FALSE
);
236 piglit_present_results();
238 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
242 piglit_init(int argc
, char **argv
)
246 GLubyte tex
[4][4][4];
248 piglit_require_gl_version(13);
250 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
252 piglit_require_fragment_program();
257 for(i
= 0; i
< NUM_PROGRAMS
; ++i
)
258 FragProg
[i
] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB
, ProgramText
[i
]);
263 for(y
= 0; y
< 4; ++y
) {
264 for(x
= 0; x
< 4; ++x
) {
265 tex
[y
][x
][0] = (x
& 1) ? 255 : 0;
266 tex
[y
][x
][1] = (x
& 2) ? 255 : 0;
267 tex
[y
][x
][2] = (y
& 1) ? 255 : 0;
268 tex
[y
][x
][3] = (y
& 2) ? 255 : 0;
272 glGenTextures(1, &texname
);
273 glActiveTexture(GL_TEXTURE0
);
274 glEnable(GL_TEXTURE_2D
);
275 glBindTexture(GL_TEXTURE_2D
, texname
);
276 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 4, 4, 0,
277 GL_RGBA
, GL_UNSIGNED_BYTE
, tex
);
279 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
280 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);