glsl: test loop unroll with uint overflow
[piglit.git] / tests / spec / ext_framebuffer_multisample / alpha-to-one-dual-src-blend.cpp
blob677f95d4a3efed9ce3f43020d4ef617e21f93ff4
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-dual-src-blend.cpp
29 * Verify sample-alpha-to-one with dual source blending.
31 * This test operates by drawing a pattern in multisample FBO to generate
32 * a reference and test image. Reference image is drawn to the right half of
33 * window system draw buffer and test image to the left half.
35 * Compare the left and right halves of window system frame buffer to verify
36 * the test image.
38 * Author: Anuj Phogat <anuj.phogat@gmail.com>
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config.supports_gl_compat_version = 10;
45 config.window_width = 512;
46 config.window_height = 256;
47 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
48 config.khr_no_error_support = PIGLIT_NO_ERRORS;
50 PIGLIT_GL_TEST_CONFIG_END
51 void
52 print_usage_and_exit(char *prog_name)
54 printf("Usage: %s <num_samples>\n", prog_name);
55 piglit_report_result(PIGLIT_FAIL);
58 void
59 piglit_init(int argc, char **argv)
61 int samples;
62 const int num_attachments = 1;
64 if (argc < 2)
65 print_usage_and_exit(argv[0]);
67 char *endptr = NULL;
68 samples = strtol(argv[1], &endptr, 0);
69 if (endptr != argv[1] + strlen(argv[1]))
70 print_usage_and_exit(argv[0]);
73 piglit_require_gl_version(30);
75 int pattern_width = piglit_width / 2;
76 int pattern_height = piglit_height / num_attachments;
78 piglit_ortho_projection(pattern_width,
79 pattern_height,
80 GL_TRUE);
82 /* Skip the test if samples > GL_MAX_SAMPLES */
83 GLint max_samples;
84 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
86 if (samples > max_samples)
87 piglit_report_result(PIGLIT_SKIP);
89 ms_fbo_and_draw_buffers_setup(samples,
90 pattern_width,
91 pattern_height,
92 num_attachments,
93 GL_COLOR_BUFFER_BIT,
94 GL_RGBA);
96 shader_compile(false /* sample_alpha_to_coverage */,
97 true /* dual_src_blend */,
98 true /* frag_out_zero_write */);
101 enum piglit_result
102 piglit_display()
104 bool pass = true;
105 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
106 glClearColor(0.0, 0.0, 0.0, 1.0);
107 glClear(GL_COLOR_BUFFER_BIT);
108 allocate_data_arrays();
110 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC1_ALPHA);
112 /* Reference image is drawn using expected color values and
113 * represents an expected output for the test image.
115 draw_reference_image(false /* sample_alpha_to_coverage */,
116 true /* sample_alpha_to_one */);
118 glEnable(GL_BLEND);
119 draw_test_image(false /* sample_alpha_to_coverage */,
120 true /* sample_alpha_to_one */);
122 glDisable(GL_BLEND);
123 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
125 glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo);
126 pass = piglit_probe_rect_halves_equal_rgba(0, 0,
127 piglit_width,
128 piglit_height)
129 && pass;
131 /* Free the memory allocated for data arrays */
132 free_data_arrays();
134 if (!piglit_automatic)
135 piglit_present_results();
137 return pass ? PIGLIT_PASS : PIGLIT_FAIL;