ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_framebuffer_multisample / alpha-to-coverage-no-draw-buffer-zero-write.cpp
blob450c9e6037c317635cad0613fd5a2966c05dba43
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 DEALINGS
21 * IN THE SOFTWARE.
24 #include "draw-buffers-common.h"
26 /**
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
56 void
57 print_usage_and_exit(char *prog_name)
59 printf("Usage: %s <num_samples>\n", prog_name);
60 piglit_report_result(PIGLIT_FAIL);
63 void
64 piglit_init(int argc, char **argv)
66 int samples;
67 /* At present fragment shader supports only fixed number of
68 * attachments (3)
70 int num_attachments = 3;
72 if (argc < 2)
73 print_usage_and_exit(argv[0]);
76 char *endptr = NULL;
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,
90 pattern_height,
91 GL_TRUE);
93 /* Skip the test if samples > GL_MAX_SAMPLES */
94 GLint 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,
101 pattern_width,
102 pattern_height,
103 num_attachments,
104 GL_COLOR_BUFFER_BIT,
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 */);
111 enum piglit_result
112 piglit_display()
114 bool pass;
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 */
127 free_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
134 * PIGLIT_PASS.
136 return pass ? PIGLIT_PASS : PIGLIT_FAIL;