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
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
25 * @file blit-mismatched-samples.cpp
27 * This test verifies if glBlitFramebuffer() throws GL_INVALID_OPERATION with
28 * non-matching samples in multisample framebuffer objects.
30 * We initialize two FBOs with different sample counts, do blitting operation
31 * and then query the gl error.
33 * Author: Anuj Phogat <anuj.phogat@gmail.com>
36 #include "piglit-test-pattern.h"
37 #include "piglit-fbo.h"
38 using namespace piglit_util_fbo
;
39 using namespace piglit_util_test_pattern
;
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config
.supports_gl_compat_version
= 10;
45 config
.window_width
= 256;
46 config
.window_height
= 256;
47 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGB
;
48 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
50 PIGLIT_GL_TEST_CONFIG_END
52 const int pattern_width
= 256; const int pattern_height
= 256;
60 /* Blit multisample-to-multisample with non-matching sample count */
61 glBindFramebuffer(GL_READ_FRAMEBUFFER
, src_fbo
.handle
);
62 glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, dst_fbo
.handle
);
63 glBlitFramebuffer(0, 0, pattern_width
, pattern_height
,
64 0, 0, pattern_width
, pattern_height
,
65 GL_COLOR_BUFFER_BIT
, GL_NEAREST
);
67 /* Here GL_INVALID_OPERATION is an expected gl error */
68 pass
= piglit_check_gl_error(GL_INVALID_OPERATION
) && pass
;
70 return (pass
? PIGLIT_PASS
: PIGLIT_FAIL
);
74 piglit_init(int argc
, char **argv
)
76 GLint samples
, max_samples
;
78 piglit_require_gl_version(21);
79 piglit_require_extension("GL_ARB_framebuffer_object");
80 piglit_require_extension("GL_ARB_vertex_array_object");
82 /* OpenGL driver is supposed to round up the specified sample count to
83 * the next available sample count. So, this will create the FBO with
84 * minimum supported sample count.
86 src_fbo
.setup(FboConfig(1 /* sample count */,
90 glGetIntegerv(GL_MAX_SAMPLES
, &max_samples
);
92 glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, src_fbo
.handle
);
93 glGetIntegerv(GL_SAMPLES
, &samples
);
95 /* Skip the test if samples = GL_MAX_SAMPLES */
96 if (samples
== max_samples
) {
97 printf("OpenGL driver seems to support only one possible"
99 piglit_report_result(PIGLIT_SKIP
);
102 /* Creating FBO with (samples + 1) ensures that we get a different
103 * value of sample count in dst_fbo.
105 dst_fbo
.setup(FboConfig(samples
+ 1, pattern_width
, pattern_height
));
107 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
108 printf("Error setting up frame buffer objects\n");
109 piglit_report_result(PIGLIT_FAIL
);