2 * Copyright 2012 VMware, Inc.
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 * Test glTexImage with an image too large for the given mipmap level.
27 * Page 157 of the OpenGL 2.1 spec says:
29 * "In a similar fashion, the maximum allowable width of a one- or
30 * two- dimensional texture image, and the maximum allowable height of a
31 * two- dimensional texture image, must be at least 2k−lod + 2bt for
32 * image arrays of level 0 through k, where k is the log base 2 of MAX
33 * TEXTURE SIZE. The maximum allowable width and height of a cube map
34 * texture must be the same, and must be at least 2k−lod + 2bt for image
35 * arrays level 0 through k, where k is the log base 2 of MAX CUBE MAP
39 #include "piglit-util-gl.h"
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config
.supports_gl_compat_version
= 10;
45 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
46 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
48 PIGLIT_GL_TEST_CONFIG_END
58 piglit_init(int argc
, char **argv
)
64 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &maxSize
);
65 printf("GL_MAX_TEXTURE_SIZE = %d\n", maxSize
);
67 glGenTextures(1, &tex
);
68 glBindTexture(GL_TEXTURE_2D
, tex
);
71 * Note: we don't try to create any maxSize by maxSize textures
72 * since we may not have enough texture memory.
76 * For level 0, maxSize by 1 (and vice-versa) should be OK.
78 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
,
80 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
81 pass
= piglit_check_gl_error(GL_NO_ERROR
);
83 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
,
85 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
86 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
88 if (!piglit_khr_no_error
) {
90 * For level 1, maxSize by 1 (and vice versa) should fail.
92 glTexImage2D(GL_TEXTURE_2D
, 1, GL_RGBA
,
94 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
95 pass
= piglit_check_gl_error(GL_INVALID_VALUE
) & pass
;
97 glTexImage2D(GL_TEXTURE_2D
, 1, GL_RGBA
,
99 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
100 pass
= piglit_check_gl_error(GL_INVALID_VALUE
) & pass
;
103 * For level 2, maxSize/2 by 1 (and vice versa) should fail.
105 glTexImage2D(GL_TEXTURE_2D
, 2, GL_RGBA
,
107 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
108 pass
= piglit_check_gl_error(GL_INVALID_VALUE
) & pass
;
110 glTexImage2D(GL_TEXTURE_2D
, 2, GL_RGBA
,
112 GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
113 pass
= piglit_check_gl_error(GL_INVALID_VALUE
) & pass
;
116 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);