framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / shaders / fp-incomplete-tex.c
blob2e68b55448765fbeb26ce94c1333a39edb5bc081
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.
24 /**
25 * According to the ARB_fragment_program spec, section 3.11.6,
26 * sampling an incomplete texture image yields (0,0,0,1).
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.supports_gl_compat_version = 10;
35 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;
37 PIGLIT_GL_TEST_CONFIG_END
39 #define NUM_PROGRAMS 5
41 static GLuint FragProg[NUM_PROGRAMS];
43 static const char* const ProgramText[NUM_PROGRAMS] = {
44 "!!ARBfp1.0\n"
45 "TEX result.color, fragment.color, texture[0], 2D;\n"
46 "END",
48 "!!ARBfp1.0\n"
49 "TEX result.color, fragment.color, texture[0], 3D;\n"
50 "END",
52 "!!ARBfp1.0\n"
53 "TEX result.color, fragment.color, texture[0], 1D;\n"
54 "END",
56 "!!ARBfp1.0\n"
57 "TEX result.color, fragment.color, texture[0], CUBE;\n"
58 "END",
60 "!!ARBfp1.0\n"
61 "TEX result.color, fragment.color, texture[0], RECT;\n"
62 "END"
65 static void DoFrame(void)
67 int i;
69 glClearColor(0.3, 0.3, 0.3, 0.3);
70 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
72 glEnable(GL_FRAGMENT_PROGRAM_ARB);
74 for(i = 0; i < NUM_PROGRAMS; ++i) {
75 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[i]);
77 glPushMatrix();
78 glTranslatef(i/2, i%2, 0);
79 glBegin(GL_QUADS);
80 glVertex2f(0, 0);
81 glVertex2f(1, 0);
82 glVertex2f(1, 1);
83 glVertex2f(0, 1);
84 glEnd();
85 glPopMatrix();
89 static const struct {
90 const char* name;
91 float x, y;
92 float expected[4];
93 } Probes[] = {
95 "incomplete 2D",
96 0.5, 0.5,
97 { 0,0,0,1 }
100 "incomplete 3D",
101 0.5, 1.5,
102 { 0,0,0,1 }
105 "incomplete 1D",
106 1.5, 0.5,
107 { 0,0,0,1 }
110 "incomplete CUBE",
111 1.5, 1.5,
112 { 0,0,0,1 }
115 "incomplete RECT",
116 2.5, 0.5,
117 { 0,0,0,1 }
121 "sanity",
122 2.5, 1.5,
123 { 0.3,0.3,0.3,0.3 }
126 // Sentinel!
129 0, 0,
130 { 0, 0, 0, 0 }
134 static bool DoTest( void )
136 int idx = 0;
137 bool pass = true;
139 while(Probes[idx].name) {
140 pass = piglit_probe_pixel_rgba(
141 (int)(Probes[idx].x * piglit_width / 3),
142 (int)(Probes[idx].y * piglit_height / 2),
143 Probes[idx].expected) && pass;
144 idx++;
147 return pass;
151 enum piglit_result
152 piglit_display(void)
154 bool pass;
156 DoFrame();
157 pass = DoTest();
158 piglit_present_results();
160 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
163 void
164 piglit_init(int argc, char **argv)
166 int i;
168 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
170 piglit_require_fragment_program();
172 for(i = 0; i < NUM_PROGRAMS; ++i)
173 FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);
175 piglit_gen_ortho_projection(0.0, 3.0, 0.0, 2.0, -2.0, 6.0, GL_FALSE);