1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Negative Texture API tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es3fNegativeTextureApiTests.hpp"
25 #include "es3fApiCase.hpp"
26 #include "gluContextInfo.hpp"
27 #include "tcuFormatUtil.hpp"
28 #include "gluTextureUtil.hpp"
29
30 #include <vector>
31 #include <algorithm>
32
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
35
36 using namespace glw; // GL types
37
38 namespace deqp
39 {
40 namespace gles3
41 {
42 namespace Functional
43 {
44
45 using glu::mapGLCompressedTexFormat;
46 using std::vector;
47 using tcu::CompressedTexFormat;
48 using tcu::getBlockPixelSize;
49 using tcu::getBlockSize;
50 using tcu::IVec3;
51 using tcu::TestLog;
52
divRoundUp(int a,int b)53 static inline int divRoundUp(int a, int b)
54 {
55 return a / b + (a % b != 0 ? 1 : 0);
56 }
57
etc2DataSize(int width,int height)58 static inline int etc2DataSize(int width, int height)
59 {
60 return (int)(divRoundUp(width, 4) * divRoundUp(height, 4) * sizeof(uint64_t));
61 }
62
etc2EacDataSize(int width,int height)63 static inline int etc2EacDataSize(int width, int height)
64 {
65 return 2 * etc2DataSize(width, height);
66 }
67
68 static const GLuint s_astcFormats[] = {
69 GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
70 GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
71 GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
72 GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
73 GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
74 GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
75 GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
76 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
77 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
78 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
79 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
80 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
81 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
82 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR};
83
cubeFaceToGLFace(tcu::CubeFace face)84 static uint32_t cubeFaceToGLFace(tcu::CubeFace face)
85 {
86 switch (face)
87 {
88 case tcu::CUBEFACE_NEGATIVE_X:
89 return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
90 case tcu::CUBEFACE_POSITIVE_X:
91 return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
92 case tcu::CUBEFACE_NEGATIVE_Y:
93 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
94 case tcu::CUBEFACE_POSITIVE_Y:
95 return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
96 case tcu::CUBEFACE_NEGATIVE_Z:
97 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
98 case tcu::CUBEFACE_POSITIVE_Z:
99 return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
100 default:
101 DE_ASSERT(false);
102 return GL_NONE;
103 }
104 }
105
106 #define FOR_CUBE_FACES(FACE_GL_VAR, BODY) \
107 do \
108 { \
109 for (int faceIterTcu = 0; faceIterTcu < tcu::CUBEFACE_LAST; faceIterTcu++) \
110 { \
111 const GLenum FACE_GL_VAR = cubeFaceToGLFace((tcu::CubeFace)faceIterTcu); \
112 BODY \
113 } \
114 } while (false)
115
NegativeTextureApiTests(Context & context)116 NegativeTextureApiTests::NegativeTextureApiTests(Context &context)
117 : TestCaseGroup(context, "texture", "Negative Texture API Cases")
118 {
119 }
120
~NegativeTextureApiTests(void)121 NegativeTextureApiTests::~NegativeTextureApiTests(void)
122 {
123 }
124
init(void)125 void NegativeTextureApiTests::init(void)
126 {
127 // glActiveTexture
128
129 ES3F_ADD_API_CASE(activetexture, "Invalid glActiveTexture() usage", {
130 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if texture is not one of GL_TEXTUREi, where i "
131 "ranges from 0 to (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1).");
132 glActiveTexture(-1);
133 expectError(GL_INVALID_ENUM);
134 int numMaxTextureUnits = m_context.getContextInfo().getInt(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
135 glActiveTexture(GL_TEXTURE0 + numMaxTextureUnits);
136 expectError(GL_INVALID_ENUM);
137 m_log << TestLog::EndSection;
138 });
139
140 // glBindTexture
141
142 ES3F_ADD_API_CASE(bindtexture, "Invalid glBindTexture() usage", {
143 GLuint texture[2];
144 glGenTextures(2, texture);
145
146 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the allowable values.");
147 glBindTexture(0, 1);
148 expectError(GL_INVALID_ENUM);
149 glBindTexture(GL_FRAMEBUFFER, 1);
150 expectError(GL_INVALID_ENUM);
151 m_log << TestLog::EndSection;
152
153 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture was previously created with a "
154 "target that doesn't match that of target.");
155 glBindTexture(GL_TEXTURE_2D, texture[0]);
156 expectError(GL_NO_ERROR);
157 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
158 expectError(GL_INVALID_OPERATION);
159 glBindTexture(GL_TEXTURE_3D, texture[0]);
160 expectError(GL_INVALID_OPERATION);
161 glBindTexture(GL_TEXTURE_2D_ARRAY, texture[0]);
162 expectError(GL_INVALID_OPERATION);
163
164 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[1]);
165 expectError(GL_NO_ERROR);
166 glBindTexture(GL_TEXTURE_2D, texture[1]);
167 expectError(GL_INVALID_OPERATION);
168 glBindTexture(GL_TEXTURE_3D, texture[1]);
169 expectError(GL_INVALID_OPERATION);
170 glBindTexture(GL_TEXTURE_2D_ARRAY, texture[1]);
171 expectError(GL_INVALID_OPERATION);
172 m_log << TestLog::EndSection;
173
174 glDeleteTextures(2, texture);
175 });
176
177 // glCompressedTexImage2D
178
179 ES3F_ADD_API_CASE(compressedteximage2d_invalid_target, "Invalid glCompressedTexImage2D() usage", {
180 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
181 glCompressedTexImage2D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
182 expectError(GL_INVALID_ENUM);
183 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
184 expectError(GL_INVALID_ENUM);
185 m_log << TestLog::EndSection;
186 });
187 ES3F_ADD_API_CASE(compressedteximage2d_invalid_format, "Invalid glCompressedTexImage2D() usage", {
188 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not a supported format "
189 "returned in GL_COMPRESSED_TEXTURE_FORMATS.");
190 glCompressedTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
191 expectError(GL_INVALID_ENUM);
192 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, 0, 0);
193 expectError(GL_INVALID_ENUM);
194 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, 0, 0);
195 expectError(GL_INVALID_ENUM);
196 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
197 expectError(GL_INVALID_ENUM);
198 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
199 expectError(GL_INVALID_ENUM);
200 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
201 expectError(GL_INVALID_ENUM);
202 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
203 expectError(GL_INVALID_ENUM);
204 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
205 expectError(GL_INVALID_ENUM);
206 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
207 expectError(GL_INVALID_ENUM);
208 m_log << TestLog::EndSection;
209 });
210 ES3F_ADD_API_CASE(compressedteximage2d_neg_level, "Invalid glCompressedTexImage2D() usage", {
211 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
212 glCompressedTexImage2D(GL_TEXTURE_2D, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
213 expectError(GL_INVALID_VALUE);
214 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
215 expectError(GL_INVALID_VALUE);
216 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
217 expectError(GL_INVALID_VALUE);
218 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
219 expectError(GL_INVALID_VALUE);
220 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
221 expectError(GL_INVALID_VALUE);
222 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
223 expectError(GL_INVALID_VALUE);
224 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
225 expectError(GL_INVALID_VALUE);
226 m_log << TestLog::EndSection;
227 });
228 ES3F_ADD_API_CASE(compressedteximage2d_max_level, "Invalid glCompressedTexImage2D() usage", {
229 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than "
230 "log_2(GL_MAX_TEXTURE_SIZE) for a 2d texture target.");
231 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
232 glCompressedTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0,
233 etc2DataSize(16, 16), 0);
234 expectError(GL_INVALID_VALUE);
235 m_log << TestLog::EndSection;
236
237 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than "
238 "log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE) for a cubemap target.");
239 uint32_t log2MaxCubemapSize =
240 deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
241 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16,
242 0, etc2EacDataSize(16, 16), 0);
243 expectError(GL_INVALID_VALUE);
244 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16,
245 0, etc2EacDataSize(16, 16), 0);
246 expectError(GL_INVALID_VALUE);
247 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16,
248 0, etc2EacDataSize(16, 16), 0);
249 expectError(GL_INVALID_VALUE);
250 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16,
251 0, etc2EacDataSize(16, 16), 0);
252 expectError(GL_INVALID_VALUE);
253 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16,
254 0, etc2EacDataSize(16, 16), 0);
255 expectError(GL_INVALID_VALUE);
256 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16,
257 0, etc2EacDataSize(16, 16), 0);
258 expectError(GL_INVALID_VALUE);
259 m_log << TestLog::EndSection;
260 });
261 ES3F_ADD_API_CASE(compressedteximage2d_neg_width_height, "Invalid glCompressedTexImage2D() usage", {
262 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
263
264 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
265 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
266 expectError(GL_INVALID_VALUE);
267 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
268 expectError(GL_INVALID_VALUE);
269 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
270 expectError(GL_INVALID_VALUE);
271 m_log << TestLog::EndSection;
272
273 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
274 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
275 expectError(GL_INVALID_VALUE);
276 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
277 expectError(GL_INVALID_VALUE);
278 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
279 expectError(GL_INVALID_VALUE);
280 m_log << TestLog::EndSection;
281
282 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
283 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
284 expectError(GL_INVALID_VALUE);
285 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
286 expectError(GL_INVALID_VALUE);
287 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
288 expectError(GL_INVALID_VALUE);
289 m_log << TestLog::EndSection;
290
291 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
292 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
293 expectError(GL_INVALID_VALUE);
294 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
295 expectError(GL_INVALID_VALUE);
296 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
297 expectError(GL_INVALID_VALUE);
298 m_log << TestLog::EndSection;
299
300 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
301 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
302 expectError(GL_INVALID_VALUE);
303 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
304 expectError(GL_INVALID_VALUE);
305 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
306 expectError(GL_INVALID_VALUE);
307 m_log << TestLog::EndSection;
308
309 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
310 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
311 expectError(GL_INVALID_VALUE);
312 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
313 expectError(GL_INVALID_VALUE);
314 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
315 expectError(GL_INVALID_VALUE);
316 m_log << TestLog::EndSection;
317
318 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
319 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
320 expectError(GL_INVALID_VALUE);
321 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
322 expectError(GL_INVALID_VALUE);
323 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
324 expectError(GL_INVALID_VALUE);
325 m_log << TestLog::EndSection;
326
327 m_log << TestLog::EndSection;
328 });
329 ES3F_ADD_API_CASE(compressedteximage2d_max_width_height, "Invalid glCompressedTexImage2D() usage", {
330 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
331 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
332 m_log << TestLog::Section(
333 "", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
334
335 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
336 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 1, 0,
337 etc2EacDataSize(maxTextureSize, 1), 0);
338 expectError(GL_INVALID_VALUE);
339 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxTextureSize, 0,
340 etc2EacDataSize(1, maxTextureSize), 0);
341 expectError(GL_INVALID_VALUE);
342 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, 0,
343 etc2EacDataSize(maxTextureSize, maxTextureSize), 0);
344 expectError(GL_INVALID_VALUE);
345 m_log << TestLog::EndSection;
346
347 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
348 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0,
349 etc2EacDataSize(maxCubemapSize, 1), 0);
350 expectError(GL_INVALID_VALUE);
351 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0,
352 etc2EacDataSize(1, maxCubemapSize), 0);
353 expectError(GL_INVALID_VALUE);
354 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize,
355 maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
356 expectError(GL_INVALID_VALUE);
357 m_log << TestLog::EndSection;
358
359 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
360 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0,
361 etc2EacDataSize(maxCubemapSize, 1), 0);
362 expectError(GL_INVALID_VALUE);
363 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0,
364 etc2EacDataSize(1, maxCubemapSize), 0);
365 expectError(GL_INVALID_VALUE);
366 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize,
367 maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
368 expectError(GL_INVALID_VALUE);
369 m_log << TestLog::EndSection;
370
371 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
372 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0,
373 etc2EacDataSize(maxCubemapSize, 1), 0);
374 expectError(GL_INVALID_VALUE);
375 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0,
376 etc2EacDataSize(1, maxCubemapSize), 0);
377 expectError(GL_INVALID_VALUE);
378 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize,
379 maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
380 expectError(GL_INVALID_VALUE);
381 m_log << TestLog::EndSection;
382
383 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
384 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0,
385 etc2EacDataSize(maxCubemapSize, 1), 0);
386 expectError(GL_INVALID_VALUE);
387 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0,
388 etc2EacDataSize(1, maxCubemapSize), 0);
389 expectError(GL_INVALID_VALUE);
390 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize,
391 maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
392 expectError(GL_INVALID_VALUE);
393 m_log << TestLog::EndSection;
394
395 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
396 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0,
397 etc2EacDataSize(maxCubemapSize, 1), 0);
398 expectError(GL_INVALID_VALUE);
399 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0,
400 etc2EacDataSize(1, maxCubemapSize), 0);
401 expectError(GL_INVALID_VALUE);
402 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize,
403 maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
404 expectError(GL_INVALID_VALUE);
405 m_log << TestLog::EndSection;
406
407 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
408 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0,
409 etc2EacDataSize(maxCubemapSize, 1), 0);
410 expectError(GL_INVALID_VALUE);
411 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0,
412 etc2EacDataSize(1, maxCubemapSize), 0);
413 expectError(GL_INVALID_VALUE);
414 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize,
415 maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
416 expectError(GL_INVALID_VALUE);
417 m_log << TestLog::EndSection;
418
419 m_log << TestLog::EndSection;
420 });
421 ES3F_ADD_API_CASE(compressedteximage2d_invalid_border, "Invalid glCompressedTexImage2D() usage", {
422 bool isES = glu::isContextTypeES(m_context.getRenderContext().getType());
423 GLenum error = isES ? GL_INVALID_VALUE : GL_INVALID_OPERATION;
424
425 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
426
427 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
428 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
429 expectError(error);
430 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
431 expectError(error);
432 m_log << TestLog::EndSection;
433
434 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
435 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
436 expectError(error);
437 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
438 expectError(error);
439 m_log << TestLog::EndSection;
440
441 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
442 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
443 expectError(error);
444 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
445 expectError(error);
446 m_log << TestLog::EndSection;
447
448 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
449 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
450 expectError(error);
451 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
452 expectError(error);
453 m_log << TestLog::EndSection;
454
455 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
456 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
457 expectError(error);
458 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
459 expectError(error);
460 m_log << TestLog::EndSection;
461
462 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
463 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
464 expectError(error);
465 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
466 expectError(error);
467 m_log << TestLog::EndSection;
468
469 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
470 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
471 expectError(error);
472 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
473 expectError(error);
474 m_log << TestLog::EndSection;
475
476 m_log << TestLog::EndSection;
477 });
478 ES3F_ADD_API_CASE(compressedteximage2d_invalid_size, "Invalid glCompressedTexImage2D() usage", {
479 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, "
480 "dimensions, and contents of the specified compressed image data.");
481 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0);
482 expectError(GL_INVALID_VALUE);
483 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, 4 * 4 * 8, 0);
484 expectError(GL_INVALID_VALUE);
485 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, 4 * 4 * 16, 0);
486 expectError(GL_INVALID_VALUE);
487 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 0, 4 * 4 * 16, 0);
488 expectError(GL_INVALID_VALUE);
489 m_log << TestLog::EndSection;
490 });
491 ES3F_ADD_API_CASE(compressedteximage2d_invalid_buffer_target, "Invalid glCompressedTexImage2D() usage", {
492 uint32_t buf;
493 std::vector<GLubyte> data(64);
494
495 glGenBuffers(1, &buf);
496 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
497 glBufferData(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
498 expectError(GL_NO_ERROR);
499
500 m_log << TestLog::Section(
501 "", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the "
502 "GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped.");
503 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
504 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 0, etc2DataSize(4, 4), 0);
505 expectError(GL_INVALID_OPERATION);
506 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
507 m_log << TestLog::EndSection;
508
509 m_log << TestLog::Section("",
510 "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the "
511 "GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the buffer object "
512 "such that the memory reads required would exceed the data store size.");
513 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
514 expectError(GL_INVALID_OPERATION);
515 m_log << TestLog::EndSection;
516
517 glDeleteBuffers(1, &buf);
518 });
519 ES3F_ADD_API_CASE(
520 compressedteximage2d_invalid_astc_target, "ASTC formats should not be supported without a proper extension.", {
521 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
522 {
523 m_log.writeMessage("ASTC supported. No negative API requirements.");
524 }
525 else
526 {
527 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
528
529 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
530 {
531 const GLuint format = s_astcFormats[formatNdx];
532 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
533 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
534 {
535 const size_t blockBytes = getBlockSize(tcuFormat);
536 const vector<uint8_t> unusedData(blockBytes);
537
538 glCompressedTexImage2D(GL_TEXTURE_2D, 0, format, blockPixels.x(), blockPixels.y(), 0,
539 (int)blockBytes, &unusedData[0]);
540 expectError(GL_INVALID_ENUM);
541 }
542 FOR_CUBE_FACES(faceGL, {
543 const int32_t cubeSize =
544 blockPixels.x() * blockPixels.y(); // Divisible by the block size and square
545 const size_t blockBytes = getBlockSize(tcuFormat) * cubeSize; // We have a x * y grid of blocks
546 const vector<uint8_t> unusedData(blockBytes);
547
548 glCompressedTexImage2D(faceGL, 0, format, cubeSize, cubeSize, 0, (int)blockBytes,
549 &unusedData[0]);
550 expectError(GL_INVALID_ENUM);
551 });
552 }
553 }
554 });
555
556 // glCopyTexImage2D
557
558 ES3F_ADD_API_CASE(copyteximage2d_invalid_target, "Invalid glCopyTexImage2D() usage", {
559 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
560 glCopyTexImage2D(0, 0, GL_RGB, 0, 0, 64, 64, 0);
561 expectError(GL_INVALID_ENUM);
562 m_log << TestLog::EndSection;
563 });
564 ES3F_ADD_API_CASE(copyteximage2d_invalid_format, "Invalid glCopyTexImage2D() usage", {
565 m_log << TestLog::Section(
566 "", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
567 glCopyTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0);
568 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
569 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0);
570 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
571 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0);
572 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
573 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0);
574 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
575 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0);
576 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
577 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0);
578 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
579 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0);
580 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
581 m_log << TestLog::EndSection;
582 });
583 ES3F_ADD_API_CASE(copyteximage2d_inequal_width_height_cube, "Invalid glCopyTexImage2D() usage", {
584 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is one of the six cube map 2D image "
585 "targets and the width and height parameters are not equal.");
586 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
587 expectError(GL_INVALID_VALUE);
588 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
589 expectError(GL_INVALID_VALUE);
590 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
591 expectError(GL_INVALID_VALUE);
592 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
593 expectError(GL_INVALID_VALUE);
594 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
595 expectError(GL_INVALID_VALUE);
596 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
597 expectError(GL_INVALID_VALUE);
598 m_log << TestLog::EndSection;
599 });
600 ES3F_ADD_API_CASE(copyteximage2d_neg_level, "Invalid glCopyTexImage2D() usage", {
601 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
602 glCopyTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 0, 0, 64, 64, 0);
603 expectError(GL_INVALID_VALUE);
604 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
605 expectError(GL_INVALID_VALUE);
606 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
607 expectError(GL_INVALID_VALUE);
608 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
609 expectError(GL_INVALID_VALUE);
610 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
611 expectError(GL_INVALID_VALUE);
612 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
613 expectError(GL_INVALID_VALUE);
614 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
615 expectError(GL_INVALID_VALUE);
616 m_log << TestLog::EndSection;
617 });
618 ES3F_ADD_API_CASE(copyteximage2d_max_level, "Invalid glCopyTexImage2D() usage", {
619 m_log << TestLog::Section("",
620 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
621 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
622 glCopyTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 0, 0, 64, 64, 0);
623 expectError(GL_INVALID_VALUE);
624 m_log << TestLog::EndSection;
625
626 m_log << TestLog::Section(
627 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
628 uint32_t log2MaxCubemapSize =
629 deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
630 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
631 expectError(GL_INVALID_VALUE);
632 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
633 expectError(GL_INVALID_VALUE);
634 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
635 expectError(GL_INVALID_VALUE);
636 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
637 expectError(GL_INVALID_VALUE);
638 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
639 expectError(GL_INVALID_VALUE);
640 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
641 expectError(GL_INVALID_VALUE);
642 m_log << TestLog::EndSection;
643 });
644 ES3F_ADD_API_CASE(copyteximage2d_neg_width_height, "Invalid glCopyTexImage2D() usage", {
645 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
646
647 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
648 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, 1, 0);
649 expectError(GL_INVALID_VALUE);
650 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, -1, 0);
651 expectError(GL_INVALID_VALUE);
652 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, -1, 0);
653 expectError(GL_INVALID_VALUE);
654 m_log << TestLog::EndSection;
655
656 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
657 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
658 expectError(GL_INVALID_VALUE);
659 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
660 expectError(GL_INVALID_VALUE);
661 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
662 expectError(GL_INVALID_VALUE);
663 m_log << TestLog::EndSection;
664
665 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
666 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
667 expectError(GL_INVALID_VALUE);
668 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
669 expectError(GL_INVALID_VALUE);
670 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
671 expectError(GL_INVALID_VALUE);
672 m_log << TestLog::EndSection;
673
674 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
675 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
676 expectError(GL_INVALID_VALUE);
677 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
678 expectError(GL_INVALID_VALUE);
679 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
680 expectError(GL_INVALID_VALUE);
681 m_log << TestLog::EndSection;
682
683 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
684 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
685 expectError(GL_INVALID_VALUE);
686 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
687 expectError(GL_INVALID_VALUE);
688 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
689 expectError(GL_INVALID_VALUE);
690 m_log << TestLog::EndSection;
691
692 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
693 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
694 expectError(GL_INVALID_VALUE);
695 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
696 expectError(GL_INVALID_VALUE);
697 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
698 expectError(GL_INVALID_VALUE);
699 m_log << TestLog::EndSection;
700
701 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
702 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
703 expectError(GL_INVALID_VALUE);
704 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
705 expectError(GL_INVALID_VALUE);
706 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
707 expectError(GL_INVALID_VALUE);
708 m_log << TestLog::EndSection;
709
710 m_log << TestLog::EndSection;
711 });
712 ES3F_ADD_API_CASE(copyteximage2d_max_width_height, "Invalid glCopyTexImage2D() usage", {
713 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
714 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
715
716 m_log << TestLog::Section(
717 "", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
718
719 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
720 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
721 expectError(GL_INVALID_VALUE);
722 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
723 expectError(GL_INVALID_VALUE);
724 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
725 expectError(GL_INVALID_VALUE);
726 m_log << TestLog::EndSection;
727
728 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
729 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
730 expectError(GL_INVALID_VALUE);
731 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
732 expectError(GL_INVALID_VALUE);
733 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
734 expectError(GL_INVALID_VALUE);
735 m_log << TestLog::EndSection;
736
737 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
738 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
739 expectError(GL_INVALID_VALUE);
740 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
741 expectError(GL_INVALID_VALUE);
742 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
743 expectError(GL_INVALID_VALUE);
744 m_log << TestLog::EndSection;
745
746 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
747 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
748 expectError(GL_INVALID_VALUE);
749 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
750 expectError(GL_INVALID_VALUE);
751 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
752 expectError(GL_INVALID_VALUE);
753 m_log << TestLog::EndSection;
754
755 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
756 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
757 expectError(GL_INVALID_VALUE);
758 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
759 expectError(GL_INVALID_VALUE);
760 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
761 expectError(GL_INVALID_VALUE);
762 m_log << TestLog::EndSection;
763
764 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
765 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
766 expectError(GL_INVALID_VALUE);
767 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
768 expectError(GL_INVALID_VALUE);
769 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
770 expectError(GL_INVALID_VALUE);
771 m_log << TestLog::EndSection;
772
773 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
774 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
775 expectError(GL_INVALID_VALUE);
776 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
777 expectError(GL_INVALID_VALUE);
778 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
779 expectError(GL_INVALID_VALUE);
780 m_log << TestLog::EndSection;
781
782 m_log << TestLog::EndSection;
783 });
784 ES3F_ADD_API_CASE(copyteximage2d_invalid_border, "Invalid glCopyTexImage2D() usage", {
785 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
786
787 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
788 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, -1);
789 expectError(GL_INVALID_VALUE);
790 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, 1);
791 expectError(GL_INVALID_VALUE);
792 m_log << TestLog::EndSection;
793
794 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
795 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
796 expectError(GL_INVALID_VALUE);
797 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
798 expectError(GL_INVALID_VALUE);
799 m_log << TestLog::EndSection;
800
801 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
802 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
803 expectError(GL_INVALID_VALUE);
804 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
805 expectError(GL_INVALID_VALUE);
806 m_log << TestLog::EndSection;
807
808 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
809 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
810 expectError(GL_INVALID_VALUE);
811 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
812 expectError(GL_INVALID_VALUE);
813 m_log << TestLog::EndSection;
814
815 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
816 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
817 expectError(GL_INVALID_VALUE);
818 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
819 expectError(GL_INVALID_VALUE);
820 m_log << TestLog::EndSection;
821
822 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
823 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
824 expectError(GL_INVALID_VALUE);
825 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
826 expectError(GL_INVALID_VALUE);
827 m_log << TestLog::EndSection;
828
829 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
830 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
831 expectError(GL_INVALID_VALUE);
832 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
833 expectError(GL_INVALID_VALUE);
834 m_log << TestLog::EndSection;
835
836 m_log << TestLog::EndSection;
837 });
838 ES3F_ADD_API_CASE(copyteximage2d_incomplete_framebuffer, "Invalid glCopyTexImage2D() usage", {
839 GLuint fbo;
840 glGenFramebuffers(1, &fbo);
841 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
842 glCheckFramebufferStatus(GL_FRAMEBUFFER);
843
844 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound "
845 "framebuffer is not framebuffer complete.");
846 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, 0, 0);
847 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
848 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
849 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
850 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
851 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
852 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
853 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
854 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
855 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
856 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
857 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
858 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
859 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
860 m_log << tcu::TestLog::EndSection;
861
862 glBindFramebuffer(GL_FRAMEBUFFER, 0);
863 glDeleteFramebuffers(1, &fbo);
864 });
865
866 // glCopyTexSubImage2D
867
868 ES3F_ADD_API_CASE(copytexsubimage2d_invalid_target, "Invalid glCopyTexSubImage2D() usage", {
869 GLuint texture;
870 glGenTextures(1, &texture);
871 glBindTexture(GL_TEXTURE_2D, texture);
872 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
873
874 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
875 glCopyTexSubImage2D(0, 0, 0, 0, 0, 0, 4, 4);
876 expectError(GL_INVALID_ENUM);
877 m_log << TestLog::EndSection;
878
879 glDeleteTextures(1, &texture);
880 });
881 ES3F_ADD_API_CASE(copytexsubimage2d_neg_level, "Invalid glCopyTexSubImage2D() usage", {
882 GLuint textures[2];
883 glGenTextures(2, &textures[0]);
884 glBindTexture(GL_TEXTURE_2D, textures[0]);
885 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
886 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
887 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
888
889 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
890 glCopyTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, 4, 4);
891 expectError(GL_INVALID_VALUE);
892 FOR_CUBE_FACES(faceGL, {
893 glCopyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4);
894 expectError(GL_INVALID_VALUE);
895 });
896 m_log << TestLog::EndSection;
897
898 glDeleteTextures(2, &textures[0]);
899 });
900 ES3F_ADD_API_CASE(copytexsubimage2d_max_level, "Invalid glCopyTexSubImage2D() usage", {
901 GLuint textures[2];
902 glGenTextures(2, &textures[0]);
903 glBindTexture(GL_TEXTURE_2D, textures[0]);
904 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
905 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
906 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
907
908 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than "
909 "log_2(GL_MAX_TEXTURE_SIZE) for 2D texture targets.");
910 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
911 glCopyTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 4, 4);
912 expectError(GL_INVALID_VALUE);
913 m_log << TestLog::EndSection;
914
915 m_log << TestLog::Section(
916 "",
917 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_SIZE) for cubemap targets.");
918 uint32_t log2MaxCubemapSize =
919 deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
920 FOR_CUBE_FACES(faceGL, {
921 glCopyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4);
922 expectError(GL_INVALID_VALUE);
923 });
924 m_log << TestLog::EndSection;
925
926 glDeleteTextures(2, &textures[0]);
927 });
928 ES3F_ADD_API_CASE(copytexsubimage2d_neg_offset, "Invalid glCopyTexSubImage2D() usage", {
929 GLuint texture;
930 glGenTextures(1, &texture);
931 glBindTexture(GL_TEXTURE_2D, texture);
932 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
933
934 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.");
935 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, 4, 4);
936 expectError(GL_INVALID_VALUE);
937 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, 4, 4);
938 expectError(GL_INVALID_VALUE);
939 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, 4, 4);
940 expectError(GL_INVALID_VALUE);
941 m_log << TestLog::EndSection;
942
943 glDeleteTextures(1, &texture);
944 });
945 ES3F_ADD_API_CASE(copytexsubimage2d_invalid_offset, "Invalid glCopyTexSubImage2D() usage", {
946 GLuint texture;
947 glGenTextures(1, &texture);
948 glBindTexture(GL_TEXTURE_2D, texture);
949 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
950
951 m_log << TestLog::Section(
952 "",
953 "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
954 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 0, 0, 0, 4, 4);
955 expectError(GL_INVALID_VALUE);
956 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 14, 0, 0, 4, 4);
957 expectError(GL_INVALID_VALUE);
958 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 14, 0, 0, 4, 4);
959 expectError(GL_INVALID_VALUE);
960 m_log << TestLog::EndSection;
961
962 glDeleteTextures(1, &texture);
963 });
964 ES3F_ADD_API_CASE(copytexsubimage2d_neg_width_height, "Invalid glCopyTexSubImage2D() usage", {
965 GLuint texture;
966 glGenTextures(1, &texture);
967 glBindTexture(GL_TEXTURE_2D, texture);
968 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
969
970 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
971 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0);
972 expectError(GL_INVALID_VALUE);
973 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1);
974 expectError(GL_INVALID_VALUE);
975 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1);
976 expectError(GL_INVALID_VALUE);
977 m_log << TestLog::EndSection;
978
979 glDeleteTextures(1, &texture);
980 });
981 ES3F_ADD_API_CASE(copytexsubimage2d_incomplete_framebuffer, "Invalid glCopyTexSubImage2D() usage", {
982 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound "
983 "framebuffer is not framebuffer complete.");
984
985 GLuint texture[2];
986 GLuint fbo;
987
988 glGenTextures(2, texture);
989 glBindTexture(GL_TEXTURE_2D, texture[0]);
990 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
991 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[1]);
992 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
993 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
994 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
995 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
996 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
997 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
998 expectError(GL_NO_ERROR);
999
1000 glGenFramebuffers(1, &fbo);
1001 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1002 glCheckFramebufferStatus(GL_FRAMEBUFFER);
1003 expectError(GL_NO_ERROR);
1004
1005 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
1006 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1007 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
1008 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1009 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
1010 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1011 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1012 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1013 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
1014 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1015 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
1016 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1017 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1018 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1019
1020 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1021 glDeleteFramebuffers(1, &fbo);
1022 glDeleteTextures(2, texture);
1023
1024 m_log << tcu::TestLog::EndSection;
1025 });
1026
1027 // glDeleteTextures
1028
1029 ES3F_ADD_API_CASE(deletetextures, "Invalid glDeleteTextures() usage", {
1030 GLuint texture;
1031 glGenTextures(1, &texture);
1032
1033 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1034 glDeleteTextures(-1, 0);
1035 expectError(GL_INVALID_VALUE);
1036
1037 glBindTexture(GL_TEXTURE_2D, texture);
1038 glDeleteTextures(-1, 0);
1039 expectError(GL_INVALID_VALUE);
1040 m_log << TestLog::EndSection;
1041
1042 glDeleteTextures(1, &texture);
1043 });
1044
1045 // glGenerateMipmap
1046
1047 ES3F_ADD_API_CASE(generatemipmap, "Invalid glGenerateMipmap() usage", {
1048 GLuint texture[2];
1049 glGenTextures(2, texture);
1050
1051 m_log << TestLog::Section(
1052 "", "GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.");
1053 glGenerateMipmap(0);
1054 expectError(GL_INVALID_ENUM);
1055 m_log << TestLog::EndSection;
1056
1057 m_log << TestLog::Section(
1058 "", "INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
1059 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1060 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
1061 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1062 glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1063 expectError(GL_INVALID_OPERATION);
1064
1065 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1066 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1067 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1068 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1069 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1070 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1071 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1072 glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1073 expectError(GL_INVALID_OPERATION);
1074 m_log << TestLog::EndSection;
1075
1076 if (glu::isContextTypeES(m_context.getRenderContext().getType()))
1077 {
1078 m_log << TestLog::Section(
1079 "",
1080 "GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
1081 glBindTexture(GL_TEXTURE_2D, texture[1]);
1082 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1083 glGenerateMipmap(GL_TEXTURE_2D);
1084 expectError(GL_INVALID_OPERATION);
1085 m_log << TestLog::EndSection;
1086
1087 m_log << TestLog::Section(
1088 "", "GL_INVALID_OPERATION is generated if the level base array was not specified with an unsized "
1089 "internal format or a sized internal format that is both color-renderable and texture-filterable.");
1090 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 0, 0, 0, GL_RGB, GL_BYTE, 0);
1091 glGenerateMipmap(GL_TEXTURE_2D);
1092 expectError(GL_INVALID_OPERATION);
1093 glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, 0);
1094 glGenerateMipmap(GL_TEXTURE_2D);
1095 expectError(GL_INVALID_OPERATION);
1096
1097 if (!(m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") &&
1098 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
1099 {
1100 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
1101 glGenerateMipmap(GL_TEXTURE_2D);
1102 expectError(GL_INVALID_OPERATION);
1103 }
1104
1105 m_log << TestLog::EndSection;
1106 }
1107
1108 glDeleteTextures(2, texture);
1109 });
1110
1111 // glGenTextures
1112
1113 ES3F_ADD_API_CASE(gentextures, "Invalid glGenTextures() usage", {
1114 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1115 glGenTextures(-1, 0);
1116 expectError(GL_INVALID_VALUE);
1117 m_log << TestLog::EndSection;
1118 });
1119
1120 // glPixelStorei
1121
1122 ES3F_ADD_API_CASE(pixelstorei, "Invalid glPixelStorei() usage", {
1123 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1124 glPixelStorei(0, 1);
1125 expectError(GL_INVALID_ENUM);
1126 m_log << TestLog::EndSection;
1127
1128 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if a negative row length, pixel skip, or row skip "
1129 "value is specified, or if alignment is specified as other than 1, 2, 4, or 8.");
1130 glPixelStorei(GL_PACK_ROW_LENGTH, -1);
1131 expectError(GL_INVALID_VALUE);
1132 glPixelStorei(GL_PACK_SKIP_ROWS, -1);
1133 expectError(GL_INVALID_VALUE);
1134 glPixelStorei(GL_PACK_SKIP_PIXELS, -1);
1135 expectError(GL_INVALID_VALUE);
1136 glPixelStorei(GL_UNPACK_ROW_LENGTH, -1);
1137 expectError(GL_INVALID_VALUE);
1138 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, -1);
1139 expectError(GL_INVALID_VALUE);
1140 glPixelStorei(GL_UNPACK_SKIP_ROWS, -1);
1141 expectError(GL_INVALID_VALUE);
1142 glPixelStorei(GL_UNPACK_SKIP_PIXELS, -1);
1143 expectError(GL_INVALID_VALUE);
1144 glPixelStorei(GL_UNPACK_SKIP_IMAGES, -1);
1145 expectError(GL_INVALID_VALUE);
1146 glPixelStorei(GL_PACK_ALIGNMENT, 0);
1147 expectError(GL_INVALID_VALUE);
1148 glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
1149 expectError(GL_INVALID_VALUE);
1150 glPixelStorei(GL_PACK_ALIGNMENT, 16);
1151 expectError(GL_INVALID_VALUE);
1152 glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
1153 expectError(GL_INVALID_VALUE);
1154 m_log << TestLog::EndSection;
1155 });
1156
1157 // glTexImage2D
1158
1159 ES3F_ADD_API_CASE(teximage2d, "Invalid glTexImage2D() usage", {
1160 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1161 glTexImage2D(0, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1162 expectError(GL_INVALID_ENUM);
1163 m_log << TestLog::EndSection;
1164
1165 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1166 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 0, 0);
1167 expectError(GL_INVALID_ENUM);
1168 m_log << TestLog::EndSection;
1169
1170 m_log << TestLog::Section(
1171 "", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
1172 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1173 expectError(GL_INVALID_OPERATION);
1174 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1175 expectError(GL_INVALID_OPERATION);
1176 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
1177 expectError(GL_INVALID_OPERATION);
1178 if (glu::isContextTypeES(m_context.getRenderContext().getType()))
1179 {
1180 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1181 expectError(GL_INVALID_OPERATION);
1182 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
1183 expectError(GL_INVALID_OPERATION);
1184 }
1185 m_log << TestLog::EndSection;
1186 });
1187 ES3F_ADD_API_CASE(teximage2d_inequal_width_height_cube, "Invalid glTexImage2D() usage", {
1188 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is one of the six cube map 2D image "
1189 "targets and the width and height parameters are not equal.");
1190 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1191 expectError(GL_INVALID_VALUE);
1192 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1193 expectError(GL_INVALID_VALUE);
1194 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1195 expectError(GL_INVALID_VALUE);
1196 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1197 expectError(GL_INVALID_VALUE);
1198 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1199 expectError(GL_INVALID_VALUE);
1200 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1201 expectError(GL_INVALID_VALUE);
1202 m_log << TestLog::EndSection;
1203 });
1204 ES3F_ADD_API_CASE(teximage2d_neg_level, "Invalid glTexImage2D() usage", {
1205 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1206 glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1207 expectError(GL_INVALID_VALUE);
1208 m_log << TestLog::EndSection;
1209
1210 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1211 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1212 expectError(GL_INVALID_VALUE);
1213 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1214 expectError(GL_INVALID_VALUE);
1215 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1216 expectError(GL_INVALID_VALUE);
1217 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1218 expectError(GL_INVALID_VALUE);
1219 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1220 expectError(GL_INVALID_VALUE);
1221 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1222 expectError(GL_INVALID_VALUE);
1223 m_log << TestLog::EndSection;
1224 });
1225 ES3F_ADD_API_CASE(teximage2d_max_level, "Invalid glTexImage2D() usage", {
1226 m_log << TestLog::Section("",
1227 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1228 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1229 glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1230 expectError(GL_INVALID_VALUE);
1231 m_log << TestLog::EndSection;
1232
1233 m_log << TestLog::Section(
1234 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1235 uint32_t log2MaxCubemapSize =
1236 deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1237 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1238 expectError(GL_INVALID_VALUE);
1239 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1240 expectError(GL_INVALID_VALUE);
1241 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1242 expectError(GL_INVALID_VALUE);
1243 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1244 expectError(GL_INVALID_VALUE);
1245 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1246 expectError(GL_INVALID_VALUE);
1247 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1248 expectError(GL_INVALID_VALUE);
1249 m_log << TestLog::EndSection;
1250 });
1251 ES3F_ADD_API_CASE(teximage2d_neg_width_height, "Invalid glTexImage2D() usage", {
1252 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1253
1254 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
1255 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1256 expectError(GL_INVALID_VALUE);
1257 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1258 expectError(GL_INVALID_VALUE);
1259 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1260 expectError(GL_INVALID_VALUE);
1261 m_log << TestLog::EndSection;
1262
1263 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1264 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1265 expectError(GL_INVALID_VALUE);
1266 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1267 expectError(GL_INVALID_VALUE);
1268 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1269 expectError(GL_INVALID_VALUE);
1270 m_log << TestLog::EndSection;
1271
1272 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1273 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1274 expectError(GL_INVALID_VALUE);
1275 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1276 expectError(GL_INVALID_VALUE);
1277 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1278 expectError(GL_INVALID_VALUE);
1279 m_log << TestLog::EndSection;
1280
1281 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1282 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1283 expectError(GL_INVALID_VALUE);
1284 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1285 expectError(GL_INVALID_VALUE);
1286 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1287 expectError(GL_INVALID_VALUE);
1288 m_log << TestLog::EndSection;
1289
1290 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1291 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1292 expectError(GL_INVALID_VALUE);
1293 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1294 expectError(GL_INVALID_VALUE);
1295 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1296 expectError(GL_INVALID_VALUE);
1297 m_log << TestLog::EndSection;
1298
1299 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1300 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1301 expectError(GL_INVALID_VALUE);
1302 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1303 expectError(GL_INVALID_VALUE);
1304 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1305 expectError(GL_INVALID_VALUE);
1306 m_log << TestLog::EndSection;
1307
1308 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1309 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1310 expectError(GL_INVALID_VALUE);
1311 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1312 expectError(GL_INVALID_VALUE);
1313 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1314 expectError(GL_INVALID_VALUE);
1315 m_log << TestLog::EndSection;
1316
1317 m_log << TestLog::EndSection;
1318 });
1319 ES3F_ADD_API_CASE(teximage2d_max_width_height, "Invalid glTexImage2D() usage", {
1320 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
1321 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1322
1323 m_log << TestLog::Section(
1324 "", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
1325 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1326 expectError(GL_INVALID_VALUE);
1327 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1328 expectError(GL_INVALID_VALUE);
1329 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1330 expectError(GL_INVALID_VALUE);
1331 m_log << TestLog::EndSection;
1332
1333 m_log << TestLog::Section(
1334 "", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1335
1336 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1337 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1338 expectError(GL_INVALID_VALUE);
1339 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1340 expectError(GL_INVALID_VALUE);
1341 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB,
1342 GL_UNSIGNED_BYTE, 0);
1343 expectError(GL_INVALID_VALUE);
1344 m_log << TestLog::EndSection;
1345
1346 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1347 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1348 expectError(GL_INVALID_VALUE);
1349 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1350 expectError(GL_INVALID_VALUE);
1351 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB,
1352 GL_UNSIGNED_BYTE, 0);
1353 expectError(GL_INVALID_VALUE);
1354 m_log << TestLog::EndSection;
1355
1356 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1357 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1358 expectError(GL_INVALID_VALUE);
1359 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1360 expectError(GL_INVALID_VALUE);
1361 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB,
1362 GL_UNSIGNED_BYTE, 0);
1363 expectError(GL_INVALID_VALUE);
1364 m_log << TestLog::EndSection;
1365
1366 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1367 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1368 expectError(GL_INVALID_VALUE);
1369 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1370 expectError(GL_INVALID_VALUE);
1371 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB,
1372 GL_UNSIGNED_BYTE, 0);
1373 expectError(GL_INVALID_VALUE);
1374 m_log << TestLog::EndSection;
1375
1376 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1377 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1378 expectError(GL_INVALID_VALUE);
1379 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1380 expectError(GL_INVALID_VALUE);
1381 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB,
1382 GL_UNSIGNED_BYTE, 0);
1383 expectError(GL_INVALID_VALUE);
1384 m_log << TestLog::EndSection;
1385
1386 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1387 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1388 expectError(GL_INVALID_VALUE);
1389 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1390 expectError(GL_INVALID_VALUE);
1391 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB,
1392 GL_UNSIGNED_BYTE, 0);
1393 expectError(GL_INVALID_VALUE);
1394 m_log << TestLog::EndSection;
1395
1396 m_log << TestLog::EndSection;
1397 });
1398 ES3F_ADD_API_CASE(teximage2d_invalid_border, "Invalid glTexImage2D() usage", {
1399 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
1400 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1401 expectError(GL_INVALID_VALUE);
1402 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1403 expectError(GL_INVALID_VALUE);
1404 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1405 expectError(GL_INVALID_VALUE);
1406 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1407 expectError(GL_INVALID_VALUE);
1408 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1409 expectError(GL_INVALID_VALUE);
1410 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1411 expectError(GL_INVALID_VALUE);
1412 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1413 expectError(GL_INVALID_VALUE);
1414 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1415 expectError(GL_INVALID_VALUE);
1416 m_log << TestLog::EndSection;
1417 });
1418 ES3F_ADD_API_CASE(teximage2d_invalid_buffer_target, "Invalid glTexImage2D() usage", {
1419 uint32_t buf;
1420 uint32_t texture;
1421 std::vector<GLubyte> data(64);
1422
1423 glGenBuffers(1, &buf);
1424 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
1425 glBufferData(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1426 glGenTextures(1, &texture);
1427 glBindTexture(GL_TEXTURE_2D, texture);
1428 expectError(GL_NO_ERROR);
1429
1430 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to "
1431 "the GL_PIXEL_UNPACK_BUFFER target and...");
1432 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1433 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1434 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1435 expectError(GL_INVALID_OPERATION);
1436 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
1437 m_log << TestLog::EndSection;
1438
1439 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads "
1440 "required would exceed the data store size.");
1441 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1442 expectError(GL_INVALID_OPERATION);
1443 m_log << TestLog::EndSection;
1444
1445 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in "
1446 "memory a datum indicated by type.");
1447 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1448 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid *)3);
1449 expectError(GL_INVALID_OPERATION);
1450 m_log << TestLog::EndSection;
1451 m_log << TestLog::EndSection;
1452
1453 glDeleteBuffers(1, &buf);
1454 glDeleteTextures(1, &texture);
1455 });
1456
1457 // glTexSubImage2D
1458
1459 ES3F_ADD_API_CASE(texsubimage2d, "Invalid glTexSubImage2D() usage", {
1460 uint32_t texture;
1461 glGenTextures(1, &texture);
1462 glBindTexture(GL_TEXTURE_2D, texture);
1463 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1464 expectError(GL_NO_ERROR);
1465
1466 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1467 glTexSubImage2D(0, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1468 expectError(GL_INVALID_ENUM);
1469 m_log << TestLog::EndSection;
1470
1471 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
1472 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, GL_UNSIGNED_BYTE, 0);
1473 expectError(GL_INVALID_ENUM);
1474 m_log << TestLog::EndSection;
1475
1476 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1477 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, 0, 0);
1478 expectError(GL_INVALID_ENUM);
1479 m_log << TestLog::EndSection;
1480
1481 m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat of "
1482 "the previously specified texture array, format and type is not valid.");
1483 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
1484 expectError(GL_INVALID_OPERATION);
1485 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1486 expectError(GL_INVALID_OPERATION);
1487 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1488 expectError(GL_INVALID_OPERATION);
1489 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1490 expectError(GL_INVALID_OPERATION);
1491 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
1492 expectError(GL_INVALID_OPERATION);
1493 if (glu::isContextTypeES(m_context.getRenderContext().getType()))
1494 {
1495 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_FLOAT, 0);
1496 expectError(GL_INVALID_OPERATION);
1497 }
1498 m_log << tcu::TestLog::EndSection;
1499
1500 glDeleteTextures(1, &texture);
1501 });
1502 ES3F_ADD_API_CASE(texsubimage2d_neg_level, "Invalid glTexSubImage2D() usage", {
1503 uint32_t textures[2];
1504 glGenTextures(2, &textures[0]);
1505 glBindTexture(GL_TEXTURE_2D, textures[0]);
1506 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1507 glBindTexture(GL_TEXTURE_2D, textures[1]);
1508 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1509 expectError(GL_NO_ERROR);
1510
1511 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1512 glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1513 expectError(GL_INVALID_VALUE);
1514 m_log << TestLog::EndSection;
1515
1516 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1517 FOR_CUBE_FACES(faceGL, {
1518 glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1519 expectError(GL_INVALID_VALUE);
1520 });
1521 m_log << TestLog::EndSection;
1522
1523 glDeleteTextures(2, &textures[0]);
1524 });
1525 ES3F_ADD_API_CASE(texsubimage2d_max_level, "Invalid glTexSubImage2D() usage", {
1526 uint32_t textures[2];
1527 glGenTextures(2, &textures[0]);
1528 glBindTexture(GL_TEXTURE_2D, textures[0]);
1529 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1530 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
1531 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1532 expectError(GL_NO_ERROR);
1533
1534 m_log << TestLog::Section("",
1535 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1536 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1537 glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1538 expectError(GL_INVALID_VALUE);
1539 m_log << TestLog::EndSection;
1540
1541 m_log << TestLog::Section(
1542 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1543 uint32_t log2MaxCubemapSize =
1544 deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1545 FOR_CUBE_FACES(faceGL, {
1546 glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1547 expectError(GL_INVALID_VALUE);
1548 });
1549 m_log << TestLog::EndSection;
1550
1551 glDeleteTextures(2, &textures[0]);
1552 });
1553 ES3F_ADD_API_CASE(texsubimage2d_neg_offset, "Invalid glTexSubImage2D() usage", {
1554 uint32_t texture;
1555 glGenTextures(1, &texture);
1556 glBindTexture(GL_TEXTURE_2D, texture);
1557 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1558 expectError(GL_NO_ERROR);
1559
1560 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
1561 glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1562 expectError(GL_INVALID_VALUE);
1563 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1564 expectError(GL_INVALID_VALUE);
1565 glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1566 expectError(GL_INVALID_VALUE);
1567 m_log << TestLog::EndSection;
1568
1569 glDeleteTextures(1, &texture);
1570 });
1571 ES3F_ADD_API_CASE(texsubimage2d_invalid_offset, "Invalid glTexSubImage2D() usage", {
1572 uint32_t texture;
1573 glGenTextures(1, &texture);
1574 glBindTexture(GL_TEXTURE_2D, texture);
1575 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1576 expectError(GL_NO_ERROR);
1577
1578 m_log << TestLog::Section(
1579 "",
1580 "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1581 glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1582 expectError(GL_INVALID_VALUE);
1583 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1584 expectError(GL_INVALID_VALUE);
1585 glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1586 expectError(GL_INVALID_VALUE);
1587 m_log << TestLog::EndSection;
1588
1589 glDeleteTextures(1, &texture);
1590 });
1591 ES3F_ADD_API_CASE(texsubimage2d_neg_width_height, "Invalid glTexSubImage2D() usage", {
1592 uint32_t texture;
1593 glGenTextures(1, &texture);
1594 glBindTexture(GL_TEXTURE_2D, texture);
1595 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1596 expectError(GL_NO_ERROR);
1597
1598 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1599 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1600 expectError(GL_INVALID_VALUE);
1601 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1602 expectError(GL_INVALID_VALUE);
1603 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1604 expectError(GL_INVALID_VALUE);
1605 m_log << TestLog::EndSection;
1606
1607 glDeleteTextures(1, &texture);
1608 });
1609 ES3F_ADD_API_CASE(texsubimage2d_invalid_buffer_target, "Invalid glTexSubImage2D() usage", {
1610 uint32_t buf;
1611 uint32_t texture;
1612 std::vector<GLubyte> data(64);
1613
1614 glGenTextures(1, &texture);
1615 glBindTexture(GL_TEXTURE_2D, texture);
1616 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1617 glGenBuffers(1, &buf);
1618 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
1619 glBufferData(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1620 expectError(GL_NO_ERROR);
1621
1622 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to "
1623 "the GL_PIXEL_UNPACK_BUFFER target and...");
1624 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1625 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1626 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1627 expectError(GL_INVALID_OPERATION);
1628 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
1629 m_log << TestLog::EndSection;
1630
1631 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads "
1632 "required would exceed the data store size.");
1633 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1634 expectError(GL_INVALID_OPERATION);
1635 m_log << TestLog::EndSection;
1636
1637 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in "
1638 "memory a datum indicated by type.");
1639 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1640 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
1641 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1642 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
1643 expectError(GL_NO_ERROR);
1644 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid *)3);
1645 expectError(GL_INVALID_OPERATION);
1646 m_log << TestLog::EndSection;
1647 m_log << TestLog::EndSection;
1648
1649 glDeleteBuffers(1, &buf);
1650 glDeleteTextures(1, &texture);
1651 });
1652
1653 // glTexParameteri
1654
1655 ES3F_ADD_API_CASE(texparameteri, "Invalid glTexParameteri() usage", {
1656 m_log << TestLog::Section(
1657 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1658 glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1659 expectError(GL_INVALID_ENUM);
1660 glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1661 expectError(GL_INVALID_ENUM);
1662 glTexParameteri(0, 0, GL_LINEAR);
1663 expectError(GL_INVALID_ENUM);
1664 m_log << TestLog::EndSection;
1665
1666 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1667 "value (based on the value of pname) and does not.");
1668 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1669 expectError(GL_INVALID_ENUM);
1670 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1671 expectError(GL_INVALID_ENUM);
1672 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1673 expectError(GL_INVALID_ENUM);
1674 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1675 expectError(GL_INVALID_ENUM);
1676 m_log << TestLog::EndSection;
1677
1678 GLuint texture;
1679 glGenTextures(1, &texture);
1680 glBindTexture(GL_TEXTURE_2D, texture);
1681
1682 m_log << TestLog::Section(
1683 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1684 glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1685 expectError(GL_INVALID_ENUM);
1686 glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1687 expectError(GL_INVALID_ENUM);
1688 glTexParameteri(0, 0, GL_LINEAR);
1689 expectError(GL_INVALID_ENUM);
1690 m_log << TestLog::EndSection;
1691
1692 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1693 "value (based on the value of pname) and does not.");
1694 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1695 expectError(GL_INVALID_ENUM);
1696 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1697 expectError(GL_INVALID_ENUM);
1698 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1699 expectError(GL_INVALID_ENUM);
1700 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1701 expectError(GL_INVALID_ENUM);
1702 m_log << TestLog::EndSection;
1703
1704 glDeleteTextures(1, &texture);
1705 });
1706
1707 // glTexParameterf
1708
1709 ES3F_ADD_API_CASE(texparameterf, "Invalid glTexParameterf() usage", {
1710 m_log << TestLog::Section(
1711 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1712 glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1713 expectError(GL_INVALID_ENUM);
1714 glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1715 expectError(GL_INVALID_ENUM);
1716 glTexParameterf(0, 0, GL_LINEAR);
1717 expectError(GL_INVALID_ENUM);
1718 m_log << TestLog::EndSection;
1719
1720 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1721 "value (based on the value of pname) and does not.");
1722 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1723 expectError(GL_INVALID_ENUM);
1724 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1725 expectError(GL_INVALID_ENUM);
1726 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1727 expectError(GL_INVALID_ENUM);
1728 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1729 expectError(GL_INVALID_ENUM);
1730 m_log << TestLog::EndSection;
1731
1732 GLuint texture;
1733 glGenTextures(1, &texture);
1734 glBindTexture(GL_TEXTURE_2D, texture);
1735
1736 m_log << TestLog::Section(
1737 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1738 glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1739 expectError(GL_INVALID_ENUM);
1740 glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1741 expectError(GL_INVALID_ENUM);
1742 glTexParameterf(0, 0, GL_LINEAR);
1743 expectError(GL_INVALID_ENUM);
1744 m_log << TestLog::EndSection;
1745
1746 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1747 "value (based on the value of pname) and does not.");
1748 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1749 expectError(GL_INVALID_ENUM);
1750 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1751 expectError(GL_INVALID_ENUM);
1752 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1753 expectError(GL_INVALID_ENUM);
1754 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1755 expectError(GL_INVALID_ENUM);
1756 m_log << TestLog::EndSection;
1757
1758 glDeleteTextures(1, &texture);
1759 });
1760
1761 // glTexParameteriv
1762
1763 ES3F_ADD_API_CASE(texparameteriv, "Invalid glTexParameteriv() usage", {
1764 m_log << TestLog::Section(
1765 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1766 GLint params[1] = {GL_LINEAR};
1767 glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1768 expectError(GL_INVALID_ENUM);
1769 glTexParameteriv(GL_TEXTURE_2D, 0, ¶ms[0]);
1770 expectError(GL_INVALID_ENUM);
1771 glTexParameteriv(0, 0, ¶ms[0]);
1772 expectError(GL_INVALID_ENUM);
1773 m_log << TestLog::EndSection;
1774
1775 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1776 "value (based on the value of pname) and does not.");
1777 params[0] = 0;
1778 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1779 expectError(GL_INVALID_ENUM);
1780 params[0] = GL_REPEAT;
1781 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1782 expectError(GL_INVALID_ENUM);
1783 params[0] = 0;
1784 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1785 expectError(GL_INVALID_ENUM);
1786 params[0] = GL_NEAREST;
1787 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1788 expectError(GL_INVALID_ENUM);
1789 m_log << TestLog::EndSection;
1790
1791 GLuint texture;
1792 glGenTextures(1, &texture);
1793 glBindTexture(GL_TEXTURE_2D, texture);
1794
1795 m_log << TestLog::Section(
1796 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1797 params[0] = GL_LINEAR;
1798 glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1799 expectError(GL_INVALID_ENUM);
1800 glTexParameteriv(GL_TEXTURE_2D, 0, ¶ms[0]);
1801 expectError(GL_INVALID_ENUM);
1802 glTexParameteriv(0, 0, ¶ms[0]);
1803 expectError(GL_INVALID_ENUM);
1804 m_log << TestLog::EndSection;
1805
1806 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1807 "value (based on the value of pname) and does not.");
1808 params[0] = 0;
1809 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1810 expectError(GL_INVALID_ENUM);
1811 params[0] = GL_REPEAT;
1812 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1813 expectError(GL_INVALID_ENUM);
1814 params[0] = 0;
1815 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1816 expectError(GL_INVALID_ENUM);
1817 params[0] = GL_NEAREST;
1818 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1819 expectError(GL_INVALID_ENUM);
1820 m_log << TestLog::EndSection;
1821
1822 glDeleteTextures(1, &texture);
1823 });
1824
1825 // glTexParameterfv
1826
1827 ES3F_ADD_API_CASE(texparameterfv, "Invalid glTexParameterfv() usage", {
1828 m_log << TestLog::Section(
1829 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1830 GLfloat params[1] = {GL_LINEAR};
1831 glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1832 expectError(GL_INVALID_ENUM);
1833 glTexParameterfv(GL_TEXTURE_2D, 0, ¶ms[0]);
1834 expectError(GL_INVALID_ENUM);
1835 glTexParameterfv(0, 0, ¶ms[0]);
1836 expectError(GL_INVALID_ENUM);
1837 m_log << TestLog::EndSection;
1838
1839 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1840 "value (based on the value of pname) and does not.");
1841 params[0] = 0.0f;
1842 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1843 expectError(GL_INVALID_ENUM);
1844 params[0] = GL_REPEAT;
1845 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1846 expectError(GL_INVALID_ENUM);
1847 params[0] = 0.0f;
1848 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1849 expectError(GL_INVALID_ENUM);
1850 params[0] = GL_NEAREST;
1851 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1852 expectError(GL_INVALID_ENUM);
1853 m_log << TestLog::EndSection;
1854
1855 GLuint texture;
1856 glGenTextures(1, &texture);
1857 glBindTexture(GL_TEXTURE_2D, texture);
1858
1859 m_log << TestLog::Section(
1860 "", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1861 params[0] = GL_LINEAR;
1862 glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1863 expectError(GL_INVALID_ENUM);
1864 glTexParameterfv(GL_TEXTURE_2D, 0, ¶ms[0]);
1865 expectError(GL_INVALID_ENUM);
1866 glTexParameterfv(0, 0, ¶ms[0]);
1867 expectError(GL_INVALID_ENUM);
1868 m_log << TestLog::EndSection;
1869
1870 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant "
1871 "value (based on the value of pname) and does not.");
1872 params[0] = 0.0f;
1873 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1874 expectError(GL_INVALID_ENUM);
1875 params[0] = GL_REPEAT;
1876 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1877 expectError(GL_INVALID_ENUM);
1878 params[0] = 0.0f;
1879 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1880 expectError(GL_INVALID_ENUM);
1881 params[0] = GL_NEAREST;
1882 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1883 expectError(GL_INVALID_ENUM);
1884 m_log << TestLog::EndSection;
1885
1886 glDeleteTextures(1, &texture);
1887 });
1888
1889 // glCompressedTexSubImage2D
1890
1891 ES3F_ADD_API_CASE(compressedtexsubimage2d, "Invalid glCompressedTexSubImage2D() usage", {
1892 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1893 glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1894 expectError(GL_INVALID_ENUM);
1895 m_log << TestLog::EndSection;
1896
1897 uint32_t texture;
1898 glGenTextures(1, &texture);
1899 glBindTexture(GL_TEXTURE_2D, texture);
1900 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1901 expectError(GL_NO_ERROR);
1902
1903 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format "
1904 "of the texture image being modified.");
1905 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1906 expectError(GL_INVALID_OPERATION);
1907 m_log << TestLog::EndSection;
1908
1909 m_log << TestLog::Section("",
1910 "For ETC2/EAC images GL_INVALID_OPERATION is generated if width is not a multiple of "
1911 "four, and width + xoffset is not equal to the width of the texture level.");
1912 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 4, 0, 10, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4),
1913 0);
1914 expectError(GL_INVALID_OPERATION);
1915 m_log << TestLog::EndSection;
1916
1917 m_log << TestLog::Section("",
1918 "For ETC2/EAC images GL_INVALID_OPERATION is generated if height is not a multiple "
1919 "of four, and height + yoffset is not equal to the height of the texture level.");
1920 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 4, 4, 10, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10),
1921 0);
1922 expectError(GL_INVALID_OPERATION);
1923 m_log << TestLog::EndSection;
1924
1925 m_log << TestLog::Section(
1926 "",
1927 "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
1928 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1929 expectError(GL_INVALID_OPERATION);
1930 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1931 expectError(GL_INVALID_OPERATION);
1932 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1933 expectError(GL_INVALID_OPERATION);
1934 m_log << TestLog::EndSection;
1935
1936 glDeleteTextures(1, &texture);
1937 });
1938 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_level, "Invalid glCompressedTexSubImage2D() usage", {
1939 uint32_t textures[2];
1940 glGenTextures(2, &textures[0]);
1941 glBindTexture(GL_TEXTURE_2D, textures[0]);
1942 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1943 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
1944 FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0,
1945 etc2EacDataSize(18, 18), 0););
1946 expectError(GL_NO_ERROR);
1947
1948 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1949 glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1950 expectError(GL_INVALID_VALUE);
1951 m_log << TestLog::EndSection;
1952
1953 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1954 FOR_CUBE_FACES(faceGL, {
1955 glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1956 expectError(GL_INVALID_VALUE);
1957 });
1958 m_log << TestLog::EndSection;
1959
1960 glDeleteTextures(2, &textures[0]);
1961 });
1962 ES3F_ADD_API_CASE(compressedtexsubimage2d_max_level, "Invalid glCompressedTexSubImage2D() usage", {
1963 uint32_t textures[2];
1964 glGenTextures(2, &textures[0]);
1965 glBindTexture(GL_TEXTURE_2D, textures[0]);
1966 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1967 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
1968 FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0,
1969 etc2EacDataSize(18, 18), 0););
1970 expectError(GL_NO_ERROR);
1971
1972 m_log << TestLog::Section("",
1973 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1974 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1975 glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1976 expectError(GL_INVALID_VALUE);
1977 m_log << TestLog::EndSection;
1978
1979 m_log << TestLog::Section(
1980 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1981 uint32_t log2MaxCubemapSize =
1982 deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1983 FOR_CUBE_FACES(faceGL, {
1984 glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1985 expectError(GL_INVALID_VALUE);
1986 });
1987 m_log << TestLog::EndSection;
1988
1989 glDeleteTextures(2, &textures[0]);
1990 });
1991 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_offset, "Invalid glCompressedTexSubImage2D() usage", {
1992 GLuint texture;
1993 glGenTextures(1, &texture);
1994 glBindTexture(GL_TEXTURE_2D, texture);
1995 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, etc2EacDataSize(8, 8), 0);
1996
1997 // \note Both GL_INVALID_VALUE and GL_INVALID_OPERATION are valid here since implementation may
1998 // first check if offsets are valid for certain format and only after that check that they
1999 // are not negative.
2000 m_log << TestLog::Section(
2001 "", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset or yoffset are negative.");
2002
2003 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2004 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2005 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2006 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2007 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2008 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2009
2010 m_log << TestLog::EndSection;
2011
2012 glDeleteTextures(1, &texture);
2013 });
2014 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_offset, "Invalid glCompressedTexSubImage2D() usage", {
2015 uint32_t texture;
2016 glGenTextures(1, &texture);
2017 glBindTexture(GL_TEXTURE_2D, texture);
2018 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2019 expectError(GL_NO_ERROR);
2020
2021 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > "
2022 "texture_width or yoffset + height > texture_height.");
2023
2024 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 0, 8, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4),
2025 0);
2026 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2027 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 12, 4, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8),
2028 0);
2029 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2030 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 12, 8, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8),
2031 0);
2032 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2033 m_log << TestLog::EndSection;
2034
2035 glDeleteTextures(1, &texture);
2036 });
2037 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_width_height, "Invalid glCompressedTexSubImage2D() usage", {
2038 uint32_t texture;
2039 glGenTextures(1, &texture);
2040 glBindTexture(GL_TEXTURE_2D, texture);
2041 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2042 expectError(GL_NO_ERROR);
2043
2044 m_log << TestLog::Section(
2045 "", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width or height is less than 0.");
2046 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2047 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2048 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2049 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2050 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2051 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2052 m_log << TestLog::EndSection;
2053
2054 glDeleteTextures(1, &texture);
2055 });
2056 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_size, "Invalid glCompressedTexImage2D() usage", {
2057 uint32_t texture;
2058 glGenTextures(1, &texture);
2059 glBindTexture(GL_TEXTURE_2D, texture);
2060 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2061 expectError(GL_NO_ERROR);
2062
2063 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, "
2064 "dimensions, and contents of the specified compressed image data.");
2065 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2066 expectError(GL_INVALID_VALUE);
2067
2068 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, 4 * 4 * 16 - 1, 0);
2069 expectError(GL_INVALID_VALUE);
2070 m_log << TestLog::EndSection;
2071
2072 glDeleteTextures(1, &texture);
2073 });
2074 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_buffer_target, "Invalid glCompressedTexSubImage2D() usage", {
2075 uint32_t buf;
2076 uint32_t texture;
2077 std::vector<GLubyte> data(128);
2078
2079 glGenTextures(1, &texture);
2080 glBindTexture(GL_TEXTURE_2D, texture);
2081 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2082 glGenBuffers(1, &buf);
2083 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2084 glBufferData(GL_PIXEL_UNPACK_BUFFER, 128, &data[0], GL_DYNAMIC_COPY);
2085 expectError(GL_NO_ERROR);
2086
2087 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to "
2088 "the GL_PIXEL_UNPACK_BUFFER target and...");
2089 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2090 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2091 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2092 expectError(GL_INVALID_OPERATION);
2093 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
2094 m_log << TestLog::EndSection;
2095
2096 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads "
2097 "required would exceed the data store size.");
2098 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16),
2099 0);
2100 expectError(GL_INVALID_OPERATION);
2101 m_log << TestLog::EndSection;
2102 m_log << TestLog::EndSection;
2103
2104 glDeleteBuffers(1, &buf);
2105 glDeleteTextures(1, &texture);
2106 });
2107
2108 // glTexImage3D
2109
2110 ES3F_ADD_API_CASE(teximage3d, "Invalid glTexImage3D() usage", {
2111 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2112 glTexImage3D(0, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2113 expectError(GL_INVALID_ENUM);
2114 glTexImage3D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2115 expectError(GL_INVALID_ENUM);
2116 m_log << TestLog::EndSection;
2117
2118 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2119 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 0, 0);
2120 expectError(GL_INVALID_ENUM);
2121 m_log << TestLog::EndSection;
2122
2123 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2124 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
2125 expectError(GL_INVALID_ENUM);
2126 m_log << TestLog::EndSection;
2127
2128 m_log << TestLog::Section(
2129 "", "GL_INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format "
2130 "symbolic constants "
2131 "or GL_INVALID_OPERATION is generated if internalformat, format and type are not compatible.");
2132 glTexImage3D(GL_TEXTURE_3D, 0, 0, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2133 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2134 m_log << TestLog::EndSection;
2135
2136 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if target is GL_TEXTURE_3D and format is "
2137 "GL_DEPTH_COMPONENT, or GL_DEPTH_STENCIL.");
2138 glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_STENCIL, 1, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
2139 expectError(GL_INVALID_OPERATION);
2140 glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_COMPONENT, 1, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
2141 expectError(GL_INVALID_OPERATION);
2142 m_log << TestLog::EndSection;
2143
2144 m_log << TestLog::Section(
2145 "", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
2146 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2147 expectError(GL_INVALID_OPERATION);
2148 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2149 expectError(GL_INVALID_OPERATION);
2150 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB10_A2, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
2151 expectError(GL_INVALID_OPERATION);
2152 if (glu::isContextTypeES(m_context.getRenderContext().getType()))
2153 {
2154 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2155 expectError(GL_INVALID_OPERATION);
2156 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, 1, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
2157 expectError(GL_INVALID_OPERATION);
2158 }
2159 m_log << TestLog::EndSection;
2160 });
2161 ES3F_ADD_API_CASE(teximage3d_neg_level, "Invalid glTexImage3D() usage", {
2162 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2163 glTexImage3D(GL_TEXTURE_3D, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2164 expectError(GL_INVALID_VALUE);
2165 glTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2166 expectError(GL_INVALID_VALUE);
2167 m_log << TestLog::EndSection;
2168 });
2169 ES3F_ADD_API_CASE(teximage3d_max_level, "Invalid glTexImage3D() usage", {
2170 m_log << TestLog::Section(
2171 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2172 uint32_t log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2173 glTexImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2174 expectError(GL_INVALID_VALUE);
2175 m_log << TestLog::EndSection;
2176
2177 m_log << TestLog::Section("",
2178 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2179 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2180 glTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2181 expectError(GL_INVALID_VALUE);
2182 m_log << TestLog::EndSection;
2183 });
2184 ES3F_ADD_API_CASE(teximage3d_neg_width_height_depth, "Invalid glTexImage3D() usage", {
2185 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
2186 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2187 expectError(GL_INVALID_VALUE);
2188 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2189 expectError(GL_INVALID_VALUE);
2190 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2191 expectError(GL_INVALID_VALUE);
2192 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2193 expectError(GL_INVALID_VALUE);
2194
2195 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2196 expectError(GL_INVALID_VALUE);
2197 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2198 expectError(GL_INVALID_VALUE);
2199 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2200 expectError(GL_INVALID_VALUE);
2201 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2202 expectError(GL_INVALID_VALUE);
2203 m_log << TestLog::EndSection;
2204 });
2205 ES3F_ADD_API_CASE(teximage3d_max_width_height_depth, "Invalid glTexImage3D() usage", {
2206 int max3DTextureSize = m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE) + 1;
2207 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2208 int maxTextureLayers = m_context.getContextInfo().getInt(GL_MAX_ARRAY_TEXTURE_LAYERS) + 1;
2209
2210 m_log << TestLog::Section(
2211 "", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_3D_TEXTURE_SIZE.");
2212 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2213 expectError(GL_INVALID_VALUE);
2214 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, max3DTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2215 expectError(GL_INVALID_VALUE);
2216 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2217 expectError(GL_INVALID_VALUE);
2218 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, GL_RGBA,
2219 GL_UNSIGNED_BYTE, 0);
2220 expectError(GL_INVALID_VALUE);
2221 m_log << TestLog::EndSection;
2222
2223 m_log << TestLog::Section(
2224 "", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2225 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2226 expectError(GL_INVALID_VALUE);
2227 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, maxTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2228 expectError(GL_INVALID_VALUE);
2229 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, maxTextureLayers, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2230 expectError(GL_INVALID_VALUE);
2231 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, maxTextureSize, maxTextureLayers, 0, GL_RGBA,
2232 GL_UNSIGNED_BYTE, 0);
2233 expectError(GL_INVALID_VALUE);
2234 m_log << TestLog::EndSection;
2235 });
2236 ES3F_ADD_API_CASE(teximage3d_invalid_border, "Invalid glTexImage3D() usage", {
2237 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0 or 1.");
2238 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2239 expectError(GL_INVALID_VALUE);
2240 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2241 expectError(GL_INVALID_VALUE);
2242 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2243 expectError(GL_INVALID_VALUE);
2244 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2245 expectError(GL_INVALID_VALUE);
2246 m_log << TestLog::EndSection;
2247 });
2248 ES3F_ADD_API_CASE(teximage3d_invalid_buffer_target, "Invalid glTexImage3D() usage", {
2249 uint32_t buf;
2250 uint32_t texture;
2251 std::vector<GLubyte> data(512);
2252
2253 glGenBuffers(1, &buf);
2254 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2255 glBufferData(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2256 glGenTextures(1, &texture);
2257 glBindTexture(GL_TEXTURE_3D, texture);
2258 expectError(GL_NO_ERROR);
2259
2260 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to "
2261 "the GL_PIXEL_UNPACK_BUFFER target and...");
2262
2263 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2264 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2265 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2266 expectError(GL_INVALID_OPERATION);
2267 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
2268 m_log << TestLog::EndSection;
2269
2270 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads "
2271 "required would exceed the data store size.");
2272 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 64, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2273 expectError(GL_INVALID_OPERATION);
2274 m_log << TestLog::EndSection;
2275
2276 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in "
2277 "memory a datum indicated by type.");
2278 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2279 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid *)3);
2280 expectError(GL_INVALID_OPERATION);
2281 m_log << TestLog::EndSection;
2282
2283 m_log << TestLog::EndSection;
2284
2285 glDeleteBuffers(1, &buf);
2286 glDeleteTextures(1, &texture);
2287 });
2288
2289 // glTexSubImage3D
2290
2291 ES3F_ADD_API_CASE(texsubimage3d, "Invalid glTexSubImage3D() usage", {
2292 uint32_t texture;
2293 glGenTextures(1, &texture);
2294 glBindTexture(GL_TEXTURE_3D, texture);
2295 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2296 expectError(GL_NO_ERROR);
2297
2298 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2299 glTexSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2300 expectError(GL_INVALID_ENUM);
2301 glTexSubImage3D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2302 expectError(GL_INVALID_ENUM);
2303 m_log << TestLog::EndSection;
2304
2305 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2306 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, GL_UNSIGNED_BYTE, 0);
2307 expectError(GL_INVALID_ENUM);
2308 m_log << TestLog::EndSection;
2309
2310 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2311 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, 0, 0);
2312 expectError(GL_INVALID_ENUM);
2313 m_log << TestLog::EndSection;
2314
2315 m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat of "
2316 "the previously specified texture array, format and type is not valid.");
2317 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2318 expectError(GL_INVALID_OPERATION);
2319 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2320 expectError(GL_INVALID_OPERATION);
2321 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2322 expectError(GL_INVALID_OPERATION);
2323 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
2324 expectError(GL_INVALID_OPERATION);
2325 if (glu::isContextTypeES(m_context.getRenderContext().getType()))
2326 {
2327 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_FLOAT, 0);
2328 expectError(GL_INVALID_OPERATION);
2329 }
2330 m_log << tcu::TestLog::EndSection;
2331
2332 glDeleteTextures(1, &texture);
2333 });
2334 ES3F_ADD_API_CASE(texsubimage3d_neg_level, "Invalid glTexSubImage3D() usage", {
2335 uint32_t textures[2];
2336 glGenTextures(2, &textures[0]);
2337 glBindTexture(GL_TEXTURE_3D, textures[0]);
2338 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2339 glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
2340 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2341 expectError(GL_NO_ERROR);
2342
2343 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2344 glTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2345 expectError(GL_INVALID_VALUE);
2346 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2347 expectError(GL_INVALID_VALUE);
2348 m_log << TestLog::EndSection;
2349
2350 glDeleteTextures(2, &textures[0]);
2351 });
2352 ES3F_ADD_API_CASE(texsubimage3d_max_level, "Invalid glTexSubImage3D() usage", {
2353 uint32_t textures[2];
2354 glGenTextures(2, &textures[0]);
2355 glBindTexture(GL_TEXTURE_3D, textures[0]);
2356 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2357 glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
2358 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2359 expectError(GL_NO_ERROR);
2360
2361 uint32_t log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2362 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2363
2364 m_log << TestLog::Section(
2365 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2366 glTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2367 expectError(GL_INVALID_VALUE);
2368 m_log << TestLog::EndSection;
2369
2370 m_log << TestLog::Section("",
2371 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2372 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2373 expectError(GL_INVALID_VALUE);
2374 m_log << TestLog::EndSection;
2375
2376 glDeleteTextures(2, &textures[0]);
2377 });
2378 ES3F_ADD_API_CASE(texsubimage3d_neg_offset, "Invalid glTexSubImage3D() usage", {
2379 uint32_t textures[2];
2380 glGenTextures(2, &textures[0]);
2381 glBindTexture(GL_TEXTURE_3D, textures[0]);
2382 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2383 glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
2384 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2385 expectError(GL_NO_ERROR);
2386
2387 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.");
2388 glTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2389 expectError(GL_INVALID_VALUE);
2390 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2391 expectError(GL_INVALID_VALUE);
2392 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2393 expectError(GL_INVALID_VALUE);
2394 glTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2395 expectError(GL_INVALID_VALUE);
2396 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2397 expectError(GL_INVALID_VALUE);
2398 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2399 expectError(GL_INVALID_VALUE);
2400 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2401 expectError(GL_INVALID_VALUE);
2402 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2403 expectError(GL_INVALID_VALUE);
2404 m_log << TestLog::EndSection;
2405
2406 glDeleteTextures(2, &textures[0]);
2407 });
2408 ES3F_ADD_API_CASE(texsubimage3d_invalid_offset, "Invalid glTexSubImage3D() usage", {
2409 uint32_t texture;
2410 glGenTextures(1, &texture);
2411 glBindTexture(GL_TEXTURE_3D, texture);
2412 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2413 expectError(GL_NO_ERROR);
2414
2415 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2416 glTexSubImage3D(GL_TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2417 expectError(GL_INVALID_VALUE);
2418 m_log << TestLog::EndSection;
2419
2420 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2421 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2422 expectError(GL_INVALID_VALUE);
2423 m_log << TestLog::EndSection;
2424
2425 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + depth > texture_depth.");
2426 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2427 expectError(GL_INVALID_VALUE);
2428 m_log << TestLog::EndSection;
2429
2430 glDeleteTextures(1, &texture);
2431 });
2432 ES3F_ADD_API_CASE(texsubimage3d_neg_width_height, "Invalid glTexSubImage3D() usage", {
2433 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2434 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2435 expectError(GL_INVALID_VALUE);
2436 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2437 expectError(GL_INVALID_VALUE);
2438 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2439 expectError(GL_INVALID_VALUE);
2440 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2441 expectError(GL_INVALID_VALUE);
2442 m_log << TestLog::EndSection;
2443 });
2444 ES3F_ADD_API_CASE(texsubimage3d_invalid_buffer_target, "Invalid glTexSubImage3D() usage", {
2445 uint32_t buf;
2446 uint32_t texture;
2447 std::vector<GLubyte> data(512);
2448
2449 glGenTextures(1, &texture);
2450 glBindTexture(GL_TEXTURE_3D, texture);
2451 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2452 glGenBuffers(1, &buf);
2453 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2454 glBufferData(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2455 expectError(GL_NO_ERROR);
2456
2457 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to "
2458 "the GL_PIXEL_UNPACK_BUFFER target and...");
2459
2460 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2461 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 512, GL_MAP_WRITE_BIT);
2462 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2463 expectError(GL_INVALID_OPERATION);
2464 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
2465 m_log << TestLog::EndSection;
2466
2467 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads "
2468 "required would exceed the data store size.");
2469 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 16, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2470 expectError(GL_INVALID_OPERATION);
2471 m_log << TestLog::EndSection;
2472
2473 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in "
2474 "memory a datum indicated by type.");
2475 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2476 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
2477 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2478 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2479 expectError(GL_NO_ERROR);
2480 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid *)3);
2481 expectError(GL_INVALID_OPERATION);
2482 m_log << TestLog::EndSection;
2483
2484 m_log << TestLog::EndSection;
2485
2486 glDeleteBuffers(1, &buf);
2487 glDeleteTextures(1, &texture);
2488 });
2489
2490 // glCopyTexSubImage3D
2491
2492 ES3F_ADD_API_CASE(copytexsubimage3d, "Invalid glCopyTexSubImage3D() usage", {
2493 GLuint texture;
2494 glGenTextures(1, &texture);
2495 glBindTexture(GL_TEXTURE_3D, texture);
2496 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2497
2498 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2499 glCopyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 4);
2500 expectError(GL_INVALID_ENUM);
2501 m_log << TestLog::EndSection;
2502
2503 glDeleteTextures(1, &texture);
2504 });
2505 ES3F_ADD_API_CASE(copytexsubimage3d_neg_level, "Invalid glCopyTexSubImage3D() usage", {
2506 uint32_t textures[2];
2507 glGenTextures(2, &textures[0]);
2508 glBindTexture(GL_TEXTURE_3D, textures[0]);
2509 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2510 glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
2511 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2512 expectError(GL_NO_ERROR);
2513
2514 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2515 glCopyTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 4);
2516 expectError(GL_INVALID_VALUE);
2517 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
2518 expectError(GL_INVALID_VALUE);
2519 m_log << TestLog::EndSection;
2520
2521 glDeleteTextures(2, &textures[0]);
2522 });
2523 ES3F_ADD_API_CASE(copytexsubimage3d_max_level, "Invalid glCopyTexSubImage3D() usage", {
2524 uint32_t log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2525 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2526
2527 uint32_t textures[2];
2528 glGenTextures(2, &textures[0]);
2529 glBindTexture(GL_TEXTURE_3D, textures[0]);
2530 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2531 glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
2532 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2533 expectError(GL_NO_ERROR);
2534
2535 m_log << TestLog::Section(
2536 "", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2537 glCopyTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 4);
2538 expectError(GL_INVALID_VALUE);
2539 m_log << TestLog::EndSection;
2540
2541 m_log << TestLog::Section("",
2542 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2543 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 4);
2544 expectError(GL_INVALID_VALUE);
2545 m_log << TestLog::EndSection;
2546
2547 glDeleteTextures(2, &textures[0]);
2548 });
2549 ES3F_ADD_API_CASE(copytexsubimage3d_neg_offset, "Invalid glCopyTexSubImage3D() usage", {
2550 GLuint texture;
2551 glGenTextures(1, &texture);
2552 glBindTexture(GL_TEXTURE_3D, texture);
2553 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2554
2555 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.");
2556 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 4, 4);
2557 expectError(GL_INVALID_VALUE);
2558 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4);
2559 expectError(GL_INVALID_VALUE);
2560 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4);
2561 expectError(GL_INVALID_VALUE);
2562 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4);
2563 expectError(GL_INVALID_VALUE);
2564 m_log << TestLog::EndSection;
2565
2566 glDeleteTextures(1, &texture);
2567 });
2568 ES3F_ADD_API_CASE(copytexsubimage3d_invalid_offset, "Invalid glCopyTexSubImage3D() usage", {
2569 GLuint texture;
2570 glGenTextures(1, &texture);
2571 glBindTexture(GL_TEXTURE_3D, texture);
2572 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2573
2574 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2575 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4);
2576 expectError(GL_INVALID_VALUE);
2577 m_log << TestLog::EndSection;
2578
2579 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2580 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4);
2581 expectError(GL_INVALID_VALUE);
2582 m_log << TestLog::EndSection;
2583
2584 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + 1 > texture_depth.");
2585 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4);
2586 expectError(GL_INVALID_VALUE);
2587 m_log << TestLog::EndSection;
2588
2589 glDeleteTextures(1, &texture);
2590 });
2591 ES3F_ADD_API_CASE(copytexsubimage3d_neg_width_height, "Invalid glCopyTexSubImage3D() usage", {
2592 GLuint texture;
2593 glGenTextures(1, &texture);
2594 glBindTexture(GL_TEXTURE_3D, texture);
2595 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2596
2597 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width < 0.");
2598 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4);
2599 expectError(GL_INVALID_VALUE);
2600 m_log << TestLog::EndSection;
2601
2602 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if height < 0.");
2603 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4);
2604 expectError(GL_INVALID_VALUE);
2605 m_log << TestLog::EndSection;
2606
2607 glDeleteTextures(1, &texture);
2608 });
2609 ES3F_ADD_API_CASE(copytexsubimage3d_incomplete_framebuffer, "Invalid glCopyTexSubImage3D() usage", {
2610 GLuint fbo;
2611 GLuint texture[2];
2612
2613 glGenTextures(2, texture);
2614 glBindTexture(GL_TEXTURE_3D, texture[0]);
2615 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2616 glBindTexture(GL_TEXTURE_2D_ARRAY, texture[1]);
2617 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2618 glGenFramebuffers(1, &fbo);
2619 glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
2620 glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
2621
2622 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound "
2623 "framebuffer is not framebuffer complete.");
2624 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4);
2625 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2626 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
2627 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2628 m_log << tcu::TestLog::EndSection;
2629
2630 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2631 glDeleteFramebuffers(1, &fbo);
2632 glDeleteTextures(2, texture);
2633 });
2634
2635 // glCompressedTexImage3D
2636
2637 ES3F_ADD_API_CASE(compressedteximage3d, "Invalid glCompressedTexImage3D() usage", {
2638 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2639 glCompressedTexImage3D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2640 expectError(GL_INVALID_ENUM);
2641 glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2642 expectError(GL_INVALID_ENUM);
2643 m_log << TestLog::EndSection;
2644
2645 m_log << TestLog::Section(
2646 "",
2647 "GL_INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.");
2648 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, 0);
2649 expectError(GL_INVALID_ENUM);
2650 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 0, 0, 0, 0, 0, 0);
2651 expectError(GL_INVALID_ENUM);
2652 m_log << TestLog::EndSection;
2653 });
2654 ES3F_ADD_API_CASE(compressedteximage3d_neg_level, "Invalid glCompressedTexImage3D() usage", {
2655 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2656 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2657 expectError(GL_INVALID_VALUE);
2658 m_log << TestLog::EndSection;
2659 });
2660 ES3F_ADD_API_CASE(compressedteximage3d_max_level, "Invalid glCompressedTexImage3D() usage", {
2661 m_log << TestLog::Section("",
2662 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2663 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2664 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2665 expectError(GL_INVALID_VALUE);
2666 m_log << TestLog::EndSection;
2667 });
2668 ES3F_ADD_API_CASE(compressedteximage3d_neg_width_height_depth, "Invalid glCompressedTexImage3D() usage", {
2669 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2670 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0, 0);
2671 expectError(GL_INVALID_VALUE);
2672 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0, 0);
2673 expectError(GL_INVALID_VALUE);
2674 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0, 0);
2675 expectError(GL_INVALID_VALUE);
2676 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, 0, 0);
2677 expectError(GL_INVALID_VALUE);
2678 m_log << TestLog::EndSection;
2679 });
2680 ES3F_ADD_API_CASE(compressedteximage3d_max_width_height_depth, "Invalid glCompressedTexImage3D() usage", {
2681 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2682 int maxTextureLayers = m_context.getContextInfo().getInt(GL_MAX_ARRAY_TEXTURE_LAYERS) + 1;
2683
2684 m_log << TestLog::Section(
2685 "", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2686 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, 0, 0);
2687 expectError(GL_INVALID_VALUE);
2688 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, 0, 0);
2689 expectError(GL_INVALID_VALUE);
2690 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureLayers, 0, 0, 0);
2691 expectError(GL_INVALID_VALUE);
2692 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize,
2693 maxTextureLayers, 0, 0, 0);
2694 expectError(GL_INVALID_VALUE);
2695 m_log << TestLog::EndSection;
2696 });
2697 ES3F_ADD_API_CASE(compressedteximage3d_invalid_border, "Invalid glCompressedTexImage3D() usage", {
2698 bool isES = glu::isContextTypeES(m_context.getRenderContext().getType());
2699 GLenum error = isES ? GL_INVALID_VALUE : GL_INVALID_OPERATION;
2700
2701 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
2702 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0, 0);
2703 expectError(error);
2704 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, 0, 0);
2705 expectError(error);
2706 m_log << TestLog::EndSection;
2707 });
2708 ES3F_ADD_API_CASE(compressedteximage3d_invalid_size, "Invalid glCompressedTexImage3D() usage", {
2709 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, "
2710 "dimensions, and contents of the specified compressed image data.");
2711 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, -1, 0);
2712 expectError(GL_INVALID_VALUE);
2713 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4 * 4 * 8, 0);
2714 expectError(GL_INVALID_VALUE);
2715 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, 4 * 4 * 16, 0);
2716 expectError(GL_INVALID_VALUE);
2717 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, 4 * 4 * 16, 0);
2718 expectError(GL_INVALID_VALUE);
2719 m_log << TestLog::EndSection;
2720 });
2721 ES3F_ADD_API_CASE(compressedteximage3d_invalid_buffer_target, "Invalid glCompressedTexImage3D() usage", {
2722 uint32_t buf;
2723 std::vector<GLubyte> data(512);
2724
2725 glGenBuffers(1, &buf);
2726 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2727 glBufferData(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
2728 expectError(GL_NO_ERROR);
2729
2730 m_log << TestLog::Section(
2731 "", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the "
2732 "GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped.");
2733 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 64, GL_MAP_WRITE_BIT);
2734 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 1, 0, etc2DataSize(4, 4), 0);
2735 expectError(GL_INVALID_OPERATION);
2736 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
2737 m_log << TestLog::EndSection;
2738
2739 m_log << TestLog::Section("",
2740 "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the "
2741 "GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the buffer object "
2742 "such that the memory reads required would exceed the data store size.");
2743 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, etc2DataSize(16, 16), 0);
2744 expectError(GL_INVALID_OPERATION);
2745 m_log << TestLog::EndSection;
2746
2747 glDeleteBuffers(1, &buf);
2748 });
2749 ES3F_ADD_API_CASE(compressedteximage3d_invalid_astc_target, "Invalid glCompressedTexImage3D() ASTC 3D targets", {
2750 // GLES 3.0.4, Sec 3.8.6, p.147: For example, the
2751 // compressed image format might be supported only for 2D
2752 // textures ... result in an INVALID_OPERATION error.
2753 // Also, if LDR is supported, formats cannot be invalid enums
2754
2755 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_sliced_3d") ||
2756 m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2757 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
2758 {
2759 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
2760 }
2761 else
2762 {
2763 const GLuint requiredError =
2764 m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ?
2765 GL_INVALID_OPERATION :
2766 GL_INVALID_ENUM;
2767
2768 if (requiredError == GL_INVALID_OPERATION)
2769 m_log.writeMessage("GL_INVALID_OPERATION should be generated if using TEXTURE_3D with LDR ASTC.");
2770 else
2771 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
2772
2773 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
2774 {
2775 const GLuint format = s_astcFormats[formatNdx];
2776 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
2777 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
2778 const size_t blockBytes = getBlockSize(tcuFormat);
2779 const vector<uint8_t> unusedData(blockBytes);
2780
2781 glCompressedTexImage3D(GL_TEXTURE_3D, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0,
2782 (int)blockBytes, &unusedData[0]);
2783 expectError(requiredError);
2784 }
2785 }
2786 });
2787
2788 // glCompressedTexSubImage3D
2789
2790 ES3F_ADD_API_CASE(compressedtexsubimage3d, "Invalid glCompressedTexSubImage3D() usage", {
2791 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2792 glCompressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2793 expectError(GL_INVALID_ENUM);
2794 m_log << TestLog::EndSection;
2795
2796 uint32_t texture;
2797 glGenTextures(1, &texture);
2798 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2799 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0,
2800 etc2EacDataSize(18, 18), 0);
2801 expectError(GL_NO_ERROR);
2802
2803 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format "
2804 "of the texture image being modified.");
2805 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
2806 expectError(GL_INVALID_OPERATION);
2807 m_log << TestLog::EndSection;
2808
2809 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and "
2810 "target is not GL_TEXTURE_2D_ARRAY.");
2811 glCompressedTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2812 etc2EacDataSize(18, 18), 0);
2813 expectError(GL_INVALID_OPERATION);
2814 m_log << TestLog::EndSection;
2815
2816 m_log << TestLog::Section("",
2817 "For ETC2/EAC images GL_INVALID_OPERATION is generated if width is not a multiple of "
2818 "four, and width + xoffset is not equal to the width of the texture level.");
2819 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2820 etc2EacDataSize(10, 4), 0);
2821 expectError(GL_INVALID_OPERATION);
2822 m_log << TestLog::EndSection;
2823
2824 m_log << TestLog::Section("",
2825 "For ETC2/EAC images GL_INVALID_OPERATION is generated if height is not a multiple "
2826 "of four, and height + yoffset is not equal to the height of the texture level.");
2827 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2828 etc2EacDataSize(4, 10), 0);
2829 expectError(GL_INVALID_OPERATION);
2830 m_log << TestLog::EndSection;
2831
2832 m_log << TestLog::Section(
2833 "",
2834 "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
2835 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2836 etc2EacDataSize(4, 4), 0);
2837 expectError(GL_INVALID_OPERATION);
2838 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2839 etc2EacDataSize(4, 4), 0);
2840 expectError(GL_INVALID_OPERATION);
2841 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2842 etc2EacDataSize(4, 4), 0);
2843 expectError(GL_INVALID_OPERATION);
2844 m_log << TestLog::EndSection;
2845
2846 glDeleteTextures(1, &texture);
2847 });
2848 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_level, "Invalid glCompressedTexSubImage3D() usage", {
2849 uint32_t texture;
2850 glGenTextures(1, &texture);
2851 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2852 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0,
2853 etc2EacDataSize(16, 16), 0);
2854 expectError(GL_NO_ERROR);
2855
2856 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2857 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2858 expectError(GL_INVALID_VALUE);
2859 m_log << TestLog::EndSection;
2860
2861 glDeleteTextures(1, &texture);
2862 });
2863 ES3F_ADD_API_CASE(compressedtexsubimage3d_max_level, "Invalid glCompressedTexSubImage3D() usage", {
2864 uint32_t texture;
2865 glGenTextures(1, &texture);
2866 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2867 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0,
2868 etc2EacDataSize(16, 16), 0);
2869 expectError(GL_NO_ERROR);
2870
2871 m_log << TestLog::Section("",
2872 "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2873 uint32_t log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2874 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0,
2875 GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2876 expectError(GL_INVALID_VALUE);
2877 m_log << TestLog::EndSection;
2878
2879 glDeleteTextures(1, &texture);
2880 });
2881 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_offset, "Invalid glCompressedTexSubImage3D() usage", {
2882 uint32_t texture;
2883 glGenTextures(1, &texture);
2884 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2885 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0,
2886 etc2EacDataSize(16, 16), 0);
2887 expectError(GL_NO_ERROR);
2888
2889 m_log << TestLog::Section(
2890 "", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.");
2891 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2892 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2893 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2894 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2895 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2896 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2897 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2898 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2899 m_log << TestLog::EndSection;
2900
2901 glDeleteTextures(1, &texture);
2902 });
2903 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_offset, "Invalid glCompressedTexSubImage3D() usage", {
2904 uint32_t texture;
2905 glGenTextures(1, &texture);
2906 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2907 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, etc2EacDataSize(4, 4),
2908 0);
2909 expectError(GL_NO_ERROR);
2910
2911 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > "
2912 "texture_width or yoffset + height > texture_height.");
2913
2914 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2915 etc2EacDataSize(8, 4), 0);
2916 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2917 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2918 etc2EacDataSize(4, 8), 0);
2919 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2920 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2921 etc2EacDataSize(4, 4), 0);
2922 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2923 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2924 etc2EacDataSize(8, 8), 0);
2925 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2926 m_log << TestLog::EndSection;
2927
2928 glDeleteTextures(1, &texture);
2929 });
2930 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_width_height_depth, "Invalid glCompressedTexSubImage3D() usage", {
2931 uint32_t texture;
2932 glGenTextures(1, &texture);
2933 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2934 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0,
2935 etc2EacDataSize(16, 16), 0);
2936 expectError(GL_NO_ERROR);
2937
2938 m_log << TestLog::Section(
2939 "", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width, height or depth are negative.");
2940 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2941 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2942 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2943 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2944 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2945 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2946 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2947 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2948 m_log << TestLog::EndSection;
2949
2950 glDeleteTextures(1, &texture);
2951 });
2952 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_size, "Invalid glCompressedTexSubImage3D() usage", {
2953 uint32_t texture;
2954 glGenTextures(1, &texture);
2955 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2956 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4 * 4 * 16, 0);
2957 expectError(GL_NO_ERROR);
2958
2959 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, "
2960 "dimensions, and contents of the specified compressed image data.");
2961 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2962 expectError(GL_INVALID_VALUE);
2963
2964 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2965 4 * 4 * 16 - 1, 0);
2966 expectError(GL_INVALID_VALUE);
2967 m_log << TestLog::EndSection;
2968
2969 glDeleteTextures(1, &texture);
2970 });
2971 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_buffer_target, "Invalid glCompressedTexSubImage3D() usage", {
2972 uint32_t buf;
2973 uint32_t texture;
2974 GLsizei bufferSize = etc2EacDataSize(4, 4);
2975 std::vector<GLubyte> data(bufferSize);
2976
2977 glGenTextures(1, &texture);
2978 glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
2979 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0,
2980 etc2EacDataSize(16, 16), 0);
2981 glGenBuffers(1, &buf);
2982 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2983 glBufferData(GL_PIXEL_UNPACK_BUFFER, bufferSize, &data[0], GL_DYNAMIC_COPY);
2984 expectError(GL_NO_ERROR);
2985
2986 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to "
2987 "the GL_PIXEL_UNPACK_BUFFER target and...");
2988 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2989 glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, GL_MAP_WRITE_BIT);
2990 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2991 etc2EacDataSize(4, 4), 0);
2992 expectError(GL_INVALID_OPERATION);
2993 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
2994 m_log << TestLog::EndSection;
2995
2996 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads "
2997 "required would exceed the data store size.");
2998 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC,
2999 etc2EacDataSize(16, 16), 0);
3000 expectError(GL_INVALID_OPERATION);
3001 m_log << TestLog::EndSection;
3002 m_log << TestLog::EndSection;
3003
3004 glDeleteBuffers(1, &buf);
3005 glDeleteTextures(1, &texture);
3006 });
3007
3008 // glTexStorage2D
3009
3010 ES3F_ADD_API_CASE(texstorage2d, "Invalid glTexStorage2D() usage", {
3011 uint32_t texture;
3012 glGenTextures(1, &texture);
3013 glBindTexture(GL_TEXTURE_2D, texture);
3014
3015 m_log << TestLog::Section(
3016 "",
3017 "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3018 glTexStorage2D(GL_TEXTURE_2D, 1, 0, 16, 16);
3019 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3020 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, 16, 16);
3021 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3022 m_log << TestLog::EndSection;
3023
3024 m_log << TestLog::Section(
3025 "", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3026 glTexStorage2D(0, 1, GL_RGBA8, 16, 16);
3027 expectError(GL_INVALID_ENUM);
3028 glTexStorage2D(GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16);
3029 expectError(GL_INVALID_ENUM);
3030 glTexStorage2D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16);
3031 expectError(GL_INVALID_ENUM);
3032 m_log << TestLog::EndSection;
3033
3034 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height are less than 1.");
3035 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 16);
3036 expectError(GL_INVALID_VALUE);
3037 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 0);
3038 expectError(GL_INVALID_VALUE);
3039 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 0);
3040 expectError(GL_INVALID_VALUE);
3041 m_log << TestLog::EndSection;
3042
3043 glDeleteTextures(1, &texture);
3044 });
3045
3046 ES3F_ADD_API_CASE(texstorage2d_invalid_binding, "Invalid glTexStorage2D() usage", {
3047 glBindTexture(GL_TEXTURE_2D, 0);
3048
3049 m_log << TestLog::Section(
3050 "", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3051 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3052 expectError(GL_INVALID_OPERATION);
3053 m_log << TestLog::EndSection;
3054
3055 uint32_t texture;
3056 glGenTextures(1, &texture);
3057 glBindTexture(GL_TEXTURE_2D, texture);
3058
3059 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the texture object currently bound to "
3060 "target already has GL_TEXTURE_IMMUTABLE_FORMAT set to GL_TRUE.");
3061 int32_t immutable = -1;
3062 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3063 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE")
3064 << TestLog::EndMessage;
3065 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3066 expectError(GL_NO_ERROR);
3067 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3068 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE")
3069 << TestLog::EndMessage;
3070 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3071 expectError(GL_INVALID_OPERATION);
3072 m_log << TestLog::EndSection;
3073
3074 glDeleteTextures(1, &texture);
3075 });
3076 ES3F_ADD_API_CASE(texstorage2d_invalid_levels, "Invalid glTexStorage2D() usage", {
3077 uint32_t texture;
3078 glGenTextures(1, &texture);
3079 glBindTexture(GL_TEXTURE_2D, texture);
3080
3081 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
3082 glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16);
3083 expectError(GL_INVALID_VALUE);
3084 glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0);
3085 expectError(GL_INVALID_VALUE);
3086 m_log << TestLog::EndSection;
3087
3088 m_log << TestLog::Section(
3089 "", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1");
3090 uint32_t log2MaxSize = deLog2Floor32(deMax32(16, 4)) + 1 + 1;
3091 glTexStorage2D(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 4);
3092 expectError(GL_INVALID_OPERATION);
3093 glTexStorage2D(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 4, 16);
3094 expectError(GL_INVALID_OPERATION);
3095 glTexStorage2D(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 16);
3096 expectError(GL_INVALID_OPERATION);
3097 m_log << TestLog::EndSection;
3098
3099 glDeleteTextures(1, &texture);
3100 });
3101 ES3F_ADD_API_CASE(texstorage2d_invalid_astc_target, "ASTC formats require extensions present.", {
3102 // GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
3103 // for which this command would have been valid, an
3104 // INVALID_OPERATION error is generated. Also: If
3105 // executing the pseudo-code would result in any other
3106 // error, the error is generated and the command will have
3107 // no effect.
3108 // In conclusion: Expect same errors as with TexImage?D
3109
3110 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
3111 {
3112 m_log.writeMessage("ASTC supported. No negative API requirements.");
3113 }
3114 else
3115 {
3116 // In earlier tests both codes are accepted for invalid target format.
3117 m_log.writeMessage(
3118 "GL_INVALID_ENUM or GL_INVALID_VALUE should be generated if no ASTC extensions are present.");
3119
3120 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3121 {
3122 const GLuint format = s_astcFormats[formatNdx];
3123 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
3124 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
3125 const int32_t cubeSize = blockPixels.x() * blockPixels.y(); // Divisible by the block size and square
3126 uint32_t texture = 0;
3127
3128 glGenTextures(1, &texture);
3129 glBindTexture(GL_TEXTURE_2D, texture);
3130
3131 glTexStorage2D(GL_TEXTURE_2D, 1, format, blockPixels.x(), blockPixels.y());
3132 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3133
3134 glDeleteTextures(1, &texture);
3135
3136 glGenTextures(1, &texture);
3137 glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
3138
3139 glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, format, cubeSize, cubeSize);
3140 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3141
3142 glDeleteTextures(1, &texture);
3143 }
3144 }
3145 });
3146
3147 // glTexStorage3D
3148
3149 ES3F_ADD_API_CASE(texstorage3d, "Invalid glTexStorage3D() usage", {
3150 uint32_t texture;
3151 glGenTextures(1, &texture);
3152 glBindTexture(GL_TEXTURE_3D, texture);
3153
3154 m_log << TestLog::Section(
3155 "",
3156 "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3157 glTexStorage3D(GL_TEXTURE_3D, 1, 0, 4, 4, 4);
3158 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3159 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA_INTEGER, 4, 4, 4);
3160 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3161 m_log << TestLog::EndSection;
3162
3163 m_log << TestLog::Section(
3164 "", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3165 glTexStorage3D(0, 1, GL_RGBA8, 4, 4, 4);
3166 expectError(GL_INVALID_ENUM);
3167 glTexStorage3D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 4, 4, 4);
3168 expectError(GL_INVALID_ENUM);
3169 glTexStorage3D(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 4);
3170 expectError(GL_INVALID_ENUM);
3171 m_log << TestLog::EndSection;
3172
3173 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth are less than 1.");
3174 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 4, 4);
3175 expectError(GL_INVALID_VALUE);
3176 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 0, 4);
3177 expectError(GL_INVALID_VALUE);
3178 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 0);
3179 expectError(GL_INVALID_VALUE);
3180 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 0, 0);
3181 expectError(GL_INVALID_VALUE);
3182 m_log << TestLog::EndSection;
3183
3184 glDeleteTextures(1, &texture);
3185 });
3186 ES3F_ADD_API_CASE(texstorage3d_invalid_binding, "Invalid glTexStorage3D() usage", {
3187 glBindTexture(GL_TEXTURE_3D, 0);
3188
3189 m_log << TestLog::Section(
3190 "", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3191 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3192 expectError(GL_INVALID_OPERATION);
3193 m_log << TestLog::EndSection;
3194
3195 uint32_t texture;
3196 glGenTextures(1, &texture);
3197 glBindTexture(GL_TEXTURE_3D, texture);
3198
3199 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the texture object currently bound to "
3200 "target already has GL_TEXTURE_IMMUTABLE_FORMAT set to GL_TRUE.");
3201 int32_t immutable = -1;
3202 glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3203 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE")
3204 << TestLog::EndMessage;
3205 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3206 expectError(GL_NO_ERROR);
3207 glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3208 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE")
3209 << TestLog::EndMessage;
3210 glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3211 expectError(GL_INVALID_OPERATION);
3212 m_log << TestLog::EndSection;
3213
3214 glDeleteTextures(1, &texture);
3215 });
3216 ES3F_ADD_API_CASE(texstorage3d_invalid_levels, "Invalid glTexStorage3D() usage", {
3217 uint32_t texture;
3218 glGenTextures(1, &texture);
3219 glBindTexture(GL_TEXTURE_3D, texture);
3220
3221 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
3222 glTexStorage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4);
3223 expectError(GL_INVALID_VALUE);
3224 glTexStorage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 0, 0, 0);
3225 expectError(GL_INVALID_VALUE);
3226 m_log << TestLog::EndSection;
3227
3228 m_log << TestLog::Section(
3229 "",
3230 "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1");
3231 uint32_t log2MaxSize = deLog2Floor32(8) + 1 + 1;
3232 glTexStorage3D(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 2, 2);
3233 expectError(GL_INVALID_OPERATION);
3234 glTexStorage3D(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 8, 2);
3235 expectError(GL_INVALID_OPERATION);
3236 glTexStorage3D(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 2, 8);
3237 expectError(GL_INVALID_OPERATION);
3238 glTexStorage3D(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 8, 8);
3239 expectError(GL_INVALID_OPERATION);
3240 m_log << TestLog::EndSection;
3241
3242 glDeleteTextures(1, &texture);
3243 });
3244
3245 ES3F_ADD_API_CASE(texstorage3d_invalid_astc_target, "Invalid glTexStorage3D() ASTC 3D targets", {
3246 // GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
3247 // for which this command would have been valid, an
3248 // INVALID_OPERATION error is generated. Also: If
3249 // executing the pseudo-code would result in any other
3250 // error, the error is generated and the command will have
3251 // no effect.
3252 // In conclusion: Expect same errors as with TexImage?D
3253
3254 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_sliced_3d") ||
3255 m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
3256 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3257 {
3258 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3259 }
3260 else
3261 {
3262 const bool ldrAstcSupported =
3263 m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr");
3264 if (ldrAstcSupported)
3265 m_log.writeMessage("GL_INVALID_OPERATION should be generated if using TEXTURE_3D with LDR.");
3266 else
3267 // In earlier tests both codes are accepted for invalid target format.
3268 m_log.writeMessage(
3269 "GL_INVALID_ENUM or GL_INVALID_VALUE should be generated if no ASTC extensions are present.");
3270
3271 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3272 {
3273 const GLuint format = s_astcFormats[formatNdx];
3274 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
3275 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
3276 uint32_t texture = 0;
3277
3278 glGenTextures(1, &texture);
3279 glBindTexture(GL_TEXTURE_3D, texture);
3280
3281 glTexStorage3D(GL_TEXTURE_3D, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3282
3283 if (ldrAstcSupported)
3284 expectError(GL_INVALID_OPERATION);
3285 else
3286 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3287
3288 glDeleteTextures(1, &texture);
3289 }
3290 }
3291 });
3292 }
3293
3294 } // namespace Functional
3295 } // namespace gles3
3296 } // namespace deqp
3297