framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_gpu_shader_fp64 / fs-non-uniform-control-flow-const.c
blob4c9bb5f689fd4c7f9164c903fa32645220fcc088
1 /*
2 * Copyright © 2016 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
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 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
21 * DEALINGS IN THE SOFTWARE.
24 /** @file fs-non-uniform-control-flow-const.c
26 * Checks that constant writes to double type variables in GLSL
27 * work correctly when they are under non-uniform control flow.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.window_width = 62;
34 config.window_height = 62;
35 config.supports_gl_compat_version = 32;
36 config.supports_gl_core_version = 32;
37 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
38 config.khr_no_error_support = PIGLIT_NO_ERRORS;
39 PIGLIT_GL_TEST_CONFIG_END
41 static const char vs_pass_thru_text[] =
42 "#version 130\n"
43 "\n"
44 "in vec4 piglit_vertex;\n"
45 "void main() {\n"
46 " gl_Position = piglit_vertex;\n"
47 "}\n";
49 static const char fs_source[] =
50 "#version 150\n"
51 "#extension GL_ARB_gpu_shader_fp64 : require\n"
52 "\n"
53 "out vec4 color;\n"
54 "\n"
55 "void main() {\n"
56 " int cx = int(gl_FragCoord.x) / 31;\n"
57 " int cy = int(gl_FragCoord.y) / 31;\n"
58 " dvec2 colord;\n"
59 " if ((cx + cy) % 2 == 0)\n"
60 " colord = dvec2(1.0lf, 0.0lf);\n"
61 " else\n"
62 " colord = dvec2(0.0lf, 1.0lf);\n"
63 " color = vec4(colord, 0, 1);\n"
64 "}\n";
66 GLuint prog;
68 void
69 piglit_init(int argc, char **argv)
71 piglit_require_extension("GL_ARB_gpu_shader_fp64");
73 prog = piglit_build_simple_program(vs_pass_thru_text, fs_source);
75 glUseProgram(prog);
77 glClearColor(0, 0, 0, 1);
79 if (!piglit_check_gl_error(GL_NO_ERROR))
80 piglit_report_result(PIGLIT_FAIL);
83 enum piglit_result piglit_display(void)
85 bool pass = true;
86 const int num_pixels = piglit_width * piglit_height;
87 float *srcPixels = malloc(num_pixels * 4 * sizeof(float));
88 float expected[4];
89 int i, j;
91 glViewport(0, 0, piglit_width, piglit_height);
92 glUseProgram(prog);
93 glClear(GL_COLOR_BUFFER_BIT);
95 piglit_draw_rect(-1, -1, 2, 2);
97 glReadPixels(0, 0, piglit_width, piglit_height,
98 GL_RGBA, GL_FLOAT, srcPixels);
100 /* Verify */
101 for (i = 0; i < piglit_height; i++) {
102 for (j = 0; j < piglit_width; j++) {
103 int cx = j / 31;
104 int cy = i / 31;
105 int pos = (i * piglit_width + j) * 4;
106 if ((cx + cy) % 2 != 0) {
107 expected[0] = 0.0;
108 expected[1] = 1.0;
109 expected[2] = 0.0;
110 expected[3] = 1.0;
111 } else {
112 expected[0] = 1.0;
113 expected[1] = 0.0;
114 expected[2] = 0.0;
115 expected[3] = 1.0;
118 pass = piglit_compare_pixels(j, i, expected,
119 srcPixels + pos,
120 piglit_tolerance,
121 4) && pass;
124 piglit_present_results();
125 free(srcPixels);
127 return pass ? PIGLIT_PASS : PIGLIT_FAIL;