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 DEALINGS
24 #include "draw-buffers-common.h"
27 * \file alpha-to-coverage-no-draw-buffer-zero-write.cpp
29 * Verify sample alpha to coverage with multiple draw buffers when nothing
30 * is written to draw buffer zero.
32 * When nothing is written to draw buffer zero, GL_SAMPLE_ALPHA_TO_COVERAGE
33 * usage shouldn't hang the system. The alpha value used to determine
34 * coverage will be undefined which will result in to pixels with undefined
35 * colors. So, pixels can't be probed for color in this test.
37 * From OpenGL 2.1 specification:
38 * "If a fragment shader writes to neither gl FragColor nor gl FragData,
39 * the values of the fragment colors following shader execution are
40 * undefined, and may differ for each fragment color."
42 * It is a significant edge case for i965 driver.
45 PIGLIT_GL_TEST_CONFIG_BEGIN
47 config
.supports_gl_compat_version
= 21;
49 config
.window_width
= 512;
50 config
.window_height
= 768;
51 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
52 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
54 PIGLIT_GL_TEST_CONFIG_END
57 print_usage_and_exit(char *prog_name
)
59 printf("Usage: %s <num_samples>\n", prog_name
);
60 piglit_report_result(PIGLIT_FAIL
);
64 piglit_init(int argc
, char **argv
)
67 /* At present fragment shader supports only fixed number of
70 int num_attachments
= 3;
73 print_usage_and_exit(argv
[0]);
77 samples
= strtol(argv
[1], &endptr
, 0);
78 if (endptr
!= argv
[1] + strlen(argv
[1]))
79 print_usage_and_exit(argv
[0]);
82 piglit_require_extension("GL_ARB_framebuffer_object");
83 piglit_require_extension("GL_ARB_vertex_array_object");
84 piglit_require_extension("GL_EXT_framebuffer_multisample");
86 int pattern_width
= piglit_width
/ 2;
87 int pattern_height
= piglit_height
/ num_attachments
;
89 piglit_ortho_projection(pattern_width
,
93 /* Skip the test if samples > GL_MAX_SAMPLES */
95 glGetIntegerv(GL_MAX_SAMPLES
, &max_samples
);
97 if (samples
< 1 || samples
> max_samples
)
98 piglit_report_result(PIGLIT_SKIP
);
100 ms_fbo_and_draw_buffers_setup(samples
,
105 GL_RGBA
/* color_buffer_zero_format */);
106 shader_compile(true /* sample_alpha_to_coverage */,
107 false /* dual_src_blend */,
108 false /* frag_out_zero_write */);
116 glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, piglit_winsys_fbo
);
117 glClearColor(0.0, 0.0, 0.0, 1.0);
118 glClear(GL_COLOR_BUFFER_BIT
);
119 allocate_data_arrays();
121 draw_test_image(true /* sample_alpha_to_coverage */,
122 false /* sample_alpha_to_one */);
124 pass
= piglit_check_gl_error(GL_NO_ERROR
);
126 /* Free the memory allocated for data arrays */
129 if (!piglit_automatic
)
130 piglit_present_results();
132 /* The fragment colors are undefined in this test. So, we can't probe
133 * the pixels. If test executes to completion without error, return
136 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;