glsl: test loop unroll with uint overflow
[piglit.git] / tests / spec / ext_framebuffer_multisample / samples.c
blob02d05b1b7087b578f1e1561d2deae1c93ecc7176
1 /*
2 * Copyright © 2011 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 "piglit-util-gl.h"
26 /**
27 * @file samples.c
29 * From the EXT_framebuffer_multisample spec:
31 * "The values of SAMPLE_BUFFERS and SAMPLES are derived from the
32 * attachments of the currently bound framebuffer object. If the
33 * current DRAW_FRAMEBUFFER_BINDING_EXT is not "framebuffer
34 * complete", then both SAMPLE_BUFFERS and SAMPLES are undefined.
35 * Otherwise, SAMPLES is equal to the value of
36 * RENDERBUFFER_SAMPLES_EXT for the attached images (which all
37 * must have the same value for RENDERBUFFER_SAMPLES_EXT).
38 * Further, SAMPLE_BUFFERS is one if SAMPLES is non-zero.
39 * Otherwise, SAMPLE_BUFFERS is zero."
41 * See also negative-mismatched-samples.c.
44 PIGLIT_GL_TEST_CONFIG_BEGIN
46 config.supports_gl_compat_version = 10;
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 enum piglit_result
54 piglit_display(void)
56 /* UNREACHED */
57 return PIGLIT_FAIL;
60 void
61 piglit_init(int argc, char **argv)
63 GLint max_samples, sample_buffers, samples, rb_samples;
64 GLuint rb, fb;
65 GLenum status;
66 bool pass = true;
67 int i;
69 piglit_require_extension("GL_EXT_framebuffer_multisample");
71 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
73 glGenFramebuffersEXT(1, &fb);
74 glBindFramebufferEXT(GL_FRAMEBUFFER, fb);
76 glDrawBuffer(GL_COLOR_ATTACHMENT0);
77 glReadBuffer(GL_COLOR_ATTACHMENT0);
79 for (i = 0; i < max_samples; i++) {
80 glGenRenderbuffersEXT(1, &rb);
81 glBindRenderbufferEXT(GL_RENDERBUFFER, rb);
82 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
83 max_samples,
84 GL_RGBA, 1, 1);
86 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
87 GL_COLOR_ATTACHMENT0,
88 GL_RENDERBUFFER, rb);
90 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
91 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
92 fprintf(stderr, "FBO incomplete\n");
93 piglit_report_result(PIGLIT_FAIL);
96 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER,
97 GL_RENDERBUFFER_SAMPLES,
98 &rb_samples);
100 glGetIntegerv(GL_SAMPLES, &samples);
101 if (rb_samples != samples) {
102 fprintf(stderr,
103 "FBO reported GL_SAMPLES %d for "
104 "rb samples %d\n",
105 samples, rb_samples);
106 pass = false;
109 glGetIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers);
110 if ((rb_samples != 0) != (sample_buffers == 1)) {
111 fprintf(stderr,
112 "FBO reported GL_SAMPLE_BUFFERS %d for "
113 "rb samples %d\n",
114 sample_buffers, samples);
115 pass = false;
118 glDeleteRenderbuffersEXT(1, &rb);
121 glDeleteFramebuffersEXT(1, &fb);
123 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);