ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_framebuffer_multisample / alpha-to-one-single-sample-buffer.cpp
blobbb5d0ea224ea68396a841f0e6f39d6055bcb6901
1 /*
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
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-one-single-sample-buffer.cpp
29 * Verify that alpha values are not modified if GL_SAMPLE_ALPHA_TO_ONE
30 * is enabled and the buffer is single-sampled.
32 * This test operates by drawing a pattern in single sample FBO to generate
33 * a reference and test image. Reference imag is drawn to the right half of
34 * window system draw buffer and test image to the left half.
36 * Compare the left and right halves of window system frame buffer to verify
37 * the test image.
39 * Author: Anuj Phogat <anuj.phogat@gmail.com>
42 PIGLIT_GL_TEST_CONFIG_BEGIN
44 config.supports_gl_compat_version = 10;
46 config.window_width = 512;
47 config.window_height = 256;
48 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
49 config.khr_no_error_support = PIGLIT_NO_ERRORS;
51 PIGLIT_GL_TEST_CONFIG_END
53 void
54 piglit_init(int argc, char **argv)
56 const int num_attachments = 1;
57 /* For single sample buffer */
58 const int samples = 0;
60 piglit_require_gl_version(21);
61 piglit_require_extension("GL_ARB_framebuffer_object");
62 piglit_require_extension("GL_ARB_vertex_array_object");
64 int pattern_width = piglit_width / 2;
65 int pattern_height = piglit_height / num_attachments;
67 piglit_ortho_projection(pattern_width,
68 pattern_height,
69 GL_TRUE);
71 /* Skip the test if samples > GL_MAX_SAMPLES */
72 GLint max_samples;
73 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
75 if (samples > max_samples)
76 piglit_report_result(PIGLIT_SKIP);
78 ms_fbo_and_draw_buffers_setup(samples,
79 pattern_width,
80 pattern_height,
81 num_attachments,
82 GL_COLOR_BUFFER_BIT,
83 GL_RGBA);
84 shader_compile(false /* sample_alpha_to_coverage */,
85 false /* dual_src_blend */,
86 true /* frag_out_zero_write */);
89 enum piglit_result
90 piglit_display()
92 bool pass = true;
93 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
94 glClearColor(0.0, 0.0, 0.0, 1.0);
95 glClear(GL_COLOR_BUFFER_BIT);
96 allocate_data_arrays();
98 /* Set sample_alpha_to_one = false to generate reference image */
99 draw_reference_image(false /* sample_alpha_to_coverage */,
100 false /* sample_alpha_to_one */);
102 draw_test_image(false /* sample_alpha_to_coverage */,
103 true /* sample_alpha_to_one */);
105 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
107 glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo);
108 pass = piglit_probe_rect_halves_equal_rgba(0, 0,
109 piglit_width,
110 piglit_height)
111 && pass;
113 /* Free the memory allocated for data arrays */
114 free_data_arrays();
116 if (!piglit_automatic)
117 piglit_present_results();
119 return pass ? PIGLIT_PASS : PIGLIT_FAIL;