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
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
24 #include "piglit-util-gl.h"
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
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
57 test_buffers(GLuint rb0
, GLuint samples0
,
58 GLuint rb1
, GLuint samples1
)
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
) {
74 "Framebuffer with %d and %d samples: "
76 "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
77 samples0
, samples1
, status
);
80 } else if (status
!= GL_FRAMEBUFFER_COMPLETE
) {
82 "Framebuffer with %d and %d samples incomplete: "
83 "reported 0x%x, not GL_FRAMEBUFFER_COMPLETE\n",
84 samples0
, samples1
, status
);
91 piglit_init(int argc
, char **argv
)
93 GLint max_samples
, max_draw_buffers
;
98 static const GLenum buffers
[2] = {
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
,
131 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER
,
132 GL_RENDERBUFFER_SAMPLES
,
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
);
149 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);