ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_framebuffer_multisample / negative-mismatched-samples.c
blobe4851100e0b2a1dc2db2a74f346f9d2b9c426cb6
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 * "Modification to 4.4.4.2 (Framebuffer Completeness)
33 * Add an entry to the bullet list:
35 * * The value of RENDERBUFFER_SAMPLES_EXT is the same for all attached
36 * images.
37 * { FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT }"
40 PIGLIT_GL_TEST_CONFIG_BEGIN
42 config.supports_gl_compat_version = 10;
44 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
45 config.khr_no_error_support = PIGLIT_NO_ERRORS;
47 PIGLIT_GL_TEST_CONFIG_END
49 enum piglit_result
50 piglit_display(void)
52 /* UNREACHED */
53 return PIGLIT_FAIL;
56 static bool
57 test_buffers(GLuint rb0, GLuint samples0,
58 GLuint rb1, GLuint samples1)
60 GLenum status;
62 if (rb0 == rb1)
63 return true;
65 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
66 GL_RENDERBUFFER, rb0);
67 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
68 GL_RENDERBUFFER, rb1);
70 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
71 if (samples0 != samples1) {
72 if (status != GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE) {
73 fprintf(stderr,
74 "Framebuffer with %d and %d samples: "
75 "reported 0x%x, not "
76 "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
77 samples0, samples1, status);
78 return false;
80 } else if (status != GL_FRAMEBUFFER_COMPLETE) {
81 fprintf(stderr,
82 "Framebuffer with %d and %d samples incomplete: "
83 "reported 0x%x, not GL_FRAMEBUFFER_COMPLETE\n",
84 samples0, samples1, status);
85 return false;
87 return true;
90 void
91 piglit_init(int argc, char **argv)
93 GLint max_samples, max_draw_buffers;
94 GLuint *rb, fb;
95 GLint *rb_samples;
96 bool pass = true;
97 int i, buf0, buf1;
98 static const GLenum buffers[2] = {
99 GL_COLOR_ATTACHMENT0,
100 GL_COLOR_ATTACHMENT1
103 piglit_require_extension("GL_EXT_framebuffer_multisample");
104 piglit_require_extension("GL_ARB_draw_buffers");
106 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
107 if (max_draw_buffers < 2) {
108 printf("test requires 2 draw buffers.\n");
109 piglit_report_result(PIGLIT_SKIP);
112 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
114 rb = malloc(max_samples * sizeof(*rb));
115 rb_samples = malloc(max_samples * sizeof(*rb_samples));
117 glGenFramebuffersEXT(1, &fb);
118 glBindFramebufferEXT(GL_FRAMEBUFFER, fb);
120 glDrawBuffers(2, buffers);
121 glReadBuffer(GL_COLOR_ATTACHMENT0);
123 glGenRenderbuffers(max_samples, rb);
125 for (i = 0; i < max_samples; i++) {
126 glBindRenderbufferEXT(GL_RENDERBUFFER, rb[i]);
127 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
129 GL_RGBA, 1, 1);
131 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER,
132 GL_RENDERBUFFER_SAMPLES,
133 &rb_samples[i]);
136 for (buf0 = 0; buf0 < max_samples; buf0++) {
137 for (buf1 = 0; buf1 < max_samples; buf1++) {
138 pass = test_buffers(rb[buf0], rb_samples[buf0],
139 rb[buf1], rb_samples[buf1]) && pass;
143 glDeleteFramebuffersEXT(1, &fb);
144 glDeleteRenderbuffersEXT(max_samples, rb);
146 free(rb);
147 free(rb_samples);
149 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);