1 /* Copyright © 2013 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * on the rights to use, copy, modify, merge, publish, distribute, sub
7 * license, and/or sell copies of the Software, and to permit persons to whom
8 * the Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Tests the TEXTURE_IMMUTABLE_LEVELS parameter.
27 * The GL ES 3.0 spec says:
29 * "If the command is successful, TEXTURE_IMMUTABLE_FORMAT becomes
30 * TRUE and TEXTURE_IMMUTABLE_LEVELS becomes levels."
32 * where <command> is either glTexStorage2D or glTexStorage3D.
34 * Test by calling glTexStorage*D with <levels> = 3, <width>, <height>, and
35 * <depth> = 32; and then confirming that TEXTURE_IMMUTABLE_LEVELS was
36 * correctly set to <levels>.
39 #include "piglit-util-gl.h"
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config
.supports_gl_es_version
= 30;
45 PIGLIT_GL_TEST_CONFIG_END
53 /* The GL ES 3.0 spec says:
55 * "The [initial] value of TEXTURE_IMMUTABLE_LEVELS is 0."
57 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
58 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
59 piglit_report_result(PIGLIT_FAIL
);
62 printf("Expected 0 levels initially, but glGetTexParameteriv "
63 "returned %d for GL_TEXTURE_1D.\n", level
);
64 piglit_report_result(PIGLIT_FAIL
);
67 glGenTextures(4, tex
);
69 glBindTexture(GL_TEXTURE_2D
, tex
[0]);
70 glTexStorage2D(GL_TEXTURE_2D
, 3, GL_RGBA8
, 32, 32);
71 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
73 printf("Expected 3 levels, but glGetTexParameteriv returned "
74 "%d for GL_TEXTURE_2D.\n", level
);
75 piglit_report_result(PIGLIT_FAIL
);
78 glBindTexture(GL_TEXTURE_3D
, tex
[1]);
79 glTexStorage3D(GL_TEXTURE_3D
, 3, GL_RGBA8
, 32, 32, 32);
80 glGetTexParameteriv(GL_TEXTURE_3D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
82 printf("Expected 3 levels, but glGetTexParameterfv returned "
83 "%d for GL_TEXTURE_3D.\n", level
);
84 piglit_report_result(PIGLIT_FAIL
);
87 glBindTexture(GL_TEXTURE_2D
, tex
[2]);
88 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 32, 32, 0, GL_RGBA
, GL_FLOAT
, NULL
);
89 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
91 printf("Expected 0 levels, but glGetTexParameteriv returned "
92 "%d for GL_TEXTURE_2D.\n", level
);
93 piglit_report_result(PIGLIT_FAIL
);
96 glBindTexture(GL_TEXTURE_3D
, tex
[3]);
97 glTexImage2D(GL_TEXTURE_3D
, 0, GL_RGBA
, 32, 32, 32, GL_RGBA
, GL_FLOAT
, NULL
);
98 glGetTexParameteriv(GL_TEXTURE_3D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
100 printf("Expected 0 levels, but glGetTexParameteriv returned "
101 "%d for GL_TEXTURE_3D.\n", level
);
102 piglit_report_result(PIGLIT_FAIL
);
105 glDeleteTextures(4, tex
);
107 piglit_report_result(PIGLIT_PASS
);
112 piglit_init(int argc
, char *argv
[])