shader_runner: don't use deleted query objects
[piglit.git] / tests / texturing / max-texture-size-level.c
blob8f90c08336585ab2459488842a853edb133adf3b
1 /*
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
13 * Software.
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
21 * IN THE SOFTWARE.
24 /**
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
36 * TEXTURE SIZE."
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
49 enum piglit_result
50 piglit_display(void)
52 /* no op */
53 return PIGLIT_PASS;
57 void
58 piglit_init(int argc, char **argv)
60 GLint maxSize;
61 GLuint tex;
62 bool pass;
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,
79 maxSize, 1, 0,
80 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
81 pass = piglit_check_gl_error(GL_NO_ERROR);
83 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
84 1, maxSize, 0,
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,
93 maxSize, 1, 0,
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,
98 1, maxSize, 0,
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,
106 maxSize/2, 1, 0,
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,
111 1, maxSize/2, 0,
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);