perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / tests / spec / ext_framebuffer_multisample_blit_scaled / negative-blit-scaled.cpp
blobe2b60fe5e7531b37a504534bdcfed90490fa3de4
1 /*
2 * Copyright © 2013 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 /** \file negative-blit-scaled.cpp
26 * This test verifies that expected GL errors are produced for cases mentioned
27 * in EXT_framebuffer_multisample_blit_scaled extension:
29 * "If the draw framebuffer is framebuffer complete and has a value of
30 * SAMPLE_BUFFERS that is greater than zero, or if the read framebuffer
31 * is framebuffer complete and has a value of SAMPLE_BUFFERS that is
32 * zero, then the error INVALID_OPERATION is generated if BlitFramebuffer
33 * is called and the filter is SCALED_RESOLVE_FASTEST_EXT or
34 * SCALED_RESOLVE_NICEST_EXT."
38 #include "piglit-fbo.h"
39 using namespace piglit_util_fbo;
41 const int pattern_width = 256; const int pattern_height = 256;
43 PIGLIT_GL_TEST_CONFIG_BEGIN
45 config.supports_gl_compat_version = 10;
47 config.window_width = pattern_width;
48 config.window_height = pattern_height;
49 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
51 PIGLIT_GL_TEST_CONFIG_END
53 static Fbo multisampled_fbo_1, multisampled_fbo_2, singlesampled_fbo;
55 void
56 piglit_init(int argc, char **argv)
58 bool pass = true;
59 GLint max_samples;
61 piglit_require_extension("GL_EXT_framebuffer_multisample_blit_scaled");
63 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
64 FboConfig Config(max_samples, pattern_width, pattern_height);
65 multisampled_fbo_1.setup(Config);
66 multisampled_fbo_2.setup(Config);
67 Config.num_samples = 0;
68 singlesampled_fbo.setup(Config);
70 if (!piglit_check_gl_error(GL_NO_ERROR)) {
71 piglit_report_result(PIGLIT_FAIL);
74 /* Do multi-sample to multi-sample scaled blit */
75 glBindFramebuffer(GL_READ_FRAMEBUFFER, multisampled_fbo_1.handle);
76 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisampled_fbo_2.handle);
78 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
79 0, 0, pattern_width, pattern_height,
80 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_FASTEST_EXT);
81 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
83 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
84 0, 0, pattern_width, pattern_height,
85 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_NICEST_EXT);
86 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
88 /* Do single-sample to single-sample scaled blit */
89 glBindFramebuffer(GL_READ_FRAMEBUFFER, singlesampled_fbo.handle);
90 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
92 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
93 0, 0, pattern_width, pattern_height,
94 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_FASTEST_EXT);
95 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
97 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
98 0, 0, pattern_width, pattern_height,
99 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_NICEST_EXT);
100 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
102 /* Do multi-sample to single-sample scaled blit */
103 glBindFramebuffer(GL_READ_FRAMEBUFFER, multisampled_fbo_1.handle);
104 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, singlesampled_fbo.handle);
106 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
107 0, 0, pattern_width, pattern_height,
108 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_FASTEST_EXT);
109 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
111 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
112 0, 0, pattern_width, pattern_height,
113 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_NICEST_EXT);
114 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
116 Config.color_internalformat = GL_RGBA8I;
117 multisampled_fbo_1.setup(Config);
118 singlesampled_fbo.setup(Config);
120 /* Do multi-sample integer buffer to single-sample scaled blit */
121 glBindFramebuffer(GL_READ_FRAMEBUFFER, multisampled_fbo_1.handle);
122 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, singlesampled_fbo.handle);
124 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
125 0, 0, pattern_width, pattern_height,
126 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_FASTEST_EXT);
127 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
129 glBlitFramebuffer(0, 0, pattern_width / 2, pattern_height / 2,
130 0, 0, pattern_width, pattern_height,
131 GL_COLOR_BUFFER_BIT, GL_SCALED_RESOLVE_NICEST_EXT);
132 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
134 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
137 enum piglit_result
138 piglit_display()
140 /* UNREACHED */
141 return PIGLIT_FAIL;