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
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
[] =
44 "in vec4 piglit_vertex;\n"
46 " gl_Position = piglit_vertex;\n"
49 static const char fs_source
[] =
51 "#extension GL_ARB_gpu_shader_fp64 : require\n"
56 " int cx = int(gl_FragCoord.x) / 31;\n"
57 " int cy = int(gl_FragCoord.y) / 31;\n"
59 " if ((cx + cy) % 2 == 0)\n"
60 " colord = dvec2(1.0lf, 0.0lf);\n"
62 " colord = dvec2(0.0lf, 1.0lf);\n"
63 " color = vec4(colord, 0, 1);\n"
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
);
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)
86 const int num_pixels
= piglit_width
* piglit_height
;
87 float *srcPixels
= malloc(num_pixels
* 4 * sizeof(float));
91 glViewport(0, 0, piglit_width
, piglit_height
);
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
);
101 for (i
= 0; i
< piglit_height
; i
++) {
102 for (j
= 0; j
< piglit_width
; j
++) {
105 int pos
= (i
* piglit_width
+ j
) * 4;
106 if ((cx
+ cy
) % 2 != 0) {
118 pass
= piglit_compare_pixels(j
, i
, expected
,
124 piglit_present_results();
127 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;