2 * Copyright © 2010 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 fbo-incomplete-texture-01.c
26 * Verify that an FBO with an incomplete texture attached is complete
28 * This test uses a 2D texture that specifies a mipmap filter, but the mipmap
29 * stack is not complete. This should not affect the completeness of the FBO.
30 * This test originally wanted the FBO to be incomplete. However, this just
31 * verified incorrect behavior in another vendor's driver.
33 * \author Ian Romanick <ian.d.romanick@intel.com>
36 #include "piglit-util-gl.h"
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config
.supports_gl_compat_version
= 10;
42 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
43 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
45 PIGLIT_GL_TEST_CONFIG_END
54 piglit_init(int argc
, char **argv
)
59 const float color
[] = {1.0,0.0,0.0,1.0};
61 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
63 piglit_require_extension("GL_ARB_framebuffer_object");
65 /* This texture will be incomplete because a mipmap filter mode is used,
66 * but the mipmap stack is incomplete.
68 glGenTextures(1, &tex
);
69 glBindTexture(GL_TEXTURE_2D
, tex
);
70 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 32, 32, 0,
71 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
73 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
,
74 GL_LINEAR_MIPMAP_LINEAR
);
75 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
77 glGenFramebuffers(1, &fb
);
78 glBindFramebuffer(GL_FRAMEBUFFER
, fb
);
79 glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
80 GL_TEXTURE_2D
, tex
, 0);
82 if (!piglit_check_gl_error(GL_NO_ERROR
))
83 piglit_report_result(PIGLIT_FAIL
);
85 status
= glCheckFramebufferStatus(GL_FRAMEBUFFER
);
86 if (status
!= GL_FRAMEBUFFER_COMPLETE
) {
87 fprintf(stderr
, "FBO erroneously incomplete: 0x%04x\n",
89 piglit_report_result(PIGLIT_FAIL
);
92 glClearColor(color
[0], color
[1], color
[2], color
[3]);
93 glClear(GL_COLOR_BUFFER_BIT
);
95 if (!piglit_check_gl_error(GL_NO_ERROR
))
96 piglit_report_result(PIGLIT_FAIL
);
98 if (!piglit_probe_texel_rect_rgba(GL_TEXTURE_2D
, 0, 0, 0, 32, 32,
100 fprintf(stderr
, "FBO clear didn't work\n");
101 piglit_report_result(PIGLIT_FAIL
);
104 piglit_report_result(PIGLIT_PASS
);