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 and TEXTURE_VIEW_NUM_LEVELS parameters.
27 * The ARB_texture_view spec says:
29 * "If the command is successful, TEXTURE_IMMUTABLE_FORMAT becomes TRUE,
30 * TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become <levels>."
32 * where <command> is glTexStorage?D.
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_compat_version
= 12;
44 config
.supports_gl_es_version
= 31;
45 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
47 PIGLIT_GL_TEST_CONFIG_END
56 /* The GL ES 3.0 spec says:
58 * "The [initial] value of TEXTURE_IMMUTABLE_LEVELS is 0."
60 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
61 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
62 piglit_report_result(PIGLIT_FAIL
);
65 printf("Expected 0 levels initially, but glGetTexParameteriv "
66 "returned %d for GL_TEXTURE_1D.\n", level
);
67 piglit_report_result(PIGLIT_FAIL
);
70 glGenTextures(ARRAY_SIZE(tex
), tex
);
72 #ifdef PIGLIT_USE_OPENGL
73 glBindTexture(GL_TEXTURE_1D
, tex
[0]);
74 glTexStorage1D(GL_TEXTURE_1D
, 3, GL_RGBA8
, 32);
75 glGetTexParameteriv(GL_TEXTURE_1D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
76 glGetTexParameteriv(GL_TEXTURE_1D
, GL_TEXTURE_VIEW_NUM_LEVELS
, &num_level
);
78 printf("Expected 3 levels, but glGetTexParameteriv returned "
79 "%d for GL_TEXTURE_1D.\n", level
);
80 piglit_report_result(PIGLIT_FAIL
);
81 } else if (level
!= num_level
) {
82 printf("Expected queries of TEXTURE_IMMUTABLE_LEVELS and "
83 "TEXTURE_VIEW_NUM_LEVELS to return identical results.");
84 piglit_report_result(PIGLIT_FAIL
);
88 glBindTexture(GL_TEXTURE_2D
, tex
[1]);
89 glTexStorage2D(GL_TEXTURE_2D
, 3, GL_RGBA8
, 32, 32);
90 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
91 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_VIEW_NUM_LEVELS
, &num_level
);
93 printf("Expected 3 levels, but glGetTexParameteriv returned "
94 "%d for GL_TEXTURE_2D.\n", level
);
95 piglit_report_result(PIGLIT_FAIL
);
96 } else if (level
!= num_level
) {
97 printf("Expected queries of TEXTURE_IMMUTABLE_LEVELS and "
98 "TEXTURE_VIEW_NUM_LEVELS to return identical results.");
99 piglit_report_result(PIGLIT_FAIL
);
102 glBindTexture(GL_TEXTURE_3D
, tex
[2]);
103 glTexStorage3D(GL_TEXTURE_3D
, 3, GL_RGBA8
, 32, 32, 32);
104 glGetTexParameteriv(GL_TEXTURE_3D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
105 glGetTexParameteriv(GL_TEXTURE_3D
, GL_TEXTURE_VIEW_NUM_LEVELS
, &num_level
);
107 printf("Expected 3 levels, but glGetTexParameterfv returned "
108 "%d for GL_TEXTURE_3D.\n", level
);
109 piglit_report_result(PIGLIT_FAIL
);
110 } else if (level
!= num_level
) {
111 printf("Expected queries of TEXTURE_IMMUTABLE_LEVELS and "
112 "TEXTURE_VIEW_NUM_LEVELS to return identical results.");
113 piglit_report_result(PIGLIT_FAIL
);
116 glBindTexture(GL_TEXTURE_2D
, tex
[3]);
117 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 32, 32, 0, GL_RGBA
, GL_FLOAT
, NULL
);
118 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
120 printf("Expected 0 levels, but glGetTexParameteriv returned "
121 "%d for GL_TEXTURE_2D.\n", level
);
122 piglit_report_result(PIGLIT_FAIL
);
125 glBindTexture(GL_TEXTURE_3D
, tex
[4]);
126 glTexImage2D(GL_TEXTURE_3D
, 0, GL_RGBA
, 32, 32, 32, GL_RGBA
, GL_FLOAT
, NULL
);
127 glGetTexParameteriv(GL_TEXTURE_3D
, GL_TEXTURE_IMMUTABLE_LEVELS
, &level
);
129 printf("Expected 0 levels, but glGetTexParameteriv returned "
130 "%d for GL_TEXTURE_3D.\n", level
);
131 piglit_report_result(PIGLIT_FAIL
);
134 glDeleteTextures(5, tex
);
136 piglit_report_result(PIGLIT_PASS
);
141 piglit_init(int argc
, char *argv
[])
143 #ifdef PIGLIT_USE_OPENGL
144 piglit_require_extension("GL_ARB_texture_view");
146 piglit_require_extension("GL_OES_texture_view");