1 /*
2 * Copyright © 2013 Intel Corporation
3 *
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:
10 *
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.
14 *
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
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 /** \file
25 *
26 * From section 4.4.4 (Framebuffer Completeness) of the GL 3.2 spec,
27 * under the "Whole Framebuffer Completeness" heading:
28 *
29 * If any framebuffer attachment is layered, all populated
30 * attachments must be layered. Additionally, all populated color
31 * attachments must be from textures of the same target.
32 *
33 * { FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS }
34 *
35 * This test verifies that if two layered framebuffer attachments use
36 * different texture targets, then the framebuffer is incomplete, even
37 * if the two attachments have the same number of layer. We test this
38 * by using a cube map texture and a 2D array texture containing 6
39 * layers.
40 */
41
42 #include "piglit-util-gl.h"
43
44 PIGLIT_GL_TEST_CONFIG_BEGIN
45
46 config.supports_gl_compat_version = 32;
47 config.supports_gl_core_version = 32;
48 config.khr_no_error_support = PIGLIT_NO_ERRORS;
49
50 PIGLIT_GL_TEST_CONFIG_END
51
52
53 #define TEX_SIZE 32
54
55
56 static const GLenum cube_map_faces[6] = {
57 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
58 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
59 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
60 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
61 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
62 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
63 };
64
65
66 void
piglit_init(int argc,char ** argv)67 piglit_init(int argc, char **argv)
68 {
69 GLuint textures[2];
70 GLuint fbo;
71 int i;
72 GLenum fbstatus;
73
74 glGenTextures(2, textures);
75 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[0]);
76 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
77 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
78 for (i = 0; i < 6; i++) {
79 glTexImage2D(cube_map_faces[i], 0 /* level */, GL_RGBA,
80 TEX_SIZE, TEX_SIZE, 0 /* border */, GL_RGBA,
81 GL_FLOAT, NULL);
82 }
83 glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
84 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
85 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
86 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0 /* level */, GL_RGBA, TEX_SIZE,
87 TEX_SIZE, 6, 0 /* border */, GL_RGBA, GL_FLOAT, NULL);
88 glGenFramebuffers(1, &fbo);
89 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
90 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textures[0],
91 0 /* level */);
92 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, textures[1],
93 0 /* level */);
94 fbstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
95 if (fbstatus != GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS) {
96 printf("Expected GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS, got "
97 "%s\n", piglit_get_gl_enum_name(fbstatus));
98 piglit_report_result(PIGLIT_FAIL);
99 }
100 piglit_report_result(PIGLIT_PASS);
101 }
102
103
104 enum piglit_result
piglit_display(void)105 piglit_display(void)
106 {
107 /* Should never be reached */
108 return PIGLIT_FAIL;
109 }
110