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
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 * Tapani Pälli <tapani.palli@intel.com>
27 /** @file fbo-discard.c
29 * Tests GL_EXT_discard_framebuffer implementation
31 * Test iterates over valid and invalid arguments and checks
32 * that the implementation returns correct error codes.
34 * GL_EXT_discard_framebuffer specification "Errors" section states:
36 * "The error INVALID_ENUM is generated if DiscardFramebufferEXT is called
37 * with a <target> that is not FRAMEBUFFER.
39 * The error INVALID_ENUM is generated if DiscardFramebufferEXT is called with
40 * a token other than COLOR_ATTACHMENT0, DEPTH_ATTACHMENT, or
41 * STENCIL_ATTACHMENT in its <attachments> list when a framebuffer object is
44 * The error INVALID_ENUM is generated if DiscardFramebufferEXT is called with
45 * a token other than COLOR_EXT, DEPTH_EXT, or STENCIL_EXT in its
46 * <attachments> list when the default framebuffer is bound to <target>.
48 * The error INVALID_VALUE is generated if DiscardFramebufferEXT is called
49 * with <numAttachments> less than zero."
52 #include "piglit-util-gl.h"
54 PIGLIT_GL_TEST_CONFIG_BEGIN
56 config
.supports_gl_es_version
= 20;
58 PIGLIT_GL_TEST_CONFIG_END
67 /* valid enums for user created fb */
68 GLenum usr_attach
[] = {
71 GL_STENCIL_ATTACHMENT
,
75 /* valid enums for default fb */
76 GLenum def_attach
[] = {
83 /* bonus invalid enum */
84 const GLenum invalid
[] = { GL_COMPILE_STATUS
};
86 glGenFramebuffers(1, &fbo
);
88 /* test with invalid target */
89 glDiscardFramebufferEXT(GL_RENDERBUFFER
, 1, usr_attach
);
90 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
92 /* test with attachments < 0 */
93 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, -1, usr_attach
);
94 pass
&= piglit_check_gl_error(GL_INVALID_VALUE
);
96 /* test with default fb */
97 glBindFramebuffer(GL_FRAMEBUFFER
, 0);
99 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 3, def_attach
);
100 for (p
= def_attach
; *p
!= 0; p
++) {
101 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 1, p
);
102 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
105 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 1, invalid
);
106 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
108 for (p
= usr_attach
; *p
!= 0; p
++) {
109 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 1, p
);
110 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
113 /* test user created fb */
114 glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
116 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 3, usr_attach
);
117 for (p
= usr_attach
; *p
!= 0; p
++) {
118 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 1, p
);
119 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
122 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 1, invalid
);
123 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
125 for (p
= def_attach
; *p
!= 0; p
++) {
126 glDiscardFramebufferEXT(GL_FRAMEBUFFER
, 1, p
);
127 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
137 GLboolean pass
= run_test();
139 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
143 piglit_init(int argc
, char **argv
)
145 piglit_require_extension("GL_EXT_discard_framebuffer");