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.
24 * Pierre-Eric Pelloux-Prayer <pelloux@gmail.com>
28 * Test whether LIT behaves correctly with src == dst
29 * (Heavily based on fp-lit-mask.c)
32 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
36 config
.supports_gl_compat_version
= 10;
38 config
.window_width
= 200;
39 config
.window_height
= 200;
40 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_DEPTH
;
42 PIGLIT_GL_TEST_CONFIG_END
44 static GLuint FragProg
[15];
46 static const char fragProgramTemplate
[] =
48 "PARAM values = { 0.65, 0.9, 0.0, 8.0 }; \n"
49 "PARAM bogus = { 0.8, 0.8, 0.8, 0.8 }; \n"
51 "MOV _values, values; \n"
52 "MOV result.color, bogus; \n"
53 "LIT _values, _values; \n"
54 "MOV result.color.%s, _values; \n"
56 static float LitExpected
[4] = { 1.0, 0.65, 0.433, 1.0 };
58 static void DoFrame(void)
62 glClearColor(0.0, 0.0, 0.0, 0.0);
63 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
65 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
67 for(mask
= 1; mask
< 16; ++mask
) {
68 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, FragProg
[mask
-1]);
70 glTranslatef((mask
% 4), (mask
/ 4), 0.0);
89 for(mask
= 1; mask
< 16; ++mask
) {
93 for(i
= 0; i
< 4; ++i
) {
95 expected
[i
] = LitExpected
[i
];
100 pass
= piglit_probe_pixel_rgba(piglit_width
* (2*(mask
%4)+1)/8,
101 piglit_height
* (2*(mask
/4)+1)/8,
116 piglit_present_results();
118 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
121 void piglit_init(int argc
, char **argv
)
125 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
127 piglit_require_fragment_program();
132 for(mask
= 1; mask
< 16; ++mask
) {
133 char programText
[1024];
137 if (mask
& 1) strcat(maskstring
, "x");
138 if (mask
& 2) strcat(maskstring
, "y");
139 if (mask
& 4) strcat(maskstring
, "z");
140 if (mask
& 8) strcat(maskstring
, "w");
141 sprintf(programText
, fragProgramTemplate
, maskstring
);
143 FragProg
[mask
-1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB
, programText
);
146 piglit_ortho_projection(4.0, 4.0, GL_FALSE
);