framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / shaders / fp-lit-src-equals-dst.c
blob90e19f4c2071cd2be5b147720f45bc3833e5d3cf
1 /*
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
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 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.
23 * Authors:
24 * Pierre-Eric Pelloux-Prayer <pelloux@gmail.com>
27 /**
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[] =
47 "!!ARBfp1.0\n"
48 "PARAM values = { 0.65, 0.9, 0.0, 8.0 }; \n"
49 "PARAM bogus = { 0.8, 0.8, 0.8, 0.8 }; \n"
50 "TEMP _values; \n"
51 "MOV _values, values; \n"
52 "MOV result.color, bogus; \n"
53 "LIT _values, _values; \n"
54 "MOV result.color.%s, _values; \n"
55 "END\n";
56 static float LitExpected[4] = { 1.0, 0.65, 0.433, 1.0 };
58 static void DoFrame(void)
60 int mask;
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]);
69 glPushMatrix();
70 glTranslatef((mask % 4), (mask / 4), 0.0);
72 glBegin(GL_QUADS);
73 glVertex2f(0, 0);
74 glVertex2f(1, 0);
75 glVertex2f(1, 1);
76 glVertex2f(0, 1);
77 glEnd();
79 glPopMatrix();
83 static bool
84 DoTest(void)
86 int mask;
87 bool pass = true;
89 for(mask = 1; mask < 16; ++mask) {
90 float expected[4];
91 int i;
93 for(i = 0; i < 4; ++i) {
94 if (mask & (1 << i))
95 expected[i] = LitExpected[i];
96 else
97 expected[i] = 0.8;
100 pass = piglit_probe_pixel_rgba(piglit_width * (2*(mask%4)+1)/8,
101 piglit_height * (2*(mask/4)+1)/8,
102 expected) && pass;
105 return pass;
108 enum piglit_result
109 piglit_display(void)
111 int pass;
113 DoFrame();
114 pass = DoTest();
116 piglit_present_results();
118 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
121 void piglit_init(int argc, char **argv)
123 int mask;
125 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
127 piglit_require_fragment_program();
130 * Fragment programs
132 for(mask = 1; mask < 16; ++mask) {
133 char programText[1024];
134 char maskstring[5];
136 maskstring[0] = 0;
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);