framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / gl-3.0 / required-renderbuffer-attachment-formats.c
blob928980b3ba89be6e6c6fda7fb5429de1c0776813
1 /* Copyright © 2011 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 #include "piglit-util-gl.h"
24 #include "sized-internalformats.h"
26 /**
27 * @file required-renderbuffer-attachment-formats.c
29 * Tests that the color-and-texturing required sized internal formats
30 * for GL 3.0 are supported as renderbuffer attachments. See page 294
31 * of the GL 3.0 pdf (20080923) "Required Framebuffer Formats" and
32 * page 180 "Required Texture Formats".
35 static int target_version;
37 enum piglit_result
38 piglit_display(void)
40 /* UNREACHED */
41 return PIGLIT_FAIL;
44 void
45 piglit_init(int argc, char **argv)
47 bool pass = true;
48 GLuint rb, fbo;
49 int i;
51 piglit_require_gl_version(30);
53 glGenRenderbuffers(1, &rb);
54 glBindRenderbuffer(GL_RENDERBUFFER, rb);
56 for (i = 0; required_formats[i].token != GL_NONE; i++) {
57 GLenum attachment, status;
58 const struct sized_internalformat *f;
60 if (!valid_for_gl_version(&required_formats[i], target_version))
61 continue;
63 if (!required_formats[i].rb_required)
64 continue;
66 f = get_sized_internalformat(required_formats[i].token);
67 const char *name = piglit_get_gl_enum_name(f->token);
69 if (f->token == GL_DEPTH24_STENCIL8 ||
70 f->token == GL_DEPTH32F_STENCIL8) {
71 attachment = GL_DEPTH_STENCIL_ATTACHMENT;
72 } else if (get_channel_size(f, D)) {
73 attachment = GL_DEPTH_ATTACHMENT;
74 } else {
75 attachment = GL_COLOR_ATTACHMENT0;
78 glRenderbufferStorage(GL_RENDERBUFFER, f->token, 1, 1);
80 /* We don't test the sizes of the channels, because
81 * the spec allows the implementation to choose
82 * resolution pretty much however it feels (GL 2.x
83 * texturing-style). From page 284 of the GL 3.0
84 * spec:
86 * "A GL implementation may vary its allocation of
87 * internal component resolution based on any
88 * RenderbufferStorage parameter (except target),
89 * but the allocation and chosen internal format
90 * must not be a function of any other state and
91 * cannot be changed once they are established."
94 if (glGetError() != 0) {
95 printf("Unexpected error creating %s texture\n",
96 name);
97 pass = false;
98 continue;
101 glGenFramebuffers(1, &fbo);
102 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
104 glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment,
105 GL_RENDERBUFFER, rb);
107 if (glGetError() != 0) {
108 printf("Unexpected error binding %s texture\n",
109 name);
110 pass = false;
111 continue;
114 if (attachment == GL_COLOR_ATTACHMENT0) {
115 glDrawBuffer(GL_COLOR_ATTACHMENT0);
116 } else {
117 glDrawBuffer(GL_NONE);
120 status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
121 if (status != GL_FRAMEBUFFER_COMPLETE) {
122 fprintf(stderr, "%s fbo incomplete (status = 0x%04x)\n",
123 name, status);
124 pass = false;
125 } else {
126 printf("%s: fbo complete\n", name);
129 glDeleteFramebuffers(1, &fbo);
132 glDeleteRenderbuffers(1, &rb);
134 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
137 PIGLIT_GL_TEST_CONFIG_BEGIN
138 setup_required_size_test(argc, argv, &config);
139 target_version = MAX2(config.supports_gl_compat_version,
140 config.supports_gl_core_version);
141 config.khr_no_error_support = PIGLIT_NO_ERRORS;
142 PIGLIT_GL_TEST_CONFIG_END