ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_framebuffer_multisample / renderbuffer-samples.c
blob323c727d5599260cd91ae8f228f0b7396a5e6c42
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 renderbuffer-samples.c
29 * Tests that asking for samples gives the correct number of
30 * GL_RENDERBUFFER_SAMPLES.
32 * From the EXT_framebuffer_multisample spec:
34 * "If <samples> is zero, then RENDERBUFFER_SAMPLES_EXT is set to
35 * zero. Otherwise <samples> represents a request for a desired
36 * minimum number of samples. Since different implementations may
37 * support different sample counts for multisampled rendering,
38 * the actual number of samples allocated for the renderbuffer
39 * image is implementation dependent. However, the resulting
40 * value for RENDERBUFFER_SAMPLES_EXT is guaranteed to be greater
41 * than or equal to <samples> and no more than the next larger
42 * sample count supported by the implementation.
44 * Note also this issue:
46 * " (2) What happens when <samples> is zero or one?
48 * RESOLVED, 0 = single sample, 1 = minimum multisample
50 * Resolved by consensus, May 9, 2005
52 * Zero means single sample, as if RenderbufferStorageEXT
53 * had been called instead of
54 * RenderbufferStorageMultisampleEXT. One means minimum
55 * number of samples supported by implementation.
57 * There was a question if one should mean the same thing as
58 * single-sample (one sample), or if it should mean the
59 * minimum supported number of samples for multisample
60 * rendering. The rules for rasterizing in "multisample"
61 * mode are different than "non-multisample" mode. In the
62 * end, we decided that some implementations may wish to
63 * support a "one-sample" multisample buffer to allow for
64 * multipass multisampling where the sample location can be
65 * varied either by the implementation or perhaps explicitly
66 * by a "multisample location" extension."
69 PIGLIT_GL_TEST_CONFIG_BEGIN
71 config.supports_gl_compat_version = 10;
73 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
74 config.khr_no_error_support = PIGLIT_NO_ERRORS;
76 PIGLIT_GL_TEST_CONFIG_END
78 enum piglit_result
79 piglit_display(void)
81 /* UNREACHED */
82 return PIGLIT_FAIL;
85 void
86 piglit_init(int argc, char **argv)
88 GLint max_samples, samples, prev_rb_samples = 0;
89 GLuint rb;
90 bool pass = true;
92 piglit_require_extension("GL_EXT_framebuffer_multisample");
94 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
96 glGenRenderbuffersEXT(1, &rb);
97 glBindRenderbufferEXT(GL_RENDERBUFFER, rb);
98 printf("%10s %10s\n", "requested", "result");
99 for (samples = 0; samples <= max_samples; samples++) {
100 GLint rb_samples;
102 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
103 samples,
104 GL_RGBA,
105 1, 1);
107 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER,
108 GL_RENDERBUFFER_SAMPLES,
109 &rb_samples);
111 if ((rb_samples < prev_rb_samples) ||
112 (samples == 0 && rb_samples != 0) ||
113 (samples > 0 && rb_samples < samples)) {
114 fprintf(stderr, "%10d %10d (ERROR)\n", samples, rb_samples);
115 pass = false;
116 } else {
117 printf("%10d %10d\n", samples, rb_samples);
120 prev_rb_samples = rb_samples;
122 glDeleteRenderbuffersEXT(1, &rb);
124 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);