1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Negative Texture API tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es3fNegativeTextureApiTests.hpp"
25 #include "es3fApiCase.hpp"
26 #include "gluContextInfo.hpp"
27 #include "tcuFormatUtil.hpp"
28 #include "gluTextureUtil.hpp"
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
36 using namespace glw; // GL types
46 using tcu::CompressedTexFormat;
47 using tcu::getBlockSize;
48 using tcu::getBlockPixelSize;
50 using glu::mapGLCompressedTexFormat;
53 static inline int divRoundUp (int a, int b)
55 return a/b + (a%b != 0 ? 1 : 0);
58 static inline int etc2DataSize (int width, int height)
60 return (int)(divRoundUp(width, 4) * divRoundUp(height, 4) * sizeof(deUint64));
63 static inline int etc2EacDataSize (int width, int height)
65 return 2 * etc2DataSize(width, height);
68 static const GLuint s_astcFormats[] =
70 GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
71 GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
72 GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
73 GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
74 GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
75 GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
76 GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
77 GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
78 GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
79 GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
80 GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
81 GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
82 GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
83 GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
84 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
85 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
86 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
87 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
88 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
89 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
90 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
91 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
92 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
93 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
94 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
95 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
96 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
97 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
100 static deUint32 cubeFaceToGLFace (tcu::CubeFace face)
104 case tcu::CUBEFACE_NEGATIVE_X: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
105 case tcu::CUBEFACE_POSITIVE_X: return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
106 case tcu::CUBEFACE_NEGATIVE_Y: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
107 case tcu::CUBEFACE_POSITIVE_Y: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
108 case tcu::CUBEFACE_NEGATIVE_Z: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
109 case tcu::CUBEFACE_POSITIVE_Z: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
116 #define FOR_CUBE_FACES(FACE_GL_VAR, BODY) \
119 for (int faceIterTcu = 0; faceIterTcu < tcu::CUBEFACE_LAST; faceIterTcu++) \
121 const GLenum FACE_GL_VAR = cubeFaceToGLFace((tcu::CubeFace)faceIterTcu); \
126 NegativeTextureApiTests::NegativeTextureApiTests (Context& context)
127 : TestCaseGroup(context, "texture", "Negative Texture API Cases")
131 NegativeTextureApiTests::~NegativeTextureApiTests (void)
135 void NegativeTextureApiTests::init (void)
139 ES3F_ADD_API_CASE(activetexture, "Invalid glActiveTexture() usage",
141 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if texture is not one of GL_TEXTUREi, where i ranges from 0 to (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1).");
143 expectError(GL_INVALID_ENUM);
144 int numMaxTextureUnits = m_context.getContextInfo().getInt(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
145 glActiveTexture(GL_TEXTURE0 + numMaxTextureUnits);
146 expectError(GL_INVALID_ENUM);
147 m_log << TestLog::EndSection;
152 ES3F_ADD_API_CASE(bindtexture, "Invalid glBindTexture() usage",
155 glGenTextures(2, texture);
157 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the allowable values.");
159 expectError(GL_INVALID_ENUM);
160 glBindTexture(GL_FRAMEBUFFER, 1);
161 expectError(GL_INVALID_ENUM);
162 m_log << TestLog::EndSection;
164 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture was previously created with a target that doesn't match that of target.");
165 glBindTexture(GL_TEXTURE_2D, texture[0]);
166 expectError(GL_NO_ERROR);
167 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
168 expectError(GL_INVALID_OPERATION);
169 glBindTexture(GL_TEXTURE_3D, texture[0]);
170 expectError(GL_INVALID_OPERATION);
171 glBindTexture(GL_TEXTURE_2D_ARRAY, texture[0]);
172 expectError(GL_INVALID_OPERATION);
174 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[1]);
175 expectError(GL_NO_ERROR);
176 glBindTexture(GL_TEXTURE_2D, texture[1]);
177 expectError(GL_INVALID_OPERATION);
178 glBindTexture(GL_TEXTURE_3D, texture[1]);
179 expectError(GL_INVALID_OPERATION);
180 glBindTexture(GL_TEXTURE_2D_ARRAY, texture[1]);
181 expectError(GL_INVALID_OPERATION);
182 m_log << TestLog::EndSection;
184 glDeleteTextures(2, texture);
187 // glCompressedTexImage2D
189 ES3F_ADD_API_CASE(compressedteximage2d_invalid_target, "Invalid glCompressedTexImage2D() usage",
191 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
192 glCompressedTexImage2D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
193 expectError(GL_INVALID_ENUM);
194 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
195 expectError(GL_INVALID_ENUM);
196 m_log << TestLog::EndSection;
198 ES3F_ADD_API_CASE(compressedteximage2d_invalid_format, "Invalid glCompressedTexImage2D() usage",
200 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not a supported format returned in GL_COMPRESSED_TEXTURE_FORMATS.");
201 glCompressedTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
202 expectError(GL_INVALID_ENUM);
203 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, 0, 0);
204 expectError(GL_INVALID_ENUM);
205 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, 0, 0);
206 expectError(GL_INVALID_ENUM);
207 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
208 expectError(GL_INVALID_ENUM);
209 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
210 expectError(GL_INVALID_ENUM);
211 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
212 expectError(GL_INVALID_ENUM);
213 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
214 expectError(GL_INVALID_ENUM);
215 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
216 expectError(GL_INVALID_ENUM);
217 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
218 expectError(GL_INVALID_ENUM);
219 m_log << TestLog::EndSection;
221 ES3F_ADD_API_CASE(compressedteximage2d_neg_level, "Invalid glCompressedTexImage2D() usage",
223 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
224 glCompressedTexImage2D(GL_TEXTURE_2D, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
225 expectError(GL_INVALID_VALUE);
226 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
227 expectError(GL_INVALID_VALUE);
228 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
229 expectError(GL_INVALID_VALUE);
230 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
231 expectError(GL_INVALID_VALUE);
232 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
233 expectError(GL_INVALID_VALUE);
234 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
235 expectError(GL_INVALID_VALUE);
236 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
237 expectError(GL_INVALID_VALUE);
238 m_log << TestLog::EndSection;
240 ES3F_ADD_API_CASE(compressedteximage2d_max_level, "Invalid glCompressedTexImage2D() usage",
242 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for a 2d texture target.");
243 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
244 glCompressedTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
245 expectError(GL_INVALID_VALUE);
246 m_log << TestLog::EndSection;
248 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE) for a cubemap target.");
249 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
250 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
251 expectError(GL_INVALID_VALUE);
252 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
253 expectError(GL_INVALID_VALUE);
254 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
255 expectError(GL_INVALID_VALUE);
256 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
257 expectError(GL_INVALID_VALUE);
258 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
259 expectError(GL_INVALID_VALUE);
260 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
261 expectError(GL_INVALID_VALUE);
262 m_log << TestLog::EndSection;
264 ES3F_ADD_API_CASE(compressedteximage2d_neg_width_height, "Invalid glCompressedTexImage2D() usage",
266 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
268 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
269 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
270 expectError(GL_INVALID_VALUE);
271 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
272 expectError(GL_INVALID_VALUE);
273 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
274 expectError(GL_INVALID_VALUE);
275 m_log << TestLog::EndSection;
277 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
278 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
279 expectError(GL_INVALID_VALUE);
280 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
281 expectError(GL_INVALID_VALUE);
282 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
283 expectError(GL_INVALID_VALUE);
284 m_log << TestLog::EndSection;
286 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
287 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
288 expectError(GL_INVALID_VALUE);
289 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
290 expectError(GL_INVALID_VALUE);
291 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
292 expectError(GL_INVALID_VALUE);
293 m_log << TestLog::EndSection;
295 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
296 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
297 expectError(GL_INVALID_VALUE);
298 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
299 expectError(GL_INVALID_VALUE);
300 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
301 expectError(GL_INVALID_VALUE);
302 m_log << TestLog::EndSection;
304 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
305 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
306 expectError(GL_INVALID_VALUE);
307 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
308 expectError(GL_INVALID_VALUE);
309 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
310 expectError(GL_INVALID_VALUE);
311 m_log << TestLog::EndSection;
313 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
314 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
315 expectError(GL_INVALID_VALUE);
316 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
317 expectError(GL_INVALID_VALUE);
318 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
319 expectError(GL_INVALID_VALUE);
320 m_log << TestLog::EndSection;
322 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
323 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
324 expectError(GL_INVALID_VALUE);
325 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
326 expectError(GL_INVALID_VALUE);
327 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
328 expectError(GL_INVALID_VALUE);
329 m_log << TestLog::EndSection;
331 m_log << TestLog::EndSection;
333 ES3F_ADD_API_CASE(compressedteximage2d_max_width_height, "Invalid glCompressedTexImage2D() usage",
335 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
336 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
337 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
339 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
340 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 1, 0, etc2EacDataSize(maxTextureSize, 1), 0);
341 expectError(GL_INVALID_VALUE);
342 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxTextureSize, 0, etc2EacDataSize(1, maxTextureSize), 0);
343 expectError(GL_INVALID_VALUE);
344 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, 0, etc2EacDataSize(maxTextureSize, maxTextureSize), 0);
345 expectError(GL_INVALID_VALUE);
346 m_log << TestLog::EndSection;
348 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
349 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, 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, etc2EacDataSize(1, maxCubemapSize), 0);
352 expectError(GL_INVALID_VALUE);
353 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
354 expectError(GL_INVALID_VALUE);
355 m_log << TestLog::EndSection;
357 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
358 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
359 expectError(GL_INVALID_VALUE);
360 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
361 expectError(GL_INVALID_VALUE);
362 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
363 expectError(GL_INVALID_VALUE);
364 m_log << TestLog::EndSection;
366 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
367 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
368 expectError(GL_INVALID_VALUE);
369 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
370 expectError(GL_INVALID_VALUE);
371 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
372 expectError(GL_INVALID_VALUE);
373 m_log << TestLog::EndSection;
375 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
376 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
377 expectError(GL_INVALID_VALUE);
378 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
379 expectError(GL_INVALID_VALUE);
380 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
381 expectError(GL_INVALID_VALUE);
382 m_log << TestLog::EndSection;
384 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
385 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
386 expectError(GL_INVALID_VALUE);
387 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
388 expectError(GL_INVALID_VALUE);
389 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
390 expectError(GL_INVALID_VALUE);
391 m_log << TestLog::EndSection;
393 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
394 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
395 expectError(GL_INVALID_VALUE);
396 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
397 expectError(GL_INVALID_VALUE);
398 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
399 expectError(GL_INVALID_VALUE);
400 m_log << TestLog::EndSection;
402 m_log << TestLog::EndSection;
404 ES3F_ADD_API_CASE(compressedteximage2d_invalid_border, "Invalid glCompressedTexImage2D() usage",
406 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
408 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
409 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
410 expectError(GL_INVALID_VALUE);
411 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
412 expectError(GL_INVALID_VALUE);
413 m_log << TestLog::EndSection;
415 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
416 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
417 expectError(GL_INVALID_VALUE);
418 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
419 expectError(GL_INVALID_VALUE);
420 m_log << TestLog::EndSection;
422 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
423 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
424 expectError(GL_INVALID_VALUE);
425 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
426 expectError(GL_INVALID_VALUE);
427 m_log << TestLog::EndSection;
429 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
430 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
431 expectError(GL_INVALID_VALUE);
432 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
433 expectError(GL_INVALID_VALUE);
434 m_log << TestLog::EndSection;
436 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
437 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
438 expectError(GL_INVALID_VALUE);
439 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
440 expectError(GL_INVALID_VALUE);
441 m_log << TestLog::EndSection;
443 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
444 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
445 expectError(GL_INVALID_VALUE);
446 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
447 expectError(GL_INVALID_VALUE);
448 m_log << TestLog::EndSection;
450 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
451 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
452 expectError(GL_INVALID_VALUE);
453 glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
454 expectError(GL_INVALID_VALUE);
455 m_log << TestLog::EndSection;
457 m_log << TestLog::EndSection;
459 ES3F_ADD_API_CASE(compressedteximage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
461 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
462 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0);
463 expectError(GL_INVALID_VALUE);
464 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, 4*4*8, 0);
465 expectError(GL_INVALID_VALUE);
466 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, 4*4*16, 0);
467 expectError(GL_INVALID_VALUE);
468 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 0, 4*4*16, 0);
469 expectError(GL_INVALID_VALUE);
470 m_log << TestLog::EndSection;
472 ES3F_ADD_API_CASE(compressedteximage2d_invalid_buffer_target, "Invalid glCompressedTexImage2D() usage",
475 std::vector<GLubyte> data(64);
477 glGenBuffers (1, &buf);
478 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
479 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
480 expectError (GL_NO_ERROR);
482 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped.");
483 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
484 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 0, etc2DataSize(4, 4), 0);
485 expectError (GL_INVALID_OPERATION);
486 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
487 m_log << TestLog::EndSection;
489 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
490 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
491 expectError (GL_INVALID_OPERATION);
492 m_log << TestLog::EndSection;
494 glDeleteBuffers (1, &buf);
496 ES3F_ADD_API_CASE(compressedteximage2d_invalid_astc_target, "ASTC formats should not be supported without a proper extension.",
498 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
500 m_log.writeMessage("ASTC supported. No negative API requirements.");
504 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
506 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
508 const GLuint format = s_astcFormats[formatNdx];
509 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
510 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
512 const size_t blockBytes = getBlockSize(tcuFormat);
513 const vector<deUint8> dummyData (blockBytes);
515 glCompressedTexImage2D(GL_TEXTURE_2D, 0, format, blockPixels.x(), blockPixels.y(), 0, (int)blockBytes, &dummyData[0]);
516 expectError(GL_INVALID_ENUM);
518 FOR_CUBE_FACES(faceGL,
520 const deInt32 cubeSize = blockPixels.x() * blockPixels.y(); // Divisible by the block size and square
521 const size_t blockBytes = getBlockSize(tcuFormat) * cubeSize; // We have a x * y grid of blocks
522 const vector<deUint8> dummyData (blockBytes);
524 glCompressedTexImage2D(faceGL, 0, format, cubeSize, cubeSize, 0, (int)blockBytes, &dummyData[0]);
525 expectError(GL_INVALID_ENUM);
533 ES3F_ADD_API_CASE(copyteximage2d_invalid_target, "Invalid glCopyTexImage2D() usage",
535 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
536 glCopyTexImage2D(0, 0, GL_RGB, 0, 0, 64, 64, 0);
537 expectError(GL_INVALID_ENUM);
538 m_log << TestLog::EndSection;
540 ES3F_ADD_API_CASE(copyteximage2d_invalid_format, "Invalid glCopyTexImage2D() usage",
542 m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
543 glCopyTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0);
544 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
545 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0);
546 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
547 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0);
548 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
549 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0);
550 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
551 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0);
552 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
553 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0);
554 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
555 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0);
556 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
557 m_log << TestLog::EndSection;
559 ES3F_ADD_API_CASE(copyteximage2d_inequal_width_height_cube, "Invalid glCopyTexImage2D() usage",
561 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is one of the six cube map 2D image targets and the width and height parameters are not equal.");
562 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
563 expectError(GL_INVALID_VALUE);
564 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
565 expectError(GL_INVALID_VALUE);
566 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
567 expectError(GL_INVALID_VALUE);
568 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
569 expectError(GL_INVALID_VALUE);
570 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
571 expectError(GL_INVALID_VALUE);
572 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
573 expectError(GL_INVALID_VALUE);
574 m_log << TestLog::EndSection;
576 ES3F_ADD_API_CASE(copyteximage2d_neg_level, "Invalid glCopyTexImage2D() usage",
578 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
579 glCopyTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 0, 0, 64, 64, 0);
580 expectError(GL_INVALID_VALUE);
581 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
582 expectError(GL_INVALID_VALUE);
583 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
584 expectError(GL_INVALID_VALUE);
585 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
586 expectError(GL_INVALID_VALUE);
587 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
588 expectError(GL_INVALID_VALUE);
589 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
590 expectError(GL_INVALID_VALUE);
591 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
592 expectError(GL_INVALID_VALUE);
593 m_log << TestLog::EndSection;
595 ES3F_ADD_API_CASE(copyteximage2d_max_level, "Invalid glCopyTexImage2D() usage",
597 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
598 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
599 glCopyTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 0, 0, 64, 64, 0);
600 expectError(GL_INVALID_VALUE);
601 m_log << TestLog::EndSection;
603 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
604 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
605 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
606 expectError(GL_INVALID_VALUE);
607 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
608 expectError(GL_INVALID_VALUE);
609 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
610 expectError(GL_INVALID_VALUE);
611 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
612 expectError(GL_INVALID_VALUE);
613 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
614 expectError(GL_INVALID_VALUE);
615 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
616 expectError(GL_INVALID_VALUE);
617 m_log << TestLog::EndSection;
619 ES3F_ADD_API_CASE(copyteximage2d_neg_width_height, "Invalid glCopyTexImage2D() usage",
621 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
623 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
624 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, 1, 0);
625 expectError(GL_INVALID_VALUE);
626 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, -1, 0);
627 expectError(GL_INVALID_VALUE);
628 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, -1, 0);
629 expectError(GL_INVALID_VALUE);
630 m_log << TestLog::EndSection;
632 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
633 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
634 expectError(GL_INVALID_VALUE);
635 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
636 expectError(GL_INVALID_VALUE);
637 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
638 expectError(GL_INVALID_VALUE);
639 m_log << TestLog::EndSection;
641 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
642 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
643 expectError(GL_INVALID_VALUE);
644 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
645 expectError(GL_INVALID_VALUE);
646 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
647 expectError(GL_INVALID_VALUE);
648 m_log << TestLog::EndSection;
650 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
651 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
652 expectError(GL_INVALID_VALUE);
653 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
654 expectError(GL_INVALID_VALUE);
655 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
656 expectError(GL_INVALID_VALUE);
657 m_log << TestLog::EndSection;
659 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
660 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
661 expectError(GL_INVALID_VALUE);
662 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
663 expectError(GL_INVALID_VALUE);
664 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
665 expectError(GL_INVALID_VALUE);
666 m_log << TestLog::EndSection;
668 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
669 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
670 expectError(GL_INVALID_VALUE);
671 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
672 expectError(GL_INVALID_VALUE);
673 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
674 expectError(GL_INVALID_VALUE);
675 m_log << TestLog::EndSection;
677 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
678 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
679 expectError(GL_INVALID_VALUE);
680 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
681 expectError(GL_INVALID_VALUE);
682 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
683 expectError(GL_INVALID_VALUE);
684 m_log << TestLog::EndSection;
686 m_log << TestLog::EndSection;
688 ES3F_ADD_API_CASE(copyteximage2d_max_width_height, "Invalid glCopyTexImage2D() usage",
690 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
691 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
693 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
695 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
696 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
697 expectError(GL_INVALID_VALUE);
698 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
699 expectError(GL_INVALID_VALUE);
700 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
701 expectError(GL_INVALID_VALUE);
702 m_log << TestLog::EndSection;
704 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
705 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
706 expectError(GL_INVALID_VALUE);
707 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
708 expectError(GL_INVALID_VALUE);
709 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
710 expectError(GL_INVALID_VALUE);
711 m_log << TestLog::EndSection;
713 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
714 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
715 expectError(GL_INVALID_VALUE);
716 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
717 expectError(GL_INVALID_VALUE);
718 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
719 expectError(GL_INVALID_VALUE);
720 m_log << TestLog::EndSection;
722 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
723 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
724 expectError(GL_INVALID_VALUE);
725 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
726 expectError(GL_INVALID_VALUE);
727 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
728 expectError(GL_INVALID_VALUE);
729 m_log << TestLog::EndSection;
731 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
732 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
733 expectError(GL_INVALID_VALUE);
734 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
735 expectError(GL_INVALID_VALUE);
736 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
737 expectError(GL_INVALID_VALUE);
738 m_log << TestLog::EndSection;
740 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
741 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
742 expectError(GL_INVALID_VALUE);
743 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
744 expectError(GL_INVALID_VALUE);
745 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
746 expectError(GL_INVALID_VALUE);
747 m_log << TestLog::EndSection;
749 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
750 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
751 expectError(GL_INVALID_VALUE);
752 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
753 expectError(GL_INVALID_VALUE);
754 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
755 expectError(GL_INVALID_VALUE);
756 m_log << TestLog::EndSection;
758 m_log << TestLog::EndSection;
760 ES3F_ADD_API_CASE(copyteximage2d_invalid_border, "Invalid glCopyTexImage2D() usage",
762 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
764 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
765 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, -1);
766 expectError(GL_INVALID_VALUE);
767 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, 1);
768 expectError(GL_INVALID_VALUE);
769 m_log << TestLog::EndSection;
771 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
772 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
773 expectError(GL_INVALID_VALUE);
774 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
775 expectError(GL_INVALID_VALUE);
776 m_log << TestLog::EndSection;
778 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
779 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
780 expectError(GL_INVALID_VALUE);
781 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
782 expectError(GL_INVALID_VALUE);
783 m_log << TestLog::EndSection;
785 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
786 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
787 expectError(GL_INVALID_VALUE);
788 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
789 expectError(GL_INVALID_VALUE);
790 m_log << TestLog::EndSection;
792 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
793 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
794 expectError(GL_INVALID_VALUE);
795 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
796 expectError(GL_INVALID_VALUE);
797 m_log << TestLog::EndSection;
799 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
800 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
801 expectError(GL_INVALID_VALUE);
802 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
803 expectError(GL_INVALID_VALUE);
804 m_log << TestLog::EndSection;
806 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
807 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
808 expectError(GL_INVALID_VALUE);
809 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
810 expectError(GL_INVALID_VALUE);
811 m_log << TestLog::EndSection;
813 m_log << TestLog::EndSection;
815 ES3F_ADD_API_CASE(copyteximage2d_incomplete_framebuffer, "Invalid glCopyTexImage2D() usage",
818 glGenFramebuffers (1, &fbo);
819 glBindFramebuffer (GL_FRAMEBUFFER, fbo);
820 glCheckFramebufferStatus(GL_FRAMEBUFFER);
822 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
823 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, 0, 0);
824 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
825 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
826 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
827 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
828 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
829 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
830 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
831 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
832 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
833 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
834 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
835 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
836 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
837 m_log << tcu::TestLog::EndSection;
839 glBindFramebuffer (GL_FRAMEBUFFER, 0);
840 glDeleteFramebuffers(1, &fbo);
843 // glCopyTexSubImage2D
845 ES3F_ADD_API_CASE(copytexsubimage2d_invalid_target, "Invalid glCopyTexSubImage2D() usage",
848 glGenTextures (1, &texture);
849 glBindTexture (GL_TEXTURE_2D, texture);
850 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
852 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
853 glCopyTexSubImage2D(0, 0, 0, 0, 0, 0, 4, 4);
854 expectError(GL_INVALID_ENUM);
855 m_log << TestLog::EndSection;
857 glDeleteTextures(1, &texture);
859 ES3F_ADD_API_CASE(copytexsubimage2d_neg_level, "Invalid glCopyTexSubImage2D() usage",
862 glGenTextures (2, &textures[0]);
863 glBindTexture (GL_TEXTURE_2D, textures[0]);
864 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
865 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
866 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
868 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
869 glCopyTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, 4, 4);
870 expectError(GL_INVALID_VALUE);
871 FOR_CUBE_FACES(faceGL,
873 glCopyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4);
874 expectError(GL_INVALID_VALUE);
876 m_log << TestLog::EndSection;
878 glDeleteTextures(2, &textures[0]);
880 ES3F_ADD_API_CASE(copytexsubimage2d_max_level, "Invalid glCopyTexSubImage2D() usage",
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););
889 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for 2D texture targets.");
890 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
891 glCopyTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 4, 4);
892 expectError(GL_INVALID_VALUE);
893 m_log << TestLog::EndSection;
895 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_SIZE) for cubemap targets.");
896 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
897 FOR_CUBE_FACES(faceGL,
899 glCopyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4);
900 expectError(GL_INVALID_VALUE);
902 m_log << TestLog::EndSection;
904 glDeleteTextures(2, &textures[0]);
906 ES3F_ADD_API_CASE(copytexsubimage2d_neg_offset, "Invalid glCopyTexSubImage2D() usage",
909 glGenTextures (1, &texture);
910 glBindTexture (GL_TEXTURE_2D, texture);
911 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
913 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.");
914 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, 4, 4);
915 expectError(GL_INVALID_VALUE);
916 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, 4, 4);
917 expectError(GL_INVALID_VALUE);
918 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, 4, 4);
919 expectError(GL_INVALID_VALUE);
920 m_log << TestLog::EndSection;
922 glDeleteTextures(1, &texture);
924 ES3F_ADD_API_CASE(copytexsubimage2d_invalid_offset, "Invalid glCopyTexSubImage2D() usage",
927 glGenTextures (1, &texture);
928 glBindTexture (GL_TEXTURE_2D, texture);
929 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
931 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
932 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 0, 0, 0, 4, 4);
933 expectError(GL_INVALID_VALUE);
934 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 14, 0, 0, 4, 4);
935 expectError(GL_INVALID_VALUE);
936 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 14, 0, 0, 4, 4);
937 expectError(GL_INVALID_VALUE);
938 m_log << TestLog::EndSection;
940 glDeleteTextures(1, &texture);
942 ES3F_ADD_API_CASE(copytexsubimage2d_neg_width_height, "Invalid glCopyTexSubImage2D() usage",
945 glGenTextures (1, &texture);
946 glBindTexture (GL_TEXTURE_2D, texture);
947 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
949 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
950 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0);
951 expectError(GL_INVALID_VALUE);
952 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1);
953 expectError(GL_INVALID_VALUE);
954 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1);
955 expectError(GL_INVALID_VALUE);
956 m_log << TestLog::EndSection;
958 glDeleteTextures(1, &texture);
960 ES3F_ADD_API_CASE(copytexsubimage2d_incomplete_framebuffer, "Invalid glCopyTexSubImage2D() usage",
962 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
967 glGenTextures (2, texture);
968 glBindTexture (GL_TEXTURE_2D, texture[0]);
969 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
970 glBindTexture (GL_TEXTURE_CUBE_MAP, texture[1]);
971 glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
972 glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
973 glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
974 glTexImage2D (GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
975 glTexImage2D (GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
976 glTexImage2D (GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
977 expectError(GL_NO_ERROR);
979 glGenFramebuffers(1, &fbo);
980 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
981 glCheckFramebufferStatus(GL_FRAMEBUFFER);
982 expectError(GL_NO_ERROR);
984 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
985 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
986 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
987 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
988 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
989 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
990 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
991 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
992 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
993 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
994 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
995 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
996 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
997 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
999 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1000 glDeleteFramebuffers(1, &fbo);
1001 glDeleteTextures(2, texture);
1003 m_log << tcu::TestLog::EndSection;
1008 ES3F_ADD_API_CASE(deletetextures, "Invalid glDeleteTextures() usage",
1011 glGenTextures(1, &texture);
1013 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1014 glDeleteTextures(-1, 0);
1015 expectError(GL_INVALID_VALUE);
1017 glBindTexture(GL_TEXTURE_2D, texture);
1018 glDeleteTextures(-1, 0);
1019 expectError(GL_INVALID_VALUE);
1020 m_log << TestLog::EndSection;
1022 glDeleteTextures(1, &texture);
1027 ES3F_ADD_API_CASE(generatemipmap, "Invalid glGenerateMipmap() usage",
1030 glGenTextures(2, texture);
1032 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.");
1033 glGenerateMipmap(0);
1034 expectError(GL_INVALID_ENUM);
1035 m_log << TestLog::EndSection;
1037 m_log << TestLog::Section("", "INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
1038 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1039 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
1040 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1041 glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1042 expectError(GL_INVALID_OPERATION);
1044 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1045 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1046 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1047 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1048 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1049 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1050 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1051 glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1052 expectError(GL_INVALID_OPERATION);
1053 m_log << TestLog::EndSection;
1055 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
1056 glBindTexture(GL_TEXTURE_2D, texture[1]);
1057 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1058 glGenerateMipmap(GL_TEXTURE_2D);
1059 expectError(GL_INVALID_OPERATION);
1060 m_log << TestLog::EndSection;
1062 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the level base array was not specified with an unsized internal format or a sized internal format that is both color-renderable and texture-filterable.");
1063 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 0, 0, 0, GL_RGB, GL_BYTE, 0);
1064 glGenerateMipmap(GL_TEXTURE_2D);
1065 expectError(GL_INVALID_OPERATION);
1066 glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, 0);
1067 glGenerateMipmap(GL_TEXTURE_2D);
1068 expectError(GL_INVALID_OPERATION);
1070 if (!(m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") && m_context.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
1072 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
1073 glGenerateMipmap(GL_TEXTURE_2D);
1074 expectError(GL_INVALID_OPERATION);
1077 m_log << TestLog::EndSection;
1079 glDeleteTextures(2, texture);
1084 ES3F_ADD_API_CASE(gentextures, "Invalid glGenTextures() usage",
1086 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1087 glGenTextures(-1, 0);
1088 expectError(GL_INVALID_VALUE);
1089 m_log << TestLog::EndSection;
1094 ES3F_ADD_API_CASE(pixelstorei, "Invalid glPixelStorei() usage",
1096 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1098 expectError(GL_INVALID_ENUM);
1099 m_log << TestLog::EndSection;
1101 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if a negative row length, pixel skip, or row skip value is specified, or if alignment is specified as other than 1, 2, 4, or 8.");
1102 glPixelStorei(GL_PACK_ROW_LENGTH, -1);
1103 expectError(GL_INVALID_VALUE);
1104 glPixelStorei(GL_PACK_SKIP_ROWS, -1);
1105 expectError(GL_INVALID_VALUE);
1106 glPixelStorei(GL_PACK_SKIP_PIXELS, -1);
1107 expectError(GL_INVALID_VALUE);
1108 glPixelStorei(GL_UNPACK_ROW_LENGTH, -1);
1109 expectError(GL_INVALID_VALUE);
1110 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, -1);
1111 expectError(GL_INVALID_VALUE);
1112 glPixelStorei(GL_UNPACK_SKIP_ROWS, -1);
1113 expectError(GL_INVALID_VALUE);
1114 glPixelStorei(GL_UNPACK_SKIP_PIXELS, -1);
1115 expectError(GL_INVALID_VALUE);
1116 glPixelStorei(GL_UNPACK_SKIP_IMAGES, -1);
1117 expectError(GL_INVALID_VALUE);
1118 glPixelStorei(GL_PACK_ALIGNMENT, 0);
1119 expectError(GL_INVALID_VALUE);
1120 glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
1121 expectError(GL_INVALID_VALUE);
1122 glPixelStorei(GL_PACK_ALIGNMENT, 16);
1123 expectError(GL_INVALID_VALUE);
1124 glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
1125 expectError(GL_INVALID_VALUE);
1126 m_log << TestLog::EndSection;
1131 ES3F_ADD_API_CASE(teximage2d, "Invalid glTexImage2D() usage",
1133 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1134 glTexImage2D(0, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1135 expectError(GL_INVALID_ENUM);
1136 m_log << TestLog::EndSection;
1138 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1139 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 0, 0);
1140 expectError(GL_INVALID_ENUM);
1141 m_log << TestLog::EndSection;
1143 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
1144 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1145 expectError(GL_INVALID_OPERATION);
1146 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1147 expectError(GL_INVALID_OPERATION);
1148 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1149 expectError(GL_INVALID_OPERATION);
1150 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
1151 expectError(GL_INVALID_OPERATION);
1152 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
1153 expectError(GL_INVALID_OPERATION);
1154 m_log << TestLog::EndSection;
1156 ES3F_ADD_API_CASE(teximage2d_inequal_width_height_cube, "Invalid glTexImage2D() usage",
1158 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is one of the six cube map 2D image targets and the width and height parameters are not equal.");
1159 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1160 expectError(GL_INVALID_VALUE);
1161 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1162 expectError(GL_INVALID_VALUE);
1163 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1164 expectError(GL_INVALID_VALUE);
1165 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1166 expectError(GL_INVALID_VALUE);
1167 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1168 expectError(GL_INVALID_VALUE);
1169 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1170 expectError(GL_INVALID_VALUE);
1171 m_log << TestLog::EndSection;
1173 ES3F_ADD_API_CASE(teximage2d_neg_level, "Invalid glTexImage2D() usage",
1175 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1176 glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1177 expectError(GL_INVALID_VALUE);
1178 m_log << TestLog::EndSection;
1180 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1181 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1182 expectError(GL_INVALID_VALUE);
1183 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1184 expectError(GL_INVALID_VALUE);
1185 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1186 expectError(GL_INVALID_VALUE);
1187 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1188 expectError(GL_INVALID_VALUE);
1189 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1190 expectError(GL_INVALID_VALUE);
1191 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1192 expectError(GL_INVALID_VALUE);
1193 m_log << TestLog::EndSection;
1195 ES3F_ADD_API_CASE(teximage2d_max_level, "Invalid glTexImage2D() usage",
1197 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1198 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1199 glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1200 expectError(GL_INVALID_VALUE);
1201 m_log << TestLog::EndSection;
1203 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1204 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1205 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1206 expectError(GL_INVALID_VALUE);
1207 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1208 expectError(GL_INVALID_VALUE);
1209 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1210 expectError(GL_INVALID_VALUE);
1211 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1212 expectError(GL_INVALID_VALUE);
1213 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1214 expectError(GL_INVALID_VALUE);
1215 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1216 expectError(GL_INVALID_VALUE);
1217 m_log << TestLog::EndSection;
1219 ES3F_ADD_API_CASE(teximage2d_neg_width_height, "Invalid glTexImage2D() usage",
1221 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1223 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
1224 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1225 expectError(GL_INVALID_VALUE);
1226 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1227 expectError(GL_INVALID_VALUE);
1228 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1229 expectError(GL_INVALID_VALUE);
1230 m_log << TestLog::EndSection;
1232 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1233 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1234 expectError(GL_INVALID_VALUE);
1235 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1236 expectError(GL_INVALID_VALUE);
1237 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1238 expectError(GL_INVALID_VALUE);
1239 m_log << TestLog::EndSection;
1241 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1242 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1243 expectError(GL_INVALID_VALUE);
1244 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1245 expectError(GL_INVALID_VALUE);
1246 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1247 expectError(GL_INVALID_VALUE);
1248 m_log << TestLog::EndSection;
1250 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1251 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1252 expectError(GL_INVALID_VALUE);
1253 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1254 expectError(GL_INVALID_VALUE);
1255 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1256 expectError(GL_INVALID_VALUE);
1257 m_log << TestLog::EndSection;
1259 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1260 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1261 expectError(GL_INVALID_VALUE);
1262 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1263 expectError(GL_INVALID_VALUE);
1264 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1265 expectError(GL_INVALID_VALUE);
1266 m_log << TestLog::EndSection;
1268 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1269 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1270 expectError(GL_INVALID_VALUE);
1271 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1272 expectError(GL_INVALID_VALUE);
1273 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1274 expectError(GL_INVALID_VALUE);
1275 m_log << TestLog::EndSection;
1277 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1278 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1279 expectError(GL_INVALID_VALUE);
1280 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1281 expectError(GL_INVALID_VALUE);
1282 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1283 expectError(GL_INVALID_VALUE);
1284 m_log << TestLog::EndSection;
1286 m_log << TestLog::EndSection;
1288 ES3F_ADD_API_CASE(teximage2d_max_width_height, "Invalid glTexImage2D() usage",
1290 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
1291 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1293 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
1294 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1295 expectError(GL_INVALID_VALUE);
1296 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1297 expectError(GL_INVALID_VALUE);
1298 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1299 expectError(GL_INVALID_VALUE);
1300 m_log << TestLog::EndSection;
1302 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1304 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1305 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1306 expectError(GL_INVALID_VALUE);
1307 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1308 expectError(GL_INVALID_VALUE);
1309 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1310 expectError(GL_INVALID_VALUE);
1311 m_log << TestLog::EndSection;
1313 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1314 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1315 expectError(GL_INVALID_VALUE);
1316 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1317 expectError(GL_INVALID_VALUE);
1318 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1319 expectError(GL_INVALID_VALUE);
1320 m_log << TestLog::EndSection;
1322 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1323 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1324 expectError(GL_INVALID_VALUE);
1325 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1326 expectError(GL_INVALID_VALUE);
1327 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1328 expectError(GL_INVALID_VALUE);
1329 m_log << TestLog::EndSection;
1331 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1332 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1333 expectError(GL_INVALID_VALUE);
1334 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1335 expectError(GL_INVALID_VALUE);
1336 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1337 expectError(GL_INVALID_VALUE);
1338 m_log << TestLog::EndSection;
1340 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1341 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1342 expectError(GL_INVALID_VALUE);
1343 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1344 expectError(GL_INVALID_VALUE);
1345 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1346 expectError(GL_INVALID_VALUE);
1347 m_log << TestLog::EndSection;
1349 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1350 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1351 expectError(GL_INVALID_VALUE);
1352 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1353 expectError(GL_INVALID_VALUE);
1354 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1355 expectError(GL_INVALID_VALUE);
1356 m_log << TestLog::EndSection;
1358 m_log << TestLog::EndSection;
1360 ES3F_ADD_API_CASE(teximage2d_invalid_border, "Invalid glTexImage2D() usage",
1362 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
1363 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1364 expectError(GL_INVALID_VALUE);
1365 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1366 expectError(GL_INVALID_VALUE);
1367 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1368 expectError(GL_INVALID_VALUE);
1369 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1370 expectError(GL_INVALID_VALUE);
1371 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1372 expectError(GL_INVALID_VALUE);
1373 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1374 expectError(GL_INVALID_VALUE);
1375 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1376 expectError(GL_INVALID_VALUE);
1377 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1378 expectError(GL_INVALID_VALUE);
1379 m_log << TestLog::EndSection;
1381 ES3F_ADD_API_CASE(teximage2d_invalid_buffer_target, "Invalid glTexImage2D() usage",
1385 std::vector<GLubyte> data(64);
1387 glGenBuffers (1, &buf);
1388 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
1389 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1390 glGenTextures (1, &texture);
1391 glBindTexture (GL_TEXTURE_2D, texture);
1392 expectError (GL_NO_ERROR);
1394 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
1395 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1396 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1397 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1398 expectError (GL_INVALID_OPERATION);
1399 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
1400 m_log << TestLog::EndSection;
1402 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
1403 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1404 expectError (GL_INVALID_OPERATION);
1405 m_log << TestLog::EndSection;
1407 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1408 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1409 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB5_A1, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
1410 expectError (GL_INVALID_OPERATION);
1411 m_log << TestLog::EndSection;
1412 m_log << TestLog::EndSection;
1414 glDeleteBuffers (1, &buf);
1415 glDeleteTextures (1, &texture);
1420 ES3F_ADD_API_CASE(texsubimage2d, "Invalid glTexSubImage2D() usage",
1423 glGenTextures (1, &texture);
1424 glBindTexture (GL_TEXTURE_2D, texture);
1425 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1426 expectError (GL_NO_ERROR);
1428 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1429 glTexSubImage2D(0, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1430 expectError(GL_INVALID_ENUM);
1431 m_log << TestLog::EndSection;
1433 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
1434 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, GL_UNSIGNED_BYTE, 0);
1435 expectError(GL_INVALID_ENUM);
1436 m_log << TestLog::EndSection;
1438 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1439 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, 0, 0);
1440 expectError(GL_INVALID_ENUM);
1441 m_log << TestLog::EndSection;
1443 m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.");
1444 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
1445 expectError(GL_INVALID_OPERATION);
1446 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1447 expectError(GL_INVALID_OPERATION);
1448 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1449 expectError(GL_INVALID_OPERATION);
1450 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1451 expectError(GL_INVALID_OPERATION);
1452 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
1453 expectError(GL_INVALID_OPERATION);
1454 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_FLOAT, 0);
1455 expectError(GL_INVALID_OPERATION);
1456 m_log << tcu::TestLog::EndSection;
1458 glDeleteTextures (1, &texture);
1460 ES3F_ADD_API_CASE(texsubimage2d_neg_level, "Invalid glTexSubImage2D() usage",
1462 deUint32 textures[2];
1463 glGenTextures (2, &textures[0]);
1464 glBindTexture (GL_TEXTURE_2D, textures[0]);
1465 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1466 glBindTexture (GL_TEXTURE_2D, textures[1]);
1467 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1468 expectError (GL_NO_ERROR);
1470 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1471 glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1472 expectError(GL_INVALID_VALUE);
1473 m_log << TestLog::EndSection;
1475 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1476 FOR_CUBE_FACES(faceGL,
1478 glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1479 expectError(GL_INVALID_VALUE);
1481 m_log << TestLog::EndSection;
1483 glDeleteTextures(2, &textures[0]);
1485 ES3F_ADD_API_CASE(texsubimage2d_max_level, "Invalid glTexSubImage2D() usage",
1487 deUint32 textures[2];
1488 glGenTextures (2, &textures[0]);
1489 glBindTexture (GL_TEXTURE_2D, textures[0]);
1490 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1491 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
1492 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1493 expectError (GL_NO_ERROR);
1495 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1496 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1497 glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1498 expectError(GL_INVALID_VALUE);
1499 m_log << TestLog::EndSection;
1501 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1502 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1503 FOR_CUBE_FACES(faceGL,
1505 glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1506 expectError(GL_INVALID_VALUE);
1508 m_log << TestLog::EndSection;
1510 glDeleteTextures(2, &textures[0]);
1512 ES3F_ADD_API_CASE(texsubimage2d_neg_offset, "Invalid glTexSubImage2D() usage",
1515 glGenTextures(1, &texture);
1516 glBindTexture(GL_TEXTURE_2D, texture);
1517 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1518 expectError(GL_NO_ERROR);
1520 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
1521 glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1522 expectError(GL_INVALID_VALUE);
1523 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1524 expectError(GL_INVALID_VALUE);
1525 glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1526 expectError(GL_INVALID_VALUE);
1527 m_log << TestLog::EndSection;
1529 glDeleteTextures(1, &texture);
1531 ES3F_ADD_API_CASE(texsubimage2d_invalid_offset, "Invalid glTexSubImage2D() usage",
1534 glGenTextures (1, &texture);
1535 glBindTexture (GL_TEXTURE_2D, texture);
1536 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1537 expectError (GL_NO_ERROR);
1539 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1540 glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1541 expectError(GL_INVALID_VALUE);
1542 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1543 expectError(GL_INVALID_VALUE);
1544 glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1545 expectError(GL_INVALID_VALUE);
1546 m_log << TestLog::EndSection;
1548 glDeleteTextures (1, &texture);
1550 ES3F_ADD_API_CASE(texsubimage2d_neg_width_height, "Invalid glTexSubImage2D() usage",
1553 glGenTextures (1, &texture);
1554 glBindTexture (GL_TEXTURE_2D, texture);
1555 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1556 expectError (GL_NO_ERROR);
1558 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1559 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1560 expectError(GL_INVALID_VALUE);
1561 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1562 expectError(GL_INVALID_VALUE);
1563 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1564 expectError(GL_INVALID_VALUE);
1565 m_log << TestLog::EndSection;
1567 glDeleteTextures (1, &texture);
1569 ES3F_ADD_API_CASE(texsubimage2d_invalid_buffer_target, "Invalid glTexSubImage2D() usage",
1573 std::vector<GLubyte> data(64);
1575 glGenTextures (1, &texture);
1576 glBindTexture (GL_TEXTURE_2D, texture);
1577 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1578 glGenBuffers (1, &buf);
1579 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
1580 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1581 expectError (GL_NO_ERROR);
1583 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
1584 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1585 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1586 glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1587 expectError (GL_INVALID_OPERATION);
1588 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
1589 m_log << TestLog::EndSection;
1591 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
1592 glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1593 expectError (GL_INVALID_OPERATION);
1594 m_log << TestLog::EndSection;
1596 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1597 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1598 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
1599 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1600 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
1601 expectError (GL_NO_ERROR);
1602 glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
1603 expectError (GL_INVALID_OPERATION);
1604 m_log << TestLog::EndSection;
1605 m_log << TestLog::EndSection;
1607 glDeleteBuffers (1, &buf);
1608 glDeleteTextures (1, &texture);
1613 ES3F_ADD_API_CASE(texparameteri, "Invalid glTexParameteri() usage",
1615 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1616 glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1617 expectError(GL_INVALID_ENUM);
1618 glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1619 expectError(GL_INVALID_ENUM);
1620 glTexParameteri(0, 0, GL_LINEAR);
1621 expectError(GL_INVALID_ENUM);
1622 m_log << TestLog::EndSection;
1624 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1625 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1626 expectError(GL_INVALID_ENUM);
1627 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1628 expectError(GL_INVALID_ENUM);
1629 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1630 expectError(GL_INVALID_ENUM);
1631 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1632 expectError(GL_INVALID_ENUM);
1633 m_log << TestLog::EndSection;
1636 glGenTextures(1, &texture);
1637 glBindTexture(GL_TEXTURE_2D, texture);
1639 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1640 glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1641 expectError(GL_INVALID_ENUM);
1642 glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1643 expectError(GL_INVALID_ENUM);
1644 glTexParameteri(0, 0, GL_LINEAR);
1645 expectError(GL_INVALID_ENUM);
1646 m_log << TestLog::EndSection;
1648 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1649 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1650 expectError(GL_INVALID_ENUM);
1651 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1652 expectError(GL_INVALID_ENUM);
1653 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1654 expectError(GL_INVALID_ENUM);
1655 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1656 expectError(GL_INVALID_ENUM);
1657 m_log << TestLog::EndSection;
1659 glDeleteTextures(1, &texture);
1664 ES3F_ADD_API_CASE(texparameterf, "Invalid glTexParameterf() usage",
1666 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1667 glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1668 expectError(GL_INVALID_ENUM);
1669 glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1670 expectError(GL_INVALID_ENUM);
1671 glTexParameterf(0, 0, GL_LINEAR);
1672 expectError(GL_INVALID_ENUM);
1673 m_log << TestLog::EndSection;
1675 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1676 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1677 expectError(GL_INVALID_ENUM);
1678 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1679 expectError(GL_INVALID_ENUM);
1680 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1681 expectError(GL_INVALID_ENUM);
1682 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1683 expectError(GL_INVALID_ENUM);
1684 m_log << TestLog::EndSection;
1687 glGenTextures(1, &texture);
1688 glBindTexture(GL_TEXTURE_2D, texture);
1690 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1691 glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1692 expectError(GL_INVALID_ENUM);
1693 glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1694 expectError(GL_INVALID_ENUM);
1695 glTexParameterf(0, 0, GL_LINEAR);
1696 expectError(GL_INVALID_ENUM);
1697 m_log << TestLog::EndSection;
1699 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1700 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1701 expectError(GL_INVALID_ENUM);
1702 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1703 expectError(GL_INVALID_ENUM);
1704 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1705 expectError(GL_INVALID_ENUM);
1706 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1707 expectError(GL_INVALID_ENUM);
1708 m_log << TestLog::EndSection;
1710 glDeleteTextures(1, &texture);
1715 ES3F_ADD_API_CASE(texparameteriv, "Invalid glTexParameteriv() usage",
1717 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1718 GLint params[1] = {GL_LINEAR};
1719 glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1720 expectError(GL_INVALID_ENUM);
1721 glTexParameteriv(GL_TEXTURE_2D, 0, ¶ms[0]);
1722 expectError(GL_INVALID_ENUM);
1723 glTexParameteriv(0, 0, ¶ms[0]);
1724 expectError(GL_INVALID_ENUM);
1725 m_log << TestLog::EndSection;
1727 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1729 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1730 expectError(GL_INVALID_ENUM);
1731 params[0] = GL_REPEAT;
1732 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1733 expectError(GL_INVALID_ENUM);
1735 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1736 expectError(GL_INVALID_ENUM);
1737 params[0] = GL_NEAREST;
1738 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1739 expectError(GL_INVALID_ENUM);
1740 m_log << TestLog::EndSection;
1743 glGenTextures(1, &texture);
1744 glBindTexture(GL_TEXTURE_2D, texture);
1746 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1747 params[0] = GL_LINEAR;
1748 glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1749 expectError(GL_INVALID_ENUM);
1750 glTexParameteriv(GL_TEXTURE_2D, 0, ¶ms[0]);
1751 expectError(GL_INVALID_ENUM);
1752 glTexParameteriv(0, 0, ¶ms[0]);
1753 expectError(GL_INVALID_ENUM);
1754 m_log << TestLog::EndSection;
1756 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1758 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1759 expectError(GL_INVALID_ENUM);
1760 params[0] = GL_REPEAT;
1761 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1762 expectError(GL_INVALID_ENUM);
1764 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1765 expectError(GL_INVALID_ENUM);
1766 params[0] = GL_NEAREST;
1767 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1768 expectError(GL_INVALID_ENUM);
1769 m_log << TestLog::EndSection;
1771 glDeleteTextures(1, &texture);
1776 ES3F_ADD_API_CASE(texparameterfv, "Invalid glTexParameterfv() usage",
1778 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1779 GLfloat params[1] = {GL_LINEAR};
1780 glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1781 expectError(GL_INVALID_ENUM);
1782 glTexParameterfv(GL_TEXTURE_2D, 0, ¶ms[0]);
1783 expectError(GL_INVALID_ENUM);
1784 glTexParameterfv(0, 0, ¶ms[0]);
1785 expectError(GL_INVALID_ENUM);
1786 m_log << TestLog::EndSection;
1788 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1790 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1791 expectError(GL_INVALID_ENUM);
1792 params[0] = GL_REPEAT;
1793 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1794 expectError(GL_INVALID_ENUM);
1796 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1797 expectError(GL_INVALID_ENUM);
1798 params[0] = GL_NEAREST;
1799 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1800 expectError(GL_INVALID_ENUM);
1801 m_log << TestLog::EndSection;
1804 glGenTextures(1, &texture);
1805 glBindTexture(GL_TEXTURE_2D, texture);
1807 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1808 params[0] = GL_LINEAR;
1809 glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1810 expectError(GL_INVALID_ENUM);
1811 glTexParameterfv(GL_TEXTURE_2D, 0, ¶ms[0]);
1812 expectError(GL_INVALID_ENUM);
1813 glTexParameterfv(0, 0, ¶ms[0]);
1814 expectError(GL_INVALID_ENUM);
1815 m_log << TestLog::EndSection;
1817 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1819 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1820 expectError(GL_INVALID_ENUM);
1821 params[0] = GL_REPEAT;
1822 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1823 expectError(GL_INVALID_ENUM);
1825 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1826 expectError(GL_INVALID_ENUM);
1827 params[0] = GL_NEAREST;
1828 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1829 expectError(GL_INVALID_ENUM);
1830 m_log << TestLog::EndSection;
1832 glDeleteTextures(1, &texture);
1835 // glCompressedTexSubImage2D
1837 ES3F_ADD_API_CASE(compressedtexsubimage2d, "Invalid glCompressedTexSubImage2D() usage",
1839 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1840 glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1841 expectError(GL_INVALID_ENUM);
1842 m_log << TestLog::EndSection;
1845 glGenTextures (1, &texture);
1846 glBindTexture (GL_TEXTURE_2D, texture);
1847 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1848 expectError (GL_NO_ERROR);
1850 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
1851 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1852 expectError(GL_INVALID_OPERATION);
1853 m_log << TestLog::EndSection;
1855 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if width is not a multiple of four, and width + xoffset is not equal to the width of the texture level.");
1856 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 4, 0, 10, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
1857 expectError(GL_INVALID_OPERATION);
1858 m_log << TestLog::EndSection;
1860 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if height is not a multiple of four, and height + yoffset is not equal to the height of the texture level.");
1861 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 4, 4, 10, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
1862 expectError(GL_INVALID_OPERATION);
1863 m_log << TestLog::EndSection;
1865 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
1866 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1867 expectError(GL_INVALID_OPERATION);
1868 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1869 expectError(GL_INVALID_OPERATION);
1870 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1871 expectError(GL_INVALID_OPERATION);
1872 m_log << TestLog::EndSection;
1874 glDeleteTextures (1, &texture);
1876 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_level, "Invalid glCompressedTexSubImage2D() usage",
1878 deUint32 textures[2];
1879 glGenTextures (2, &textures[0]);
1880 glBindTexture (GL_TEXTURE_2D, textures[0]);
1881 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1882 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
1883 FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
1884 expectError (GL_NO_ERROR);
1886 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1887 glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1888 expectError(GL_INVALID_VALUE);
1889 m_log << TestLog::EndSection;
1891 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1892 FOR_CUBE_FACES(faceGL,
1894 glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1895 expectError(GL_INVALID_VALUE);
1897 m_log << TestLog::EndSection;
1899 glDeleteTextures(2, &textures[0]);
1901 ES3F_ADD_API_CASE(compressedtexsubimage2d_max_level, "Invalid glCompressedTexSubImage2D() usage",
1903 deUint32 textures[2];
1904 glGenTextures (2, &textures[0]);
1905 glBindTexture (GL_TEXTURE_2D, textures[0]);
1906 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1907 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
1908 FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
1909 expectError (GL_NO_ERROR);
1911 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1912 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1913 glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1914 expectError(GL_INVALID_VALUE);
1915 m_log << TestLog::EndSection;
1917 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1918 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1919 FOR_CUBE_FACES(faceGL,
1921 glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1922 expectError(GL_INVALID_VALUE);
1924 m_log << TestLog::EndSection;
1926 glDeleteTextures(2, &textures[0]);
1928 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_offset, "Invalid glCompressedTexSubImage2D() usage",
1931 glGenTextures(1, &texture);
1932 glBindTexture(GL_TEXTURE_2D, texture);
1933 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, etc2EacDataSize(8, 8), 0);
1935 // \note Both GL_INVALID_VALUE and GL_INVALID_OPERATION are valid here since implementation may
1936 // first check if offsets are valid for certain format and only after that check that they
1937 // are not negative.
1938 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset or yoffset are negative.");
1940 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1941 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1942 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1943 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1944 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1945 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1947 m_log << TestLog::EndSection;
1949 glDeleteTextures(1, &texture);
1951 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_offset, "Invalid glCompressedTexSubImage2D() usage",
1954 glGenTextures (1, &texture);
1955 glBindTexture (GL_TEXTURE_2D, texture);
1956 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1957 expectError (GL_NO_ERROR);
1959 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1961 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 0, 8, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
1962 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1963 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 12, 4, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
1964 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1965 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 12, 8, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
1966 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1967 m_log << TestLog::EndSection;
1969 glDeleteTextures (1, &texture);
1971 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_width_height, "Invalid glCompressedTexSubImage2D() usage",
1974 glGenTextures (1, &texture);
1975 glBindTexture (GL_TEXTURE_2D, texture);
1976 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1977 expectError (GL_NO_ERROR);
1979 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width or height is less than 0.");
1980 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1981 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1982 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1983 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1984 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1985 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1986 m_log << TestLog::EndSection;
1988 glDeleteTextures(1, &texture);
1990 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
1993 glGenTextures (1, &texture);
1994 glBindTexture (GL_TEXTURE_2D, texture);
1995 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1996 expectError (GL_NO_ERROR);
1998 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
1999 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2000 expectError(GL_INVALID_VALUE);
2002 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2003 expectError(GL_INVALID_VALUE);
2004 m_log << TestLog::EndSection;
2006 glDeleteTextures (1, &texture);
2008 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_buffer_target, "Invalid glCompressedTexSubImage2D() usage",
2012 std::vector<GLubyte> data(128);
2014 glGenTextures (1, &texture);
2015 glBindTexture (GL_TEXTURE_2D, texture);
2016 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2017 glGenBuffers (1, &buf);
2018 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2019 glBufferData (GL_PIXEL_UNPACK_BUFFER, 128, &data[0], GL_DYNAMIC_COPY);
2020 expectError (GL_NO_ERROR);
2022 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
2023 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2024 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2025 glCompressedTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2026 expectError (GL_INVALID_OPERATION);
2027 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2028 m_log << TestLog::EndSection;
2030 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2031 glCompressedTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2032 expectError (GL_INVALID_OPERATION);
2033 m_log << TestLog::EndSection;
2034 m_log << TestLog::EndSection;
2036 glDeleteBuffers (1, &buf);
2037 glDeleteTextures (1, &texture);
2042 ES3F_ADD_API_CASE(teximage3d, "Invalid glTexImage3D() usage",
2044 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2045 glTexImage3D(0, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2046 expectError(GL_INVALID_ENUM);
2047 glTexImage3D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2048 expectError(GL_INVALID_ENUM);
2049 m_log << TestLog::EndSection;
2051 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2052 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 0, 0);
2053 expectError(GL_INVALID_ENUM);
2054 m_log << TestLog::EndSection;
2056 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2057 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
2058 expectError(GL_INVALID_ENUM);
2059 m_log << TestLog::EndSection;
2061 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants "
2062 "or GL_INVALID_OPERATION is generated if internalformat, format and type are not compatible.");
2063 glTexImage3D(GL_TEXTURE_3D, 0, 0, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2064 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2065 m_log << TestLog::EndSection;
2067 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if target is GL_TEXTURE_3D and format is GL_DEPTH_COMPONENT, or GL_DEPTH_STENCIL.");
2068 glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_STENCIL, 1, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
2069 expectError(GL_INVALID_OPERATION);
2070 glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_COMPONENT, 1, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
2071 expectError(GL_INVALID_OPERATION);
2072 m_log << TestLog::EndSection;
2074 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
2075 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2076 expectError(GL_INVALID_OPERATION);
2077 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2078 expectError(GL_INVALID_OPERATION);
2079 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2080 expectError(GL_INVALID_OPERATION);
2081 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB10_A2, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
2082 expectError(GL_INVALID_OPERATION);
2083 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, 1, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
2084 expectError(GL_INVALID_OPERATION);
2085 m_log << TestLog::EndSection;
2087 ES3F_ADD_API_CASE(teximage3d_neg_level, "Invalid glTexImage3D() usage",
2089 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2090 glTexImage3D(GL_TEXTURE_3D, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2091 expectError(GL_INVALID_VALUE);
2092 glTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2093 expectError(GL_INVALID_VALUE);
2094 m_log << TestLog::EndSection;
2096 ES3F_ADD_API_CASE(teximage3d_max_level, "Invalid glTexImage3D() usage",
2098 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2099 deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2100 glTexImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2101 expectError(GL_INVALID_VALUE);
2102 m_log << TestLog::EndSection;
2104 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2105 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2106 glTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2107 expectError(GL_INVALID_VALUE);
2108 m_log << TestLog::EndSection;
2110 ES3F_ADD_API_CASE(teximage3d_neg_width_height_depth, "Invalid glTexImage3D() usage",
2112 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
2113 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2114 expectError(GL_INVALID_VALUE);
2115 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2116 expectError(GL_INVALID_VALUE);
2117 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2118 expectError(GL_INVALID_VALUE);
2119 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2120 expectError(GL_INVALID_VALUE);
2122 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2123 expectError(GL_INVALID_VALUE);
2124 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2125 expectError(GL_INVALID_VALUE);
2126 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2127 expectError(GL_INVALID_VALUE);
2128 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2129 expectError(GL_INVALID_VALUE);
2130 m_log << TestLog::EndSection;
2132 ES3F_ADD_API_CASE(teximage3d_max_width_height_depth, "Invalid glTexImage3D() usage",
2134 int max3DTextureSize = m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE) + 1;
2135 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2137 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_3D_TEXTURE_SIZE.");
2138 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2139 expectError(GL_INVALID_VALUE);
2140 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, max3DTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2141 expectError(GL_INVALID_VALUE);
2142 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2143 expectError(GL_INVALID_VALUE);
2144 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2145 expectError(GL_INVALID_VALUE);
2146 m_log << TestLog::EndSection;
2148 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2149 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2150 expectError(GL_INVALID_VALUE);
2151 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, maxTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2152 expectError(GL_INVALID_VALUE);
2153 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2154 expectError(GL_INVALID_VALUE);
2155 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, maxTextureSize, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2156 expectError(GL_INVALID_VALUE);
2157 m_log << TestLog::EndSection;
2159 ES3F_ADD_API_CASE(teximage3d_invalid_border, "Invalid glTexImage3D() usage",
2161 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0 or 1.");
2162 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2163 expectError(GL_INVALID_VALUE);
2164 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2165 expectError(GL_INVALID_VALUE);
2166 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2167 expectError(GL_INVALID_VALUE);
2168 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2169 expectError(GL_INVALID_VALUE);
2170 m_log << TestLog::EndSection;
2172 ES3F_ADD_API_CASE(teximage3d_invalid_buffer_target, "Invalid glTexImage3D() usage",
2176 std::vector<GLubyte> data(512);
2178 glGenBuffers (1, &buf);
2179 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2180 glBufferData (GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2181 glGenTextures (1, &texture);
2182 glBindTexture (GL_TEXTURE_3D, texture);
2183 expectError (GL_NO_ERROR);
2185 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
2187 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2188 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2189 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2190 expectError (GL_INVALID_OPERATION);
2191 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2192 m_log << TestLog::EndSection;
2194 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2195 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 64, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2196 expectError (GL_INVALID_OPERATION);
2197 m_log << TestLog::EndSection;
2199 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2200 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2201 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGB5_A1, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
2202 expectError (GL_INVALID_OPERATION);
2203 m_log << TestLog::EndSection;
2205 m_log << TestLog::EndSection;
2207 glDeleteBuffers (1, &buf);
2208 glDeleteTextures (1, &texture);
2213 ES3F_ADD_API_CASE(texsubimage3d, "Invalid glTexSubImage3D() usage",
2216 glGenTextures (1, &texture);
2217 glBindTexture (GL_TEXTURE_3D, texture);
2218 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2219 expectError (GL_NO_ERROR);
2221 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2222 glTexSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2223 expectError(GL_INVALID_ENUM);
2224 glTexSubImage3D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2225 expectError(GL_INVALID_ENUM);
2226 m_log << TestLog::EndSection;
2228 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2229 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, GL_UNSIGNED_BYTE, 0);
2230 expectError(GL_INVALID_ENUM);
2231 m_log << TestLog::EndSection;
2233 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2234 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, 0, 0);
2235 expectError(GL_INVALID_ENUM);
2236 m_log << TestLog::EndSection;
2238 m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.");
2239 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2240 expectError(GL_INVALID_OPERATION);
2241 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2242 expectError(GL_INVALID_OPERATION);
2243 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2244 expectError(GL_INVALID_OPERATION);
2245 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
2246 expectError(GL_INVALID_OPERATION);
2247 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_FLOAT, 0);
2248 expectError(GL_INVALID_OPERATION);
2249 m_log << tcu::TestLog::EndSection;
2251 glDeleteTextures (1, &texture);
2253 ES3F_ADD_API_CASE(texsubimage3d_neg_level, "Invalid glTexSubImage3D() usage",
2255 deUint32 textures[2];
2256 glGenTextures (2, &textures[0]);
2257 glBindTexture (GL_TEXTURE_3D, textures[0]);
2258 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2259 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2260 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2261 expectError (GL_NO_ERROR);
2263 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2264 glTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2265 expectError(GL_INVALID_VALUE);
2266 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2267 expectError(GL_INVALID_VALUE);
2268 m_log << TestLog::EndSection;
2270 glDeleteTextures (2, &textures[0]);
2272 ES3F_ADD_API_CASE(texsubimage3d_max_level, "Invalid glTexSubImage3D() usage",
2274 deUint32 textures[2];
2275 glGenTextures (2, &textures[0]);
2276 glBindTexture (GL_TEXTURE_3D, textures[0]);
2277 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2278 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2279 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2280 expectError (GL_NO_ERROR);
2282 deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2283 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2285 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2286 glTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2287 expectError(GL_INVALID_VALUE);
2288 m_log << TestLog::EndSection;
2290 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2291 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2292 expectError(GL_INVALID_VALUE);
2293 m_log << TestLog::EndSection;
2295 glDeleteTextures (2, &textures[0]);
2297 ES3F_ADD_API_CASE(texsubimage3d_neg_offset, "Invalid glTexSubImage3D() usage",
2299 deUint32 textures[2];
2300 glGenTextures (2, &textures[0]);
2301 glBindTexture (GL_TEXTURE_3D, textures[0]);
2302 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2303 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2304 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2305 expectError (GL_NO_ERROR);
2307 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.");
2308 glTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2309 expectError(GL_INVALID_VALUE);
2310 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2311 expectError(GL_INVALID_VALUE);
2312 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2313 expectError(GL_INVALID_VALUE);
2314 glTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2315 expectError(GL_INVALID_VALUE);
2316 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2317 expectError(GL_INVALID_VALUE);
2318 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2319 expectError(GL_INVALID_VALUE);
2320 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2321 expectError(GL_INVALID_VALUE);
2322 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2323 expectError(GL_INVALID_VALUE);
2324 m_log << TestLog::EndSection;
2326 glDeleteTextures (2, &textures[0]);
2328 ES3F_ADD_API_CASE(texsubimage3d_invalid_offset, "Invalid glTexSubImage3D() usage",
2331 glGenTextures (1, &texture);
2332 glBindTexture (GL_TEXTURE_3D, texture);
2333 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2334 expectError (GL_NO_ERROR);
2336 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2337 glTexSubImage3D(GL_TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2338 expectError(GL_INVALID_VALUE);
2339 m_log << TestLog::EndSection;
2341 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2342 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2343 expectError(GL_INVALID_VALUE);
2344 m_log << TestLog::EndSection;
2346 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + depth > texture_depth.");
2347 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2348 expectError(GL_INVALID_VALUE);
2349 m_log << TestLog::EndSection;
2351 glDeleteTextures (1, &texture);
2353 ES3F_ADD_API_CASE(texsubimage3d_neg_width_height, "Invalid glTexSubImage3D() usage",
2355 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2356 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2357 expectError(GL_INVALID_VALUE);
2358 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2359 expectError(GL_INVALID_VALUE);
2360 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2361 expectError(GL_INVALID_VALUE);
2362 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2363 expectError(GL_INVALID_VALUE);
2364 m_log << TestLog::EndSection;
2366 ES3F_ADD_API_CASE(texsubimage3d_invalid_buffer_target, "Invalid glTexSubImage3D() usage",
2370 std::vector<GLubyte> data(512);
2372 glGenTextures (1, &texture);
2373 glBindTexture (GL_TEXTURE_3D, texture);
2374 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2375 glGenBuffers (1, &buf);
2376 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2377 glBufferData (GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2378 expectError (GL_NO_ERROR);
2380 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
2382 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2383 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 512, GL_MAP_WRITE_BIT);
2384 glTexSubImage3D (GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2385 expectError (GL_INVALID_OPERATION);
2386 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2387 m_log << TestLog::EndSection;
2389 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2390 glTexSubImage3D (GL_TEXTURE_3D, 0, 0, 0, 0, 16, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2391 expectError (GL_INVALID_OPERATION);
2392 m_log << TestLog::EndSection;
2394 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2395 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2396 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
2397 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2398 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2399 expectError (GL_NO_ERROR);
2400 glTexSubImage3D (GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
2401 expectError (GL_INVALID_OPERATION);
2402 m_log << TestLog::EndSection;
2404 m_log << TestLog::EndSection;
2406 glDeleteBuffers (1, &buf);
2407 glDeleteTextures (1, &texture);
2410 // glCopyTexSubImage3D
2412 ES3F_ADD_API_CASE(copytexsubimage3d, "Invalid glCopyTexSubImage3D() usage",
2415 glGenTextures (1, &texture);
2416 glBindTexture (GL_TEXTURE_3D, texture);
2417 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2419 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2420 glCopyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 4);
2421 expectError(GL_INVALID_ENUM);
2422 m_log << TestLog::EndSection;
2424 glDeleteTextures(1, &texture);
2426 ES3F_ADD_API_CASE(copytexsubimage3d_neg_level, "Invalid glCopyTexSubImage3D() usage",
2428 deUint32 textures[2];
2429 glGenTextures (2, &textures[0]);
2430 glBindTexture (GL_TEXTURE_3D, textures[0]);
2431 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2432 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2433 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2434 expectError (GL_NO_ERROR);
2436 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2437 glCopyTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 4);
2438 expectError(GL_INVALID_VALUE);
2439 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
2440 expectError(GL_INVALID_VALUE);
2441 m_log << TestLog::EndSection;
2443 glDeleteTextures(2, &textures[0]);
2445 ES3F_ADD_API_CASE(copytexsubimage3d_max_level, "Invalid glCopyTexSubImage3D() usage",
2447 deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2448 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2450 deUint32 textures[2];
2451 glGenTextures (2, &textures[0]);
2452 glBindTexture (GL_TEXTURE_3D, textures[0]);
2453 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2454 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2455 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2456 expectError (GL_NO_ERROR);
2458 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2459 glCopyTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 4);
2460 expectError(GL_INVALID_VALUE);
2461 m_log << TestLog::EndSection;
2463 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2464 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 4);
2465 expectError(GL_INVALID_VALUE);
2466 m_log << TestLog::EndSection;
2468 glDeleteTextures(2, &textures[0]);
2470 ES3F_ADD_API_CASE(copytexsubimage3d_neg_offset, "Invalid glCopyTexSubImage3D() usage",
2473 glGenTextures (1, &texture);
2474 glBindTexture (GL_TEXTURE_3D, texture);
2475 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2477 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.");
2478 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 4, 4);
2479 expectError(GL_INVALID_VALUE);
2480 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4);
2481 expectError(GL_INVALID_VALUE);
2482 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4);
2483 expectError(GL_INVALID_VALUE);
2484 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4);
2485 expectError(GL_INVALID_VALUE);
2486 m_log << TestLog::EndSection;
2488 glDeleteTextures(1, &texture);
2490 ES3F_ADD_API_CASE(copytexsubimage3d_invalid_offset, "Invalid glCopyTexSubImage3D() usage",
2493 glGenTextures (1, &texture);
2494 glBindTexture (GL_TEXTURE_3D, texture);
2495 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2497 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2498 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4);
2499 expectError(GL_INVALID_VALUE);
2500 m_log << TestLog::EndSection;
2502 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2503 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4);
2504 expectError(GL_INVALID_VALUE);
2505 m_log << TestLog::EndSection;
2507 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + 1 > texture_depth.");
2508 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4);
2509 expectError(GL_INVALID_VALUE);
2510 m_log << TestLog::EndSection;
2512 glDeleteTextures(1, &texture);
2514 ES3F_ADD_API_CASE(copytexsubimage3d_neg_width_height, "Invalid glCopyTexSubImage3D() usage",
2517 glGenTextures (1, &texture);
2518 glBindTexture (GL_TEXTURE_3D, texture);
2519 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2521 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width < 0.");
2522 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4);
2523 expectError(GL_INVALID_VALUE);
2524 m_log << TestLog::EndSection;
2526 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if height < 0.");
2527 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4);
2528 expectError(GL_INVALID_VALUE);
2529 m_log << TestLog::EndSection;
2531 glDeleteTextures(1, &texture);
2533 ES3F_ADD_API_CASE(copytexsubimage3d_incomplete_framebuffer, "Invalid glCopyTexSubImage3D() usage",
2538 glGenTextures (2, texture);
2539 glBindTexture (GL_TEXTURE_3D, texture[0]);
2540 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2541 glBindTexture (GL_TEXTURE_2D_ARRAY, texture[1]);
2542 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2543 glGenFramebuffers (1, &fbo);
2544 glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo);
2545 glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
2547 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
2548 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4);
2549 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2550 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
2551 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2552 m_log << tcu::TestLog::EndSection;
2554 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2555 glDeleteFramebuffers(1, &fbo);
2556 glDeleteTextures(2, texture);
2559 // glCompressedTexImage3D
2561 ES3F_ADD_API_CASE(compressedteximage3d, "Invalid glCompressedTexImage3D() usage",
2563 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2564 glCompressedTexImage3D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2565 expectError(GL_INVALID_ENUM);
2566 glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2567 expectError(GL_INVALID_ENUM);
2568 m_log << TestLog::EndSection;
2570 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.");
2571 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, 0);
2572 expectError(GL_INVALID_ENUM);
2573 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 0, 0, 0, 0, 0, 0);
2574 expectError(GL_INVALID_ENUM);
2575 m_log << TestLog::EndSection;
2577 ES3F_ADD_API_CASE(compressedteximage3d_neg_level, "Invalid glCompressedTexImage3D() usage",
2579 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2580 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2581 expectError(GL_INVALID_VALUE);
2582 m_log << TestLog::EndSection;
2584 ES3F_ADD_API_CASE(compressedteximage3d_max_level, "Invalid glCompressedTexImage3D() usage",
2586 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2587 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2588 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2589 expectError(GL_INVALID_VALUE);
2590 m_log << TestLog::EndSection;
2592 ES3F_ADD_API_CASE(compressedteximage3d_neg_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2594 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2595 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0, 0);
2596 expectError(GL_INVALID_VALUE);
2597 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0, 0);
2598 expectError(GL_INVALID_VALUE);
2599 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0, 0);
2600 expectError(GL_INVALID_VALUE);
2601 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, 0, 0);
2602 expectError(GL_INVALID_VALUE);
2603 m_log << TestLog::EndSection;
2605 ES3F_ADD_API_CASE(compressedteximage3d_max_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2607 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2609 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2610 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, 0, 0);
2611 expectError(GL_INVALID_VALUE);
2612 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, 0, 0);
2613 expectError(GL_INVALID_VALUE);
2614 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureSize, 0, 0, 0);
2615 expectError(GL_INVALID_VALUE);
2616 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, maxTextureSize, 0, 0, 0);
2617 expectError(GL_INVALID_VALUE);
2618 m_log << TestLog::EndSection;
2620 ES3F_ADD_API_CASE(compressedteximage3d_invalid_border, "Invalid glCompressedTexImage3D() usage",
2622 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
2623 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0, 0);
2624 expectError(GL_INVALID_VALUE);
2625 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, 0, 0);
2626 expectError(GL_INVALID_VALUE);
2627 m_log << TestLog::EndSection;
2629 ES3F_ADD_API_CASE(compressedteximage3d_invalid_size, "Invalid glCompressedTexImage3D() usage",
2631 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
2632 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, -1, 0);
2633 expectError(GL_INVALID_VALUE);
2634 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*8, 0);
2635 expectError(GL_INVALID_VALUE);
2636 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, 4*4*16, 0);
2637 expectError(GL_INVALID_VALUE);
2638 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, 4*4*16, 0);
2639 expectError(GL_INVALID_VALUE);
2640 m_log << TestLog::EndSection;
2642 ES3F_ADD_API_CASE(compressedteximage3d_invalid_buffer_target, "Invalid glCompressedTexImage3D() usage",
2645 std::vector<GLubyte> data(512);
2647 glGenBuffers (1, &buf);
2648 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2649 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
2650 expectError (GL_NO_ERROR);
2652 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped.");
2653 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 64, GL_MAP_WRITE_BIT);
2654 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 1, 0, etc2DataSize(4, 4), 0);
2655 expectError (GL_INVALID_OPERATION);
2656 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2657 m_log << TestLog::EndSection;
2659 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2660 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, etc2DataSize(16, 16), 0);
2661 expectError (GL_INVALID_OPERATION);
2662 m_log << TestLog::EndSection;
2664 glDeleteBuffers (1, &buf);
2666 ES3F_ADD_API_CASE(compressedteximage3d_invalid_astc_target, "Invalid glCompressedTexImage3D() ASTC 3D targets",
2668 // GLES 3.0.4, Sec 3.8.6, p.147: For example, the
2669 // compressed image format might be supported only for 2D
2670 // textures ... result in an INVALID_OPERATION error.
2671 // Also, if LDR is supported, formats cannot be invalid enums
2673 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2674 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
2676 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
2680 const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
2682 if (requiredError == GL_INVALID_OPERATION)
2683 m_log.writeMessage("GL_INVALID_OPERATION should be generated if using TEXTURE_3D with LDR ASTC.");
2685 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
2687 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
2689 const GLuint format = s_astcFormats[formatNdx];
2690 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
2691 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
2692 const size_t blockBytes = getBlockSize(tcuFormat);
2693 const vector<deUint8> dummyData (blockBytes);
2695 glCompressedTexImage3D(GL_TEXTURE_3D, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0, (int)blockBytes, &dummyData[0]);
2696 expectError(requiredError);
2701 // glCompressedTexSubImage3D
2703 ES3F_ADD_API_CASE(compressedtexsubimage3d, "Invalid glCompressedTexSubImage3D() usage",
2705 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2706 glCompressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2707 expectError(GL_INVALID_ENUM);
2708 m_log << TestLog::EndSection;
2711 glGenTextures (1, &texture);
2712 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2713 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0, etc2EacDataSize(18, 18), 0);
2714 expectError (GL_NO_ERROR);
2716 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
2717 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
2718 expectError(GL_INVALID_OPERATION);
2719 m_log << TestLog::EndSection;
2721 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.");
2722 glCompressedTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(18, 18), 0);
2723 expectError(GL_INVALID_OPERATION);
2724 m_log << TestLog::EndSection;
2726 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if width is not a multiple of four, and width + xoffset is not equal to the width of the texture level.");
2727 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
2728 expectError(GL_INVALID_OPERATION);
2729 m_log << TestLog::EndSection;
2731 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if height is not a multiple of four, and height + yoffset is not equal to the height of the texture level.");
2732 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
2733 expectError(GL_INVALID_OPERATION);
2734 m_log << TestLog::EndSection;
2736 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
2737 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2738 expectError(GL_INVALID_OPERATION);
2739 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2740 expectError(GL_INVALID_OPERATION);
2741 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2742 expectError(GL_INVALID_OPERATION);
2743 m_log << TestLog::EndSection;
2745 glDeleteTextures (1, &texture);
2747 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_level, "Invalid glCompressedTexSubImage3D() usage",
2750 glGenTextures (1, &texture);
2751 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2752 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2753 expectError (GL_NO_ERROR);
2755 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2756 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2757 expectError(GL_INVALID_VALUE);
2758 m_log << TestLog::EndSection;
2760 glDeleteTextures (1, &texture);
2762 ES3F_ADD_API_CASE(compressedtexsubimage3d_max_level, "Invalid glCompressedTexSubImage3D() usage",
2765 glGenTextures (1, &texture);
2766 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2767 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2768 expectError (GL_NO_ERROR);
2770 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2771 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2772 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2773 expectError(GL_INVALID_VALUE);
2774 m_log << TestLog::EndSection;
2776 glDeleteTextures (1, &texture);
2778 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_offset, "Invalid glCompressedTexSubImage3D() usage",
2781 glGenTextures (1, &texture);
2782 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2783 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2784 expectError (GL_NO_ERROR);
2786 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.");
2787 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2788 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2789 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2790 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2791 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2792 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2793 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2794 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2795 m_log << TestLog::EndSection;
2797 glDeleteTextures (1, &texture);
2799 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_offset, "Invalid glCompressedTexSubImage3D() usage",
2802 glGenTextures (1, &texture);
2803 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2804 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, etc2EacDataSize(4, 4), 0);
2805 expectError (GL_NO_ERROR);
2807 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
2809 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
2810 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2811 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
2812 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2813 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2814 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2815 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
2816 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2817 m_log << TestLog::EndSection;
2819 glDeleteTextures (1, &texture);
2821 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_width_height_depth, "Invalid glCompressedTexSubImage3D() usage",
2824 glGenTextures (1, &texture);
2825 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2826 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2827 expectError (GL_NO_ERROR);
2829 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width, height or depth are negative.");
2830 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2831 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2832 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2833 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2834 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2835 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2836 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2837 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2838 m_log << TestLog::EndSection;
2840 glDeleteTextures (1, &texture);
2842 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_size, "Invalid glCompressedTexSubImage3D() usage",
2845 glGenTextures (1, &texture);
2846 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2847 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*16, 0);
2848 expectError (GL_NO_ERROR);
2850 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
2851 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2852 expectError(GL_INVALID_VALUE);
2854 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2855 expectError(GL_INVALID_VALUE);
2856 m_log << TestLog::EndSection;
2858 glDeleteTextures (1, &texture);
2860 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_buffer_target, "Invalid glCompressedTexSubImage3D() usage",
2864 GLsizei bufferSize = etc2EacDataSize(4, 4);
2865 std::vector<GLubyte> data(bufferSize);
2867 glGenTextures (1, &texture);
2868 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2869 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2870 glGenBuffers (1, &buf);
2871 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2872 glBufferData (GL_PIXEL_UNPACK_BUFFER, bufferSize, &data[0], GL_DYNAMIC_COPY);
2873 expectError (GL_NO_ERROR);
2875 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
2876 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2877 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, GL_MAP_WRITE_BIT);
2878 glCompressedTexSubImage3D (GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2879 expectError (GL_INVALID_OPERATION);
2880 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2881 m_log << TestLog::EndSection;
2883 m_log << TestLog::Section("", "...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2884 glCompressedTexSubImage3D (GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2885 expectError (GL_INVALID_OPERATION);
2886 m_log << TestLog::EndSection;
2887 m_log << TestLog::EndSection;
2889 glDeleteBuffers (1, &buf);
2890 glDeleteTextures (1, &texture);
2895 ES3F_ADD_API_CASE(texstorage2d, "Invalid glTexStorage2D() usage",
2898 glGenTextures (1, &texture);
2899 glBindTexture (GL_TEXTURE_2D, texture);
2901 m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
2902 glTexStorage2D (GL_TEXTURE_2D, 1, 0, 16, 16);
2903 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
2904 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, 16, 16);
2905 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
2906 m_log << TestLog::EndSection;
2908 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
2909 glTexStorage2D (0, 1, GL_RGBA8, 16, 16);
2910 expectError (GL_INVALID_ENUM);
2911 glTexStorage2D (GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16);
2912 expectError (GL_INVALID_ENUM);
2913 glTexStorage2D (GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16);
2914 expectError (GL_INVALID_ENUM);
2915 m_log << TestLog::EndSection;
2917 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height are less than 1.");
2918 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 0, 16);
2919 expectError (GL_INVALID_VALUE);
2920 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 0);
2921 expectError (GL_INVALID_VALUE);
2922 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 0, 0);
2923 expectError (GL_INVALID_VALUE);
2924 m_log << TestLog::EndSection;
2926 glDeleteTextures(1, &texture);
2929 ES3F_ADD_API_CASE(texstorage2d_invalid_binding, "Invalid glTexStorage2D() usage",
2931 glBindTexture (GL_TEXTURE_2D, 0);
2933 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
2934 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2935 expectError (GL_INVALID_OPERATION);
2936 m_log << TestLog::EndSection;
2939 glGenTextures (1, &texture);
2940 glBindTexture (GL_TEXTURE_2D, texture);
2942 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the texture object currently bound to target already has GL_TEXTURE_IMMUTABLE_FORMAT set to GL_TRUE.");
2943 deInt32 immutable = -1;
2944 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
2945 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
2946 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2947 expectError (GL_NO_ERROR);
2948 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
2949 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
2950 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2951 expectError (GL_INVALID_OPERATION);
2952 m_log << TestLog::EndSection;
2954 glDeleteTextures(1, &texture);
2956 ES3F_ADD_API_CASE(texstorage2d_invalid_levels, "Invalid glTexStorage2D() usage",
2959 glGenTextures (1, &texture);
2960 glBindTexture (GL_TEXTURE_2D, texture);
2962 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
2963 glTexStorage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16);
2964 expectError (GL_INVALID_VALUE);
2965 glTexStorage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0);
2966 expectError (GL_INVALID_VALUE);
2967 m_log << TestLog::EndSection;
2969 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1");
2970 deUint32 log2MaxSize = deLog2Floor32(deMax32(16, 4)) + 1 + 1;
2971 glTexStorage2D (GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 4);
2972 expectError (GL_INVALID_OPERATION);
2973 glTexStorage2D (GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 4, 16);
2974 expectError (GL_INVALID_OPERATION);
2975 glTexStorage2D (GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 16);
2976 expectError (GL_INVALID_OPERATION);
2977 m_log << TestLog::EndSection;
2979 glDeleteTextures(1, &texture);
2981 ES3F_ADD_API_CASE(texstorage2d_invalid_astc_target, "ASTC formats require extensions present.",
2983 // GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
2984 // for which this command would have been valid, an
2985 // INVALID_OPERATION error is generated. Also: If
2986 // executing the pseudo-code would result in any other
2987 // error, the error is generated and the command will have
2989 // In conclusion: Expect same errors as with TexImage?D
2991 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
2993 m_log.writeMessage("ASTC supported. No negative API requirements.");
2997 // In earlier tests both codes are accepted for invalid target format.
2998 m_log.writeMessage("GL_INVALID_ENUM or GL_INVALID_VALUE should be generated if no ASTC extensions are present.");
3000 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3002 const GLuint format = s_astcFormats[formatNdx];
3003 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
3004 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
3005 const deInt32 cubeSize = blockPixels.x() * blockPixels.y(); // Divisible by the block size and square
3006 deUint32 texture = 0;
3008 glGenTextures (1, &texture);
3009 glBindTexture (GL_TEXTURE_2D, texture);
3011 glTexStorage2D (GL_TEXTURE_2D, 1, format, blockPixels.x(), blockPixels.y());
3012 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
3014 glDeleteTextures(1, &texture);
3016 glGenTextures (1, &texture);
3017 glBindTexture (GL_TEXTURE_CUBE_MAP, texture);
3019 glTexStorage2D (GL_TEXTURE_CUBE_MAP, 1, format, cubeSize, cubeSize);
3020 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
3022 glDeleteTextures(1, &texture);
3029 ES3F_ADD_API_CASE(texstorage3d, "Invalid glTexStorage3D() usage",
3032 glGenTextures (1, &texture);
3033 glBindTexture (GL_TEXTURE_3D, texture);
3035 m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3036 glTexStorage3D (GL_TEXTURE_3D, 1, 0, 4, 4, 4);
3037 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
3038 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA_INTEGER, 4, 4, 4);
3039 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
3040 m_log << TestLog::EndSection;
3042 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3043 glTexStorage3D (0, 1, GL_RGBA8, 4, 4, 4);
3044 expectError (GL_INVALID_ENUM);
3045 glTexStorage3D (GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 4, 4, 4);
3046 expectError (GL_INVALID_ENUM);
3047 glTexStorage3D (GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 4);
3048 expectError (GL_INVALID_ENUM);
3049 m_log << TestLog::EndSection;
3051 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth are less than 1.");
3052 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 0, 4, 4);
3053 expectError (GL_INVALID_VALUE);
3054 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 0, 4);
3055 expectError (GL_INVALID_VALUE);
3056 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 0);
3057 expectError (GL_INVALID_VALUE);
3058 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 0, 0, 0);
3059 expectError (GL_INVALID_VALUE);
3060 m_log << TestLog::EndSection;
3062 glDeleteTextures(1, &texture);
3064 ES3F_ADD_API_CASE(texstorage3d_invalid_binding, "Invalid glTexStorage3D() usage",
3066 glBindTexture (GL_TEXTURE_3D, 0);
3068 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3069 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3070 expectError (GL_INVALID_OPERATION);
3071 m_log << TestLog::EndSection;
3074 glGenTextures (1, &texture);
3075 glBindTexture (GL_TEXTURE_3D, texture);
3077 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the texture object currently bound to target already has GL_TEXTURE_IMMUTABLE_FORMAT set to GL_TRUE.");
3078 deInt32 immutable = -1;
3079 glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3080 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3081 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3082 expectError (GL_NO_ERROR);
3083 glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3084 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3085 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3086 expectError (GL_INVALID_OPERATION);
3087 m_log << TestLog::EndSection;
3089 glDeleteTextures(1, &texture);
3091 ES3F_ADD_API_CASE(texstorage3d_invalid_levels, "Invalid glTexStorage3D() usage",
3094 glGenTextures (1, &texture);
3095 glBindTexture (GL_TEXTURE_3D, texture);
3097 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
3098 glTexStorage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4);
3099 expectError (GL_INVALID_VALUE);
3100 glTexStorage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 0, 0, 0);
3101 expectError (GL_INVALID_VALUE);
3102 m_log << TestLog::EndSection;
3104 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1");
3105 deUint32 log2MaxSize = deLog2Floor32(8) + 1 + 1;
3106 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 2, 2);
3107 expectError (GL_INVALID_OPERATION);
3108 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 8, 2);
3109 expectError (GL_INVALID_OPERATION);
3110 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 2, 8);
3111 expectError (GL_INVALID_OPERATION);
3112 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 8, 8);
3113 expectError (GL_INVALID_OPERATION);
3114 m_log << TestLog::EndSection;
3116 glDeleteTextures(1, &texture);
3119 ES3F_ADD_API_CASE(texstorage3d_invalid_astc_target, "Invalid glTexStorage3D() ASTC 3D targets",
3121 // GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
3122 // for which this command would have been valid, an
3123 // INVALID_OPERATION error is generated. Also: If
3124 // executing the pseudo-code would result in any other
3125 // error, the error is generated and the command will have
3127 // In conclusion: Expect same errors as with TexImage?D
3129 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
3130 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3132 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3136 const bool ldrAstcSupported = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr");
3137 if (ldrAstcSupported)
3138 m_log.writeMessage("GL_INVALID_OPERATION should be generated if using TEXTURE_3D with LDR.");
3140 // In earlier tests both codes are accepted for invalid target format.
3141 m_log.writeMessage("GL_INVALID_ENUM or GL_INVALID_VALUE should be generated if no ASTC extensions are present.");
3143 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3145 const GLuint format = s_astcFormats[formatNdx];
3146 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
3147 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
3148 deUint32 texture = 0;
3150 glGenTextures (1, &texture);
3151 glBindTexture (GL_TEXTURE_3D, texture);
3153 glTexStorage3D (GL_TEXTURE_3D, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3155 if (ldrAstcSupported)
3156 expectError(GL_INVALID_OPERATION);
3158 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3160 glDeleteTextures(1, &texture);