2 * Copyright © 2012 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 int-draw-buffers-alpha-to-coverage.cpp
29 * Verify sample alpha to coverage with integer draw buffers.
31 * When draw buffer zero is bound to an integer format buffer,
32 * GL_SAMPLE_ALPHA_TO_COVERAGE should have no effect. This should work
33 * properly even if there are other draw buffers that are not in integer
36 * This test operates by drawing a pattern in multisample FBO to generate
37 * reference and test images for all the draw buffers. Reference images are drawn
38 * to right half of window system draw buffer and test images to left half.
40 * Compare the left and right halves of window system frame buffer to verify
43 * Author: Anuj Phogat <anuj.phogat@gmail.com>
46 PIGLIT_GL_TEST_CONFIG_BEGIN
48 config
.supports_gl_compat_version
= 10;
50 config
.window_width
= 512;
51 config
.window_height
= 768;
52 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
53 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
55 PIGLIT_GL_TEST_CONFIG_END
57 /* At present fragment shader in draw-buffers-common.cpp supports only
58 * fixed number of attachments = 3.
60 static int num_attachments
= 3;
64 print_usage_and_exit(char *prog_name
)
66 printf("Usage: %s <num_samples>\n", prog_name
);
67 piglit_report_result(PIGLIT_FAIL
);
71 piglit_init(int argc
, char **argv
)
75 print_usage_and_exit(argv
[0]);
78 samples
= strtol(argv
[1], &endptr
, 0);
79 if (endptr
!= argv
[1] + strlen(argv
[1]))
80 print_usage_and_exit(argv
[0]);
83 piglit_require_gl_version(30);
85 int pattern_width
= piglit_width
/ 2;
86 int pattern_height
= piglit_height
/ num_attachments
;
88 piglit_ortho_projection(pattern_width
,
91 /* Skip the test if samples > GL_MAX_SAMPLES */
93 glGetIntegerv(GL_MAX_SAMPLES
, &max_samples
);
95 if (samples
> max_samples
)
96 piglit_report_result(PIGLIT_SKIP
);
97 /* Testing of integer formats other than GL_RGBA8I is not supported
98 * by utility functions in draw-buffers-common.cpp.
100 ms_fbo_and_draw_buffers_setup(samples
,
106 shader_compile(true /* sample_alpha_to_coverage */,
107 false /* dual_src_blend */,
108 true /* frag_out_zero_write */);
115 glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, piglit_winsys_fbo
);
116 glClearColor(0.0, 0.0, 0.0, 1.0);
117 glClear(GL_COLOR_BUFFER_BIT
);
118 allocate_data_arrays();
120 draw_reference_image(true /* sample_alpha_to_coverage */,
121 false /* sample_alpha_to_one */);
123 draw_test_image(true /* sample_alpha_to_coverage */,
124 false /* sample_alpha_to_one */);
126 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
128 glBindFramebuffer(GL_READ_FRAMEBUFFER
, piglit_winsys_fbo
);
129 pass
= piglit_probe_rect_halves_equal_rgba(0, 0,
134 /* Free the memory allocated for data arrays */
137 if (!piglit_automatic
)
138 piglit_present_results();
140 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;