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, "Invalid glCompressedTexImage2D() ASTC 2D targets",
498 // GLES 3.0.4, Sec 3.8.6, p.147: For example, the
499 // compressed image format might be supported only for 2D
500 // textures ... result in an INVALID_OPERATION error.
501 // Also, if LDR is supported, formats cannot be invalid enums
503 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
504 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
506 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
510 const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
512 if (requiredError == GL_INVALID_OPERATION)
513 m_log.writeMessage("GL_INVALID_OPERATION should be generated if cube map targets work with LDR ASTC.");
515 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
517 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
519 const GLuint format = s_astcFormats[formatNdx];
520 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
521 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
522 const size_t blockBytes = getBlockSize(tcuFormat);
523 const vector<deUint8> dummyData (blockBytes);
525 FOR_CUBE_FACES(faceGL,
527 glCompressedTexImage2D(faceGL, 0, format, blockPixels.x(), blockPixels.y(), 0, blockBytes, &dummyData[0]);
528 expectError(requiredError);
536 ES3F_ADD_API_CASE(copyteximage2d_invalid_target, "Invalid glCopyTexImage2D() usage",
538 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
539 glCopyTexImage2D(0, 0, GL_RGB, 0, 0, 64, 64, 0);
540 expectError(GL_INVALID_ENUM);
541 m_log << TestLog::EndSection;
543 ES3F_ADD_API_CASE(copyteximage2d_invalid_format, "Invalid glCopyTexImage2D() usage",
545 m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
546 glCopyTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0);
547 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
548 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0);
549 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
550 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0);
551 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
552 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0);
553 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
554 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0);
555 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
556 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0);
557 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
558 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0);
559 expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
560 m_log << TestLog::EndSection;
562 ES3F_ADD_API_CASE(copyteximage2d_inequal_width_height_cube, "Invalid glCopyTexImage2D() usage",
564 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.");
565 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
566 expectError(GL_INVALID_VALUE);
567 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
568 expectError(GL_INVALID_VALUE);
569 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
570 expectError(GL_INVALID_VALUE);
571 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
572 expectError(GL_INVALID_VALUE);
573 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
574 expectError(GL_INVALID_VALUE);
575 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
576 expectError(GL_INVALID_VALUE);
577 m_log << TestLog::EndSection;
579 ES3F_ADD_API_CASE(copyteximage2d_neg_level, "Invalid glCopyTexImage2D() usage",
581 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
582 glCopyTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 0, 0, 64, 64, 0);
583 expectError(GL_INVALID_VALUE);
584 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
585 expectError(GL_INVALID_VALUE);
586 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
587 expectError(GL_INVALID_VALUE);
588 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
589 expectError(GL_INVALID_VALUE);
590 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
591 expectError(GL_INVALID_VALUE);
592 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
593 expectError(GL_INVALID_VALUE);
594 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
595 expectError(GL_INVALID_VALUE);
596 m_log << TestLog::EndSection;
598 ES3F_ADD_API_CASE(copyteximage2d_max_level, "Invalid glCopyTexImage2D() usage",
600 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
601 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
602 glCopyTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 0, 0, 64, 64, 0);
603 expectError(GL_INVALID_VALUE);
604 m_log << TestLog::EndSection;
606 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
607 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
608 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
609 expectError(GL_INVALID_VALUE);
610 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
611 expectError(GL_INVALID_VALUE);
612 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
613 expectError(GL_INVALID_VALUE);
614 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
615 expectError(GL_INVALID_VALUE);
616 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
617 expectError(GL_INVALID_VALUE);
618 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
619 expectError(GL_INVALID_VALUE);
620 m_log << TestLog::EndSection;
622 ES3F_ADD_API_CASE(copyteximage2d_neg_width_height, "Invalid glCopyTexImage2D() usage",
624 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
626 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
627 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, 1, 0);
628 expectError(GL_INVALID_VALUE);
629 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, -1, 0);
630 expectError(GL_INVALID_VALUE);
631 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, -1, 0);
632 expectError(GL_INVALID_VALUE);
633 m_log << TestLog::EndSection;
635 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
636 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
637 expectError(GL_INVALID_VALUE);
638 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
639 expectError(GL_INVALID_VALUE);
640 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
641 expectError(GL_INVALID_VALUE);
642 m_log << TestLog::EndSection;
644 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
645 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
646 expectError(GL_INVALID_VALUE);
647 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
648 expectError(GL_INVALID_VALUE);
649 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
650 expectError(GL_INVALID_VALUE);
651 m_log << TestLog::EndSection;
653 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
654 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
655 expectError(GL_INVALID_VALUE);
656 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
657 expectError(GL_INVALID_VALUE);
658 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
659 expectError(GL_INVALID_VALUE);
660 m_log << TestLog::EndSection;
662 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
663 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
664 expectError(GL_INVALID_VALUE);
665 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
666 expectError(GL_INVALID_VALUE);
667 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
668 expectError(GL_INVALID_VALUE);
669 m_log << TestLog::EndSection;
671 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
672 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
673 expectError(GL_INVALID_VALUE);
674 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
675 expectError(GL_INVALID_VALUE);
676 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
677 expectError(GL_INVALID_VALUE);
678 m_log << TestLog::EndSection;
680 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
681 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
682 expectError(GL_INVALID_VALUE);
683 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
684 expectError(GL_INVALID_VALUE);
685 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
686 expectError(GL_INVALID_VALUE);
687 m_log << TestLog::EndSection;
689 m_log << TestLog::EndSection;
691 ES3F_ADD_API_CASE(copyteximage2d_max_width_height, "Invalid glCopyTexImage2D() usage",
693 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
694 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
696 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
698 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
699 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
700 expectError(GL_INVALID_VALUE);
701 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
702 expectError(GL_INVALID_VALUE);
703 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
704 expectError(GL_INVALID_VALUE);
705 m_log << TestLog::EndSection;
707 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
708 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
709 expectError(GL_INVALID_VALUE);
710 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
711 expectError(GL_INVALID_VALUE);
712 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
713 expectError(GL_INVALID_VALUE);
714 m_log << TestLog::EndSection;
716 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
717 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
718 expectError(GL_INVALID_VALUE);
719 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
720 expectError(GL_INVALID_VALUE);
721 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
722 expectError(GL_INVALID_VALUE);
723 m_log << TestLog::EndSection;
725 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
726 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
727 expectError(GL_INVALID_VALUE);
728 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
729 expectError(GL_INVALID_VALUE);
730 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
731 expectError(GL_INVALID_VALUE);
732 m_log << TestLog::EndSection;
734 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
735 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
736 expectError(GL_INVALID_VALUE);
737 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
738 expectError(GL_INVALID_VALUE);
739 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
740 expectError(GL_INVALID_VALUE);
741 m_log << TestLog::EndSection;
743 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
744 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
745 expectError(GL_INVALID_VALUE);
746 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
747 expectError(GL_INVALID_VALUE);
748 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
749 expectError(GL_INVALID_VALUE);
750 m_log << TestLog::EndSection;
752 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
753 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
754 expectError(GL_INVALID_VALUE);
755 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
756 expectError(GL_INVALID_VALUE);
757 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
758 expectError(GL_INVALID_VALUE);
759 m_log << TestLog::EndSection;
761 m_log << TestLog::EndSection;
763 ES3F_ADD_API_CASE(copyteximage2d_invalid_border, "Invalid glCopyTexImage2D() usage",
765 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
767 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
768 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, -1);
769 expectError(GL_INVALID_VALUE);
770 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, 1);
771 expectError(GL_INVALID_VALUE);
772 m_log << TestLog::EndSection;
774 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
775 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
776 expectError(GL_INVALID_VALUE);
777 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
778 expectError(GL_INVALID_VALUE);
779 m_log << TestLog::EndSection;
781 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
782 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
783 expectError(GL_INVALID_VALUE);
784 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
785 expectError(GL_INVALID_VALUE);
786 m_log << TestLog::EndSection;
788 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
789 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
790 expectError(GL_INVALID_VALUE);
791 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
792 expectError(GL_INVALID_VALUE);
793 m_log << TestLog::EndSection;
795 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
796 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
797 expectError(GL_INVALID_VALUE);
798 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
799 expectError(GL_INVALID_VALUE);
800 m_log << TestLog::EndSection;
802 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
803 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
804 expectError(GL_INVALID_VALUE);
805 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
806 expectError(GL_INVALID_VALUE);
807 m_log << TestLog::EndSection;
809 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
810 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
811 expectError(GL_INVALID_VALUE);
812 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
813 expectError(GL_INVALID_VALUE);
814 m_log << TestLog::EndSection;
816 m_log << TestLog::EndSection;
818 ES3F_ADD_API_CASE(copyteximage2d_incomplete_framebuffer, "Invalid glCopyTexImage2D() usage",
821 glGenFramebuffers (1, &fbo);
822 glBindFramebuffer (GL_FRAMEBUFFER, fbo);
823 glCheckFramebufferStatus(GL_FRAMEBUFFER);
825 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
826 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, 0, 0);
827 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
828 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
829 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
830 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
831 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
832 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
833 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
834 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
835 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
836 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
837 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
838 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
839 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
840 m_log << tcu::TestLog::EndSection;
842 glBindFramebuffer (GL_FRAMEBUFFER, 0);
843 glDeleteFramebuffers(1, &fbo);
846 // glCopyTexSubImage2D
848 ES3F_ADD_API_CASE(copytexsubimage2d_invalid_target, "Invalid glCopyTexSubImage2D() usage",
851 glGenTextures (1, &texture);
852 glBindTexture (GL_TEXTURE_2D, texture);
853 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
855 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
856 glCopyTexSubImage2D(0, 0, 0, 0, 0, 0, 4, 4);
857 expectError(GL_INVALID_ENUM);
858 m_log << TestLog::EndSection;
860 glDeleteTextures(1, &texture);
862 ES3F_ADD_API_CASE(copytexsubimage2d_neg_level, "Invalid glCopyTexSubImage2D() usage",
865 glGenTextures (2, &textures[0]);
866 glBindTexture (GL_TEXTURE_2D, textures[0]);
867 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
868 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
869 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
871 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
872 glCopyTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, 4, 4);
873 expectError(GL_INVALID_VALUE);
874 FOR_CUBE_FACES(faceGL,
876 glCopyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4);
877 expectError(GL_INVALID_VALUE);
879 m_log << TestLog::EndSection;
881 glDeleteTextures(2, &textures[0]);
883 ES3F_ADD_API_CASE(copytexsubimage2d_max_level, "Invalid glCopyTexSubImage2D() usage",
886 glGenTextures (2, &textures[0]);
887 glBindTexture (GL_TEXTURE_2D, textures[0]);
888 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
889 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
890 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
892 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for 2D texture targets.");
893 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
894 glCopyTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 4, 4);
895 expectError(GL_INVALID_VALUE);
896 m_log << TestLog::EndSection;
898 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_SIZE) for cubemap targets.");
899 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
900 FOR_CUBE_FACES(faceGL,
902 glCopyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4);
903 expectError(GL_INVALID_VALUE);
905 m_log << TestLog::EndSection;
907 glDeleteTextures(2, &textures[0]);
909 ES3F_ADD_API_CASE(copytexsubimage2d_neg_offset, "Invalid glCopyTexSubImage2D() usage",
912 glGenTextures (1, &texture);
913 glBindTexture (GL_TEXTURE_2D, texture);
914 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
916 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.");
917 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, 4, 4);
918 expectError(GL_INVALID_VALUE);
919 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, 4, 4);
920 expectError(GL_INVALID_VALUE);
921 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, 4, 4);
922 expectError(GL_INVALID_VALUE);
923 m_log << TestLog::EndSection;
925 glDeleteTextures(1, &texture);
927 ES3F_ADD_API_CASE(copytexsubimage2d_invalid_offset, "Invalid glCopyTexSubImage2D() usage",
930 glGenTextures (1, &texture);
931 glBindTexture (GL_TEXTURE_2D, texture);
932 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
934 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
935 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 0, 0, 0, 4, 4);
936 expectError(GL_INVALID_VALUE);
937 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 14, 0, 0, 4, 4);
938 expectError(GL_INVALID_VALUE);
939 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 14, 0, 0, 4, 4);
940 expectError(GL_INVALID_VALUE);
941 m_log << TestLog::EndSection;
943 glDeleteTextures(1, &texture);
945 ES3F_ADD_API_CASE(copytexsubimage2d_neg_width_height, "Invalid glCopyTexSubImage2D() usage",
948 glGenTextures (1, &texture);
949 glBindTexture (GL_TEXTURE_2D, texture);
950 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
952 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
953 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0);
954 expectError(GL_INVALID_VALUE);
955 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1);
956 expectError(GL_INVALID_VALUE);
957 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1);
958 expectError(GL_INVALID_VALUE);
959 m_log << TestLog::EndSection;
961 glDeleteTextures(1, &texture);
963 ES3F_ADD_API_CASE(copytexsubimage2d_incomplete_framebuffer, "Invalid glCopyTexSubImage2D() usage",
965 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
970 glGenTextures (2, texture);
971 glBindTexture (GL_TEXTURE_2D, texture[0]);
972 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
973 glBindTexture (GL_TEXTURE_CUBE_MAP, texture[1]);
974 glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
975 glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
976 glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
977 glTexImage2D (GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
978 glTexImage2D (GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
979 glTexImage2D (GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
980 expectError(GL_NO_ERROR);
982 glGenFramebuffers(1, &fbo);
983 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
984 glCheckFramebufferStatus(GL_FRAMEBUFFER);
985 expectError(GL_NO_ERROR);
987 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
988 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
989 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
990 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
991 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
992 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
993 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
994 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
995 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
996 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
997 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
998 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
999 glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1000 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1002 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1003 glDeleteFramebuffers(1, &fbo);
1004 glDeleteTextures(2, texture);
1006 m_log << tcu::TestLog::EndSection;
1011 ES3F_ADD_API_CASE(deletetextures, "Invalid glDeleteTextures() usage",
1014 glGenTextures(1, &texture);
1016 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1017 glDeleteTextures(-1, 0);
1018 expectError(GL_INVALID_VALUE);
1020 glBindTexture(GL_TEXTURE_2D, texture);
1021 glDeleteTextures(-1, 0);
1022 expectError(GL_INVALID_VALUE);
1023 m_log << TestLog::EndSection;
1025 glDeleteTextures(1, &texture);
1030 ES3F_ADD_API_CASE(generatemipmap, "Invalid glGenerateMipmap() usage",
1033 glGenTextures(2, texture);
1035 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.");
1036 glGenerateMipmap(0);
1037 expectError(GL_INVALID_ENUM);
1038 m_log << TestLog::EndSection;
1040 m_log << TestLog::Section("", "INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
1041 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1042 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
1043 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1044 glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1045 expectError(GL_INVALID_OPERATION);
1047 glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1048 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1049 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1050 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1051 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1052 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1053 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1054 glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1055 expectError(GL_INVALID_OPERATION);
1056 m_log << TestLog::EndSection;
1058 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
1059 glBindTexture(GL_TEXTURE_2D, texture[1]);
1060 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1061 glGenerateMipmap(GL_TEXTURE_2D);
1062 expectError(GL_INVALID_OPERATION);
1063 m_log << TestLog::EndSection;
1065 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.");
1066 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 0, 0, 0, GL_RGB, GL_BYTE, 0);
1067 glGenerateMipmap(GL_TEXTURE_2D);
1068 expectError(GL_INVALID_OPERATION);
1069 glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, 0);
1070 glGenerateMipmap(GL_TEXTURE_2D);
1071 expectError(GL_INVALID_OPERATION);
1073 if (!(m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") && m_context.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
1075 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
1076 glGenerateMipmap(GL_TEXTURE_2D);
1077 expectError(GL_INVALID_OPERATION);
1080 m_log << TestLog::EndSection;
1082 glDeleteTextures(2, texture);
1087 ES3F_ADD_API_CASE(gentextures, "Invalid glGenTextures() usage",
1089 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1090 glGenTextures(-1, 0);
1091 expectError(GL_INVALID_VALUE);
1092 m_log << TestLog::EndSection;
1097 ES3F_ADD_API_CASE(pixelstorei, "Invalid glPixelStorei() usage",
1099 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1101 expectError(GL_INVALID_ENUM);
1102 m_log << TestLog::EndSection;
1104 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.");
1105 glPixelStorei(GL_PACK_ROW_LENGTH, -1);
1106 expectError(GL_INVALID_VALUE);
1107 glPixelStorei(GL_PACK_SKIP_ROWS, -1);
1108 expectError(GL_INVALID_VALUE);
1109 glPixelStorei(GL_PACK_SKIP_PIXELS, -1);
1110 expectError(GL_INVALID_VALUE);
1111 glPixelStorei(GL_UNPACK_ROW_LENGTH, -1);
1112 expectError(GL_INVALID_VALUE);
1113 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, -1);
1114 expectError(GL_INVALID_VALUE);
1115 glPixelStorei(GL_UNPACK_SKIP_ROWS, -1);
1116 expectError(GL_INVALID_VALUE);
1117 glPixelStorei(GL_UNPACK_SKIP_PIXELS, -1);
1118 expectError(GL_INVALID_VALUE);
1119 glPixelStorei(GL_UNPACK_SKIP_IMAGES, -1);
1120 expectError(GL_INVALID_VALUE);
1121 glPixelStorei(GL_PACK_ALIGNMENT, 0);
1122 expectError(GL_INVALID_VALUE);
1123 glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
1124 expectError(GL_INVALID_VALUE);
1125 glPixelStorei(GL_PACK_ALIGNMENT, 16);
1126 expectError(GL_INVALID_VALUE);
1127 glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
1128 expectError(GL_INVALID_VALUE);
1129 m_log << TestLog::EndSection;
1134 ES3F_ADD_API_CASE(teximage2d, "Invalid glTexImage2D() usage",
1136 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1137 glTexImage2D(0, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1138 expectError(GL_INVALID_ENUM);
1139 m_log << TestLog::EndSection;
1141 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1142 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 0, 0);
1143 expectError(GL_INVALID_ENUM);
1144 m_log << TestLog::EndSection;
1146 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
1147 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1148 expectError(GL_INVALID_OPERATION);
1149 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1150 expectError(GL_INVALID_OPERATION);
1151 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1152 expectError(GL_INVALID_OPERATION);
1153 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
1154 expectError(GL_INVALID_OPERATION);
1155 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
1156 expectError(GL_INVALID_OPERATION);
1157 m_log << TestLog::EndSection;
1159 ES3F_ADD_API_CASE(teximage2d_inequal_width_height_cube, "Invalid glTexImage2D() usage",
1161 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.");
1162 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1163 expectError(GL_INVALID_VALUE);
1164 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1165 expectError(GL_INVALID_VALUE);
1166 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1167 expectError(GL_INVALID_VALUE);
1168 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1169 expectError(GL_INVALID_VALUE);
1170 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1171 expectError(GL_INVALID_VALUE);
1172 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1173 expectError(GL_INVALID_VALUE);
1174 m_log << TestLog::EndSection;
1176 ES3F_ADD_API_CASE(teximage2d_neg_level, "Invalid glTexImage2D() usage",
1178 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1179 glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1180 expectError(GL_INVALID_VALUE);
1181 m_log << TestLog::EndSection;
1183 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1184 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1185 expectError(GL_INVALID_VALUE);
1186 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1187 expectError(GL_INVALID_VALUE);
1188 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1189 expectError(GL_INVALID_VALUE);
1190 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1191 expectError(GL_INVALID_VALUE);
1192 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1193 expectError(GL_INVALID_VALUE);
1194 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1195 expectError(GL_INVALID_VALUE);
1196 m_log << TestLog::EndSection;
1198 ES3F_ADD_API_CASE(teximage2d_max_level, "Invalid glTexImage2D() usage",
1200 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1201 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1202 glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1203 expectError(GL_INVALID_VALUE);
1204 m_log << TestLog::EndSection;
1206 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1207 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1208 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1209 expectError(GL_INVALID_VALUE);
1210 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1211 expectError(GL_INVALID_VALUE);
1212 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1213 expectError(GL_INVALID_VALUE);
1214 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1215 expectError(GL_INVALID_VALUE);
1216 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1217 expectError(GL_INVALID_VALUE);
1218 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1219 expectError(GL_INVALID_VALUE);
1220 m_log << TestLog::EndSection;
1222 ES3F_ADD_API_CASE(teximage2d_neg_width_height, "Invalid glTexImage2D() usage",
1224 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1226 m_log << TestLog::Section("", "GL_TEXTURE_2D target");
1227 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1228 expectError(GL_INVALID_VALUE);
1229 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1230 expectError(GL_INVALID_VALUE);
1231 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1232 expectError(GL_INVALID_VALUE);
1233 m_log << TestLog::EndSection;
1235 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1236 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1237 expectError(GL_INVALID_VALUE);
1238 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1239 expectError(GL_INVALID_VALUE);
1240 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1241 expectError(GL_INVALID_VALUE);
1242 m_log << TestLog::EndSection;
1244 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1245 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1246 expectError(GL_INVALID_VALUE);
1247 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1248 expectError(GL_INVALID_VALUE);
1249 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1250 expectError(GL_INVALID_VALUE);
1251 m_log << TestLog::EndSection;
1253 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1254 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1255 expectError(GL_INVALID_VALUE);
1256 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1257 expectError(GL_INVALID_VALUE);
1258 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1259 expectError(GL_INVALID_VALUE);
1260 m_log << TestLog::EndSection;
1262 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1263 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1264 expectError(GL_INVALID_VALUE);
1265 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1266 expectError(GL_INVALID_VALUE);
1267 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1268 expectError(GL_INVALID_VALUE);
1269 m_log << TestLog::EndSection;
1271 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1272 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1273 expectError(GL_INVALID_VALUE);
1274 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1275 expectError(GL_INVALID_VALUE);
1276 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1277 expectError(GL_INVALID_VALUE);
1278 m_log << TestLog::EndSection;
1280 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1281 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1282 expectError(GL_INVALID_VALUE);
1283 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1284 expectError(GL_INVALID_VALUE);
1285 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1286 expectError(GL_INVALID_VALUE);
1287 m_log << TestLog::EndSection;
1289 m_log << TestLog::EndSection;
1291 ES3F_ADD_API_CASE(teximage2d_max_width_height, "Invalid glTexImage2D() usage",
1293 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
1294 int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1296 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
1297 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1298 expectError(GL_INVALID_VALUE);
1299 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1300 expectError(GL_INVALID_VALUE);
1301 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1302 expectError(GL_INVALID_VALUE);
1303 m_log << TestLog::EndSection;
1305 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1307 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1308 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1309 expectError(GL_INVALID_VALUE);
1310 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1311 expectError(GL_INVALID_VALUE);
1312 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1313 expectError(GL_INVALID_VALUE);
1314 m_log << TestLog::EndSection;
1316 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1317 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1318 expectError(GL_INVALID_VALUE);
1319 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1320 expectError(GL_INVALID_VALUE);
1321 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1322 expectError(GL_INVALID_VALUE);
1323 m_log << TestLog::EndSection;
1325 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1326 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1327 expectError(GL_INVALID_VALUE);
1328 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1329 expectError(GL_INVALID_VALUE);
1330 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1331 expectError(GL_INVALID_VALUE);
1332 m_log << TestLog::EndSection;
1334 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1335 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1336 expectError(GL_INVALID_VALUE);
1337 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1338 expectError(GL_INVALID_VALUE);
1339 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1340 expectError(GL_INVALID_VALUE);
1341 m_log << TestLog::EndSection;
1343 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1344 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1345 expectError(GL_INVALID_VALUE);
1346 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1347 expectError(GL_INVALID_VALUE);
1348 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1349 expectError(GL_INVALID_VALUE);
1350 m_log << TestLog::EndSection;
1352 m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1353 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1354 expectError(GL_INVALID_VALUE);
1355 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1356 expectError(GL_INVALID_VALUE);
1357 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1358 expectError(GL_INVALID_VALUE);
1359 m_log << TestLog::EndSection;
1361 m_log << TestLog::EndSection;
1363 ES3F_ADD_API_CASE(teximage2d_invalid_border, "Invalid glTexImage2D() usage",
1365 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
1366 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1367 expectError(GL_INVALID_VALUE);
1368 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1369 expectError(GL_INVALID_VALUE);
1370 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1371 expectError(GL_INVALID_VALUE);
1372 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1373 expectError(GL_INVALID_VALUE);
1374 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1375 expectError(GL_INVALID_VALUE);
1376 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1377 expectError(GL_INVALID_VALUE);
1378 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1379 expectError(GL_INVALID_VALUE);
1380 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1381 expectError(GL_INVALID_VALUE);
1382 m_log << TestLog::EndSection;
1384 ES3F_ADD_API_CASE(teximage2d_invalid_buffer_target, "Invalid glTexImage2D() usage",
1388 std::vector<GLubyte> data(64);
1390 glGenBuffers (1, &buf);
1391 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
1392 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1393 glGenTextures (1, &texture);
1394 glBindTexture (GL_TEXTURE_2D, texture);
1395 expectError (GL_NO_ERROR);
1397 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...");
1398 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1399 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1400 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1401 expectError (GL_INVALID_OPERATION);
1402 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
1403 m_log << TestLog::EndSection;
1405 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.");
1406 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1407 expectError (GL_INVALID_OPERATION);
1408 m_log << TestLog::EndSection;
1410 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1411 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1412 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB5_A1, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
1413 expectError (GL_INVALID_OPERATION);
1414 m_log << TestLog::EndSection;
1415 m_log << TestLog::EndSection;
1417 glDeleteBuffers (1, &buf);
1418 glDeleteTextures (1, &texture);
1423 ES3F_ADD_API_CASE(texsubimage2d, "Invalid glTexSubImage2D() usage",
1426 glGenTextures (1, &texture);
1427 glBindTexture (GL_TEXTURE_2D, texture);
1428 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1429 expectError (GL_NO_ERROR);
1431 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1432 glTexSubImage2D(0, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1433 expectError(GL_INVALID_ENUM);
1434 m_log << TestLog::EndSection;
1436 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
1437 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, GL_UNSIGNED_BYTE, 0);
1438 expectError(GL_INVALID_ENUM);
1439 m_log << TestLog::EndSection;
1441 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1442 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, 0, 0);
1443 expectError(GL_INVALID_ENUM);
1444 m_log << TestLog::EndSection;
1446 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.");
1447 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
1448 expectError(GL_INVALID_OPERATION);
1449 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1450 expectError(GL_INVALID_OPERATION);
1451 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1452 expectError(GL_INVALID_OPERATION);
1453 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1454 expectError(GL_INVALID_OPERATION);
1455 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
1456 expectError(GL_INVALID_OPERATION);
1457 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_FLOAT, 0);
1458 expectError(GL_INVALID_OPERATION);
1459 m_log << tcu::TestLog::EndSection;
1461 glDeleteTextures (1, &texture);
1463 ES3F_ADD_API_CASE(texsubimage2d_neg_level, "Invalid glTexSubImage2D() usage",
1465 deUint32 textures[2];
1466 glGenTextures (2, &textures[0]);
1467 glBindTexture (GL_TEXTURE_2D, textures[0]);
1468 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1469 glBindTexture (GL_TEXTURE_2D, textures[1]);
1470 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1471 expectError (GL_NO_ERROR);
1473 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1474 glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1475 expectError(GL_INVALID_VALUE);
1476 m_log << TestLog::EndSection;
1478 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1479 FOR_CUBE_FACES(faceGL,
1481 glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1482 expectError(GL_INVALID_VALUE);
1484 m_log << TestLog::EndSection;
1486 glDeleteTextures(2, &textures[0]);
1488 ES3F_ADD_API_CASE(texsubimage2d_max_level, "Invalid glTexSubImage2D() usage",
1490 deUint32 textures[2];
1491 glGenTextures (2, &textures[0]);
1492 glBindTexture (GL_TEXTURE_2D, textures[0]);
1493 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1494 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
1495 FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1496 expectError (GL_NO_ERROR);
1498 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1499 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1500 glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1501 expectError(GL_INVALID_VALUE);
1502 m_log << TestLog::EndSection;
1504 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1505 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1506 FOR_CUBE_FACES(faceGL,
1508 glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1509 expectError(GL_INVALID_VALUE);
1511 m_log << TestLog::EndSection;
1513 glDeleteTextures(2, &textures[0]);
1515 ES3F_ADD_API_CASE(texsubimage2d_neg_offset, "Invalid glTexSubImage2D() usage",
1518 glGenTextures(1, &texture);
1519 glBindTexture(GL_TEXTURE_2D, texture);
1520 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1521 expectError(GL_NO_ERROR);
1523 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
1524 glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1525 expectError(GL_INVALID_VALUE);
1526 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1527 expectError(GL_INVALID_VALUE);
1528 glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1529 expectError(GL_INVALID_VALUE);
1530 m_log << TestLog::EndSection;
1532 glDeleteTextures(1, &texture);
1534 ES3F_ADD_API_CASE(texsubimage2d_invalid_offset, "Invalid glTexSubImage2D() usage",
1537 glGenTextures (1, &texture);
1538 glBindTexture (GL_TEXTURE_2D, texture);
1539 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1540 expectError (GL_NO_ERROR);
1542 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1543 glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1544 expectError(GL_INVALID_VALUE);
1545 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1546 expectError(GL_INVALID_VALUE);
1547 glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1548 expectError(GL_INVALID_VALUE);
1549 m_log << TestLog::EndSection;
1551 glDeleteTextures (1, &texture);
1553 ES3F_ADD_API_CASE(texsubimage2d_neg_width_height, "Invalid glTexSubImage2D() usage",
1556 glGenTextures (1, &texture);
1557 glBindTexture (GL_TEXTURE_2D, texture);
1558 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1559 expectError (GL_NO_ERROR);
1561 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1562 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1563 expectError(GL_INVALID_VALUE);
1564 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1565 expectError(GL_INVALID_VALUE);
1566 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1567 expectError(GL_INVALID_VALUE);
1568 m_log << TestLog::EndSection;
1570 glDeleteTextures (1, &texture);
1572 ES3F_ADD_API_CASE(texsubimage2d_invalid_buffer_target, "Invalid glTexSubImage2D() usage",
1576 std::vector<GLubyte> data(64);
1578 glGenTextures (1, &texture);
1579 glBindTexture (GL_TEXTURE_2D, texture);
1580 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1581 glGenBuffers (1, &buf);
1582 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
1583 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1584 expectError (GL_NO_ERROR);
1586 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...");
1587 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1588 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1589 glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1590 expectError (GL_INVALID_OPERATION);
1591 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
1592 m_log << TestLog::EndSection;
1594 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.");
1595 glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1596 expectError (GL_INVALID_OPERATION);
1597 m_log << TestLog::EndSection;
1599 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1600 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1601 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
1602 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1603 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
1604 expectError (GL_NO_ERROR);
1605 glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
1606 expectError (GL_INVALID_OPERATION);
1607 m_log << TestLog::EndSection;
1608 m_log << TestLog::EndSection;
1610 glDeleteBuffers (1, &buf);
1611 glDeleteTextures (1, &texture);
1616 ES3F_ADD_API_CASE(texparameteri, "Invalid glTexParameteri() usage",
1618 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1619 glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1620 expectError(GL_INVALID_ENUM);
1621 glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1622 expectError(GL_INVALID_ENUM);
1623 glTexParameteri(0, 0, GL_LINEAR);
1624 expectError(GL_INVALID_ENUM);
1625 m_log << TestLog::EndSection;
1627 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.");
1628 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1629 expectError(GL_INVALID_ENUM);
1630 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1631 expectError(GL_INVALID_ENUM);
1632 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1633 expectError(GL_INVALID_ENUM);
1634 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1635 expectError(GL_INVALID_ENUM);
1636 m_log << TestLog::EndSection;
1639 glGenTextures(1, &texture);
1640 glBindTexture(GL_TEXTURE_2D, texture);
1642 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1643 glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1644 expectError(GL_INVALID_ENUM);
1645 glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1646 expectError(GL_INVALID_ENUM);
1647 glTexParameteri(0, 0, GL_LINEAR);
1648 expectError(GL_INVALID_ENUM);
1649 m_log << TestLog::EndSection;
1651 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.");
1652 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1653 expectError(GL_INVALID_ENUM);
1654 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1655 expectError(GL_INVALID_ENUM);
1656 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1657 expectError(GL_INVALID_ENUM);
1658 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1659 expectError(GL_INVALID_ENUM);
1660 m_log << TestLog::EndSection;
1662 glDeleteTextures(1, &texture);
1667 ES3F_ADD_API_CASE(texparameterf, "Invalid glTexParameterf() usage",
1669 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1670 glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1671 expectError(GL_INVALID_ENUM);
1672 glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1673 expectError(GL_INVALID_ENUM);
1674 glTexParameterf(0, 0, GL_LINEAR);
1675 expectError(GL_INVALID_ENUM);
1676 m_log << TestLog::EndSection;
1678 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.");
1679 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1680 expectError(GL_INVALID_ENUM);
1681 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1682 expectError(GL_INVALID_ENUM);
1683 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1684 expectError(GL_INVALID_ENUM);
1685 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1686 expectError(GL_INVALID_ENUM);
1687 m_log << TestLog::EndSection;
1690 glGenTextures(1, &texture);
1691 glBindTexture(GL_TEXTURE_2D, texture);
1693 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1694 glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1695 expectError(GL_INVALID_ENUM);
1696 glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1697 expectError(GL_INVALID_ENUM);
1698 glTexParameterf(0, 0, GL_LINEAR);
1699 expectError(GL_INVALID_ENUM);
1700 m_log << TestLog::EndSection;
1702 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.");
1703 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1704 expectError(GL_INVALID_ENUM);
1705 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1706 expectError(GL_INVALID_ENUM);
1707 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1708 expectError(GL_INVALID_ENUM);
1709 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1710 expectError(GL_INVALID_ENUM);
1711 m_log << TestLog::EndSection;
1713 glDeleteTextures(1, &texture);
1718 ES3F_ADD_API_CASE(texparameteriv, "Invalid glTexParameteriv() usage",
1720 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1721 GLint params[1] = {GL_LINEAR};
1722 glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1723 expectError(GL_INVALID_ENUM);
1724 glTexParameteriv(GL_TEXTURE_2D, 0, ¶ms[0]);
1725 expectError(GL_INVALID_ENUM);
1726 glTexParameteriv(0, 0, ¶ms[0]);
1727 expectError(GL_INVALID_ENUM);
1728 m_log << TestLog::EndSection;
1730 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.");
1732 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1733 expectError(GL_INVALID_ENUM);
1734 params[0] = GL_REPEAT;
1735 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1736 expectError(GL_INVALID_ENUM);
1738 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1739 expectError(GL_INVALID_ENUM);
1740 params[0] = GL_NEAREST;
1741 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1742 expectError(GL_INVALID_ENUM);
1743 m_log << TestLog::EndSection;
1746 glGenTextures(1, &texture);
1747 glBindTexture(GL_TEXTURE_2D, texture);
1749 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1750 params[0] = GL_LINEAR;
1751 glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1752 expectError(GL_INVALID_ENUM);
1753 glTexParameteriv(GL_TEXTURE_2D, 0, ¶ms[0]);
1754 expectError(GL_INVALID_ENUM);
1755 glTexParameteriv(0, 0, ¶ms[0]);
1756 expectError(GL_INVALID_ENUM);
1757 m_log << TestLog::EndSection;
1759 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.");
1761 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1762 expectError(GL_INVALID_ENUM);
1763 params[0] = GL_REPEAT;
1764 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1765 expectError(GL_INVALID_ENUM);
1767 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1768 expectError(GL_INVALID_ENUM);
1769 params[0] = GL_NEAREST;
1770 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1771 expectError(GL_INVALID_ENUM);
1772 m_log << TestLog::EndSection;
1774 glDeleteTextures(1, &texture);
1779 ES3F_ADD_API_CASE(texparameterfv, "Invalid glTexParameterfv() usage",
1781 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1782 GLfloat params[1] = {GL_LINEAR};
1783 glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1784 expectError(GL_INVALID_ENUM);
1785 glTexParameterfv(GL_TEXTURE_2D, 0, ¶ms[0]);
1786 expectError(GL_INVALID_ENUM);
1787 glTexParameterfv(0, 0, ¶ms[0]);
1788 expectError(GL_INVALID_ENUM);
1789 m_log << TestLog::EndSection;
1791 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.");
1793 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1794 expectError(GL_INVALID_ENUM);
1795 params[0] = GL_REPEAT;
1796 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1797 expectError(GL_INVALID_ENUM);
1799 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1800 expectError(GL_INVALID_ENUM);
1801 params[0] = GL_NEAREST;
1802 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1803 expectError(GL_INVALID_ENUM);
1804 m_log << TestLog::EndSection;
1807 glGenTextures(1, &texture);
1808 glBindTexture(GL_TEXTURE_2D, texture);
1810 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1811 params[0] = GL_LINEAR;
1812 glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1813 expectError(GL_INVALID_ENUM);
1814 glTexParameterfv(GL_TEXTURE_2D, 0, ¶ms[0]);
1815 expectError(GL_INVALID_ENUM);
1816 glTexParameterfv(0, 0, ¶ms[0]);
1817 expectError(GL_INVALID_ENUM);
1818 m_log << TestLog::EndSection;
1820 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.");
1822 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
1823 expectError(GL_INVALID_ENUM);
1824 params[0] = GL_REPEAT;
1825 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ¶ms[0]);
1826 expectError(GL_INVALID_ENUM);
1828 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ¶ms[0]);
1829 expectError(GL_INVALID_ENUM);
1830 params[0] = GL_NEAREST;
1831 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ¶ms[0]);
1832 expectError(GL_INVALID_ENUM);
1833 m_log << TestLog::EndSection;
1835 glDeleteTextures(1, &texture);
1838 // glCompressedTexSubImage2D
1840 ES3F_ADD_API_CASE(compressedtexsubimage2d, "Invalid glCompressedTexSubImage2D() usage",
1842 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1843 glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1844 expectError(GL_INVALID_ENUM);
1845 m_log << TestLog::EndSection;
1848 glGenTextures (1, &texture);
1849 glBindTexture (GL_TEXTURE_2D, texture);
1850 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1851 expectError (GL_NO_ERROR);
1853 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
1854 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1855 expectError(GL_INVALID_OPERATION);
1856 m_log << TestLog::EndSection;
1858 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.");
1859 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 4, 0, 10, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
1860 expectError(GL_INVALID_OPERATION);
1861 m_log << TestLog::EndSection;
1863 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.");
1864 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 4, 4, 10, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
1865 expectError(GL_INVALID_OPERATION);
1866 m_log << TestLog::EndSection;
1868 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
1869 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1870 expectError(GL_INVALID_OPERATION);
1871 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1872 expectError(GL_INVALID_OPERATION);
1873 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1874 expectError(GL_INVALID_OPERATION);
1875 m_log << TestLog::EndSection;
1877 glDeleteTextures (1, &texture);
1879 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_level, "Invalid glCompressedTexSubImage2D() usage",
1881 deUint32 textures[2];
1882 glGenTextures (2, &textures[0]);
1883 glBindTexture (GL_TEXTURE_2D, textures[0]);
1884 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1885 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
1886 FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
1887 expectError (GL_NO_ERROR);
1889 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1890 glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1891 expectError(GL_INVALID_VALUE);
1892 m_log << TestLog::EndSection;
1894 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1895 FOR_CUBE_FACES(faceGL,
1897 glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1898 expectError(GL_INVALID_VALUE);
1900 m_log << TestLog::EndSection;
1902 glDeleteTextures(2, &textures[0]);
1904 ES3F_ADD_API_CASE(compressedtexsubimage2d_max_level, "Invalid glCompressedTexSubImage2D() usage",
1906 deUint32 textures[2];
1907 glGenTextures (2, &textures[0]);
1908 glBindTexture (GL_TEXTURE_2D, textures[0]);
1909 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1910 glBindTexture (GL_TEXTURE_CUBE_MAP, textures[1]);
1911 FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
1912 expectError (GL_NO_ERROR);
1914 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1915 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1916 glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1917 expectError(GL_INVALID_VALUE);
1918 m_log << TestLog::EndSection;
1920 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1921 deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1922 FOR_CUBE_FACES(faceGL,
1924 glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1925 expectError(GL_INVALID_VALUE);
1927 m_log << TestLog::EndSection;
1929 glDeleteTextures(2, &textures[0]);
1931 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_offset, "Invalid glCompressedTexSubImage2D() usage",
1934 glGenTextures(1, &texture);
1935 glBindTexture(GL_TEXTURE_2D, texture);
1936 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, etc2EacDataSize(8, 8), 0);
1938 // \note Both GL_INVALID_VALUE and GL_INVALID_OPERATION are valid here since implementation may
1939 // first check if offsets are valid for certain format and only after that check that they
1940 // are not negative.
1941 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset or yoffset are negative.");
1943 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1944 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1945 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1946 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1947 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1948 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1950 m_log << TestLog::EndSection;
1952 glDeleteTextures(1, &texture);
1954 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_offset, "Invalid glCompressedTexSubImage2D() usage",
1957 glGenTextures (1, &texture);
1958 glBindTexture (GL_TEXTURE_2D, texture);
1959 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1960 expectError (GL_NO_ERROR);
1962 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1964 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 0, 8, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
1965 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1966 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 12, 4, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
1967 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1968 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 12, 8, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
1969 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1970 m_log << TestLog::EndSection;
1972 glDeleteTextures (1, &texture);
1974 ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_width_height, "Invalid glCompressedTexSubImage2D() usage",
1977 glGenTextures (1, &texture);
1978 glBindTexture (GL_TEXTURE_2D, texture);
1979 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1980 expectError (GL_NO_ERROR);
1982 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width or height is less than 0.");
1983 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1984 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1985 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1986 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1987 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1988 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1989 m_log << TestLog::EndSection;
1991 glDeleteTextures(1, &texture);
1993 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
1996 glGenTextures (1, &texture);
1997 glBindTexture (GL_TEXTURE_2D, texture);
1998 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1999 expectError (GL_NO_ERROR);
2001 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.");
2002 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2003 expectError(GL_INVALID_VALUE);
2005 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2006 expectError(GL_INVALID_VALUE);
2007 m_log << TestLog::EndSection;
2009 glDeleteTextures (1, &texture);
2011 ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_buffer_target, "Invalid glCompressedTexSubImage2D() usage",
2015 std::vector<GLubyte> data(128);
2017 glGenTextures (1, &texture);
2018 glBindTexture (GL_TEXTURE_2D, texture);
2019 glCompressedTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2020 glGenBuffers (1, &buf);
2021 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2022 glBufferData (GL_PIXEL_UNPACK_BUFFER, 128, &data[0], GL_DYNAMIC_COPY);
2023 expectError (GL_NO_ERROR);
2025 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...");
2026 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2027 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2028 glCompressedTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2029 expectError (GL_INVALID_OPERATION);
2030 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2031 m_log << TestLog::EndSection;
2033 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.");
2034 glCompressedTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2035 expectError (GL_INVALID_OPERATION);
2036 m_log << TestLog::EndSection;
2037 m_log << TestLog::EndSection;
2039 glDeleteBuffers (1, &buf);
2040 glDeleteTextures (1, &texture);
2045 ES3F_ADD_API_CASE(teximage3d, "Invalid glTexImage3D() usage",
2047 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2048 glTexImage3D(0, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2049 expectError(GL_INVALID_ENUM);
2050 glTexImage3D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2051 expectError(GL_INVALID_ENUM);
2052 m_log << TestLog::EndSection;
2054 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2055 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 0, 0);
2056 expectError(GL_INVALID_ENUM);
2057 m_log << TestLog::EndSection;
2059 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2060 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
2061 expectError(GL_INVALID_ENUM);
2062 m_log << TestLog::EndSection;
2064 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants "
2065 "or GL_INVALID_OPERATION is generated if internalformat, format and type are not compatible.");
2066 glTexImage3D(GL_TEXTURE_3D, 0, 0, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2067 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2068 m_log << TestLog::EndSection;
2070 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.");
2071 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, 0);
2072 expectError(GL_INVALID_OPERATION);
2073 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
2074 expectError(GL_INVALID_OPERATION);
2075 m_log << TestLog::EndSection;
2077 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
2078 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2079 expectError(GL_INVALID_OPERATION);
2080 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2081 expectError(GL_INVALID_OPERATION);
2082 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2083 expectError(GL_INVALID_OPERATION);
2084 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB10_A2, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
2085 expectError(GL_INVALID_OPERATION);
2086 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, 1, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
2087 expectError(GL_INVALID_OPERATION);
2088 m_log << TestLog::EndSection;
2090 ES3F_ADD_API_CASE(teximage3d_neg_level, "Invalid glTexImage3D() usage",
2092 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2093 glTexImage3D(GL_TEXTURE_3D, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2094 expectError(GL_INVALID_VALUE);
2095 glTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2096 expectError(GL_INVALID_VALUE);
2097 m_log << TestLog::EndSection;
2099 ES3F_ADD_API_CASE(teximage3d_max_level, "Invalid glTexImage3D() usage",
2101 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2102 deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2103 glTexImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2104 expectError(GL_INVALID_VALUE);
2105 m_log << TestLog::EndSection;
2107 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2108 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2109 glTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2110 expectError(GL_INVALID_VALUE);
2111 m_log << TestLog::EndSection;
2113 ES3F_ADD_API_CASE(teximage3d_neg_width_height_depth, "Invalid glTexImage3D() usage",
2115 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
2116 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2117 expectError(GL_INVALID_VALUE);
2118 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2119 expectError(GL_INVALID_VALUE);
2120 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2121 expectError(GL_INVALID_VALUE);
2122 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2123 expectError(GL_INVALID_VALUE);
2125 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2126 expectError(GL_INVALID_VALUE);
2127 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2128 expectError(GL_INVALID_VALUE);
2129 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2130 expectError(GL_INVALID_VALUE);
2131 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2132 expectError(GL_INVALID_VALUE);
2133 m_log << TestLog::EndSection;
2135 ES3F_ADD_API_CASE(teximage3d_max_width_height_depth, "Invalid glTexImage3D() usage",
2137 int max3DTextureSize = m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE) + 1;
2138 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2140 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_3D_TEXTURE_SIZE.");
2141 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2142 expectError(GL_INVALID_VALUE);
2143 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, max3DTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2144 expectError(GL_INVALID_VALUE);
2145 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2146 expectError(GL_INVALID_VALUE);
2147 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2148 expectError(GL_INVALID_VALUE);
2149 m_log << TestLog::EndSection;
2151 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2152 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2153 expectError(GL_INVALID_VALUE);
2154 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, maxTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2155 expectError(GL_INVALID_VALUE);
2156 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2157 expectError(GL_INVALID_VALUE);
2158 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, maxTextureSize, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2159 expectError(GL_INVALID_VALUE);
2160 m_log << TestLog::EndSection;
2162 ES3F_ADD_API_CASE(teximage3d_invalid_border, "Invalid glTexImage3D() usage",
2164 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0 or 1.");
2165 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2166 expectError(GL_INVALID_VALUE);
2167 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2168 expectError(GL_INVALID_VALUE);
2169 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2170 expectError(GL_INVALID_VALUE);
2171 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2172 expectError(GL_INVALID_VALUE);
2173 m_log << TestLog::EndSection;
2175 ES3F_ADD_API_CASE(teximage3d_invalid_buffer_target, "Invalid glTexImage3D() usage",
2179 std::vector<GLubyte> data(512);
2181 glGenBuffers (1, &buf);
2182 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2183 glBufferData (GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2184 glGenTextures (1, &texture);
2185 glBindTexture (GL_TEXTURE_3D, texture);
2186 expectError (GL_NO_ERROR);
2188 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...");
2190 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2191 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2192 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2193 expectError (GL_INVALID_OPERATION);
2194 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2195 m_log << TestLog::EndSection;
2197 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.");
2198 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 64, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2199 expectError (GL_INVALID_OPERATION);
2200 m_log << TestLog::EndSection;
2202 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2203 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2204 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGB5_A1, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
2205 expectError (GL_INVALID_OPERATION);
2206 m_log << TestLog::EndSection;
2208 m_log << TestLog::EndSection;
2210 glDeleteBuffers (1, &buf);
2211 glDeleteTextures (1, &texture);
2216 ES3F_ADD_API_CASE(texsubimage3d, "Invalid glTexSubImage3D() usage",
2219 glGenTextures (1, &texture);
2220 glBindTexture (GL_TEXTURE_3D, texture);
2221 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2222 expectError (GL_NO_ERROR);
2224 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2225 glTexSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2226 expectError(GL_INVALID_ENUM);
2227 glTexSubImage3D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2228 expectError(GL_INVALID_ENUM);
2229 m_log << TestLog::EndSection;
2231 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2232 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, GL_UNSIGNED_BYTE, 0);
2233 expectError(GL_INVALID_ENUM);
2234 m_log << TestLog::EndSection;
2236 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2237 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, 0, 0);
2238 expectError(GL_INVALID_ENUM);
2239 m_log << TestLog::EndSection;
2241 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.");
2242 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2243 expectError(GL_INVALID_OPERATION);
2244 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2245 expectError(GL_INVALID_OPERATION);
2246 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2247 expectError(GL_INVALID_OPERATION);
2248 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
2249 expectError(GL_INVALID_OPERATION);
2250 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_FLOAT, 0);
2251 expectError(GL_INVALID_OPERATION);
2252 m_log << tcu::TestLog::EndSection;
2254 glDeleteTextures (1, &texture);
2256 ES3F_ADD_API_CASE(texsubimage3d_neg_level, "Invalid glTexSubImage3D() usage",
2258 deUint32 textures[2];
2259 glGenTextures (2, &textures[0]);
2260 glBindTexture (GL_TEXTURE_3D, textures[0]);
2261 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2262 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2263 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2264 expectError (GL_NO_ERROR);
2266 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2267 glTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2268 expectError(GL_INVALID_VALUE);
2269 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2270 expectError(GL_INVALID_VALUE);
2271 m_log << TestLog::EndSection;
2273 glDeleteTextures (2, &textures[0]);
2275 ES3F_ADD_API_CASE(texsubimage3d_max_level, "Invalid glTexSubImage3D() usage",
2277 deUint32 textures[2];
2278 glGenTextures (2, &textures[0]);
2279 glBindTexture (GL_TEXTURE_3D, textures[0]);
2280 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2281 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2282 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2283 expectError (GL_NO_ERROR);
2285 deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2286 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2288 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2289 glTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2290 expectError(GL_INVALID_VALUE);
2291 m_log << TestLog::EndSection;
2293 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2294 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2295 expectError(GL_INVALID_VALUE);
2296 m_log << TestLog::EndSection;
2298 glDeleteTextures (2, &textures[0]);
2300 ES3F_ADD_API_CASE(texsubimage3d_neg_offset, "Invalid glTexSubImage3D() usage",
2302 deUint32 textures[2];
2303 glGenTextures (2, &textures[0]);
2304 glBindTexture (GL_TEXTURE_3D, textures[0]);
2305 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2306 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2307 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2308 expectError (GL_NO_ERROR);
2310 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.");
2311 glTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2312 expectError(GL_INVALID_VALUE);
2313 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2314 expectError(GL_INVALID_VALUE);
2315 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2316 expectError(GL_INVALID_VALUE);
2317 glTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2318 expectError(GL_INVALID_VALUE);
2319 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2320 expectError(GL_INVALID_VALUE);
2321 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2322 expectError(GL_INVALID_VALUE);
2323 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2324 expectError(GL_INVALID_VALUE);
2325 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2326 expectError(GL_INVALID_VALUE);
2327 m_log << TestLog::EndSection;
2329 glDeleteTextures (2, &textures[0]);
2331 ES3F_ADD_API_CASE(texsubimage3d_invalid_offset, "Invalid glTexSubImage3D() usage",
2334 glGenTextures (1, &texture);
2335 glBindTexture (GL_TEXTURE_3D, texture);
2336 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2337 expectError (GL_NO_ERROR);
2339 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2340 glTexSubImage3D(GL_TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2341 expectError(GL_INVALID_VALUE);
2342 m_log << TestLog::EndSection;
2344 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2345 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2346 expectError(GL_INVALID_VALUE);
2347 m_log << TestLog::EndSection;
2349 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + depth > texture_depth.");
2350 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2351 expectError(GL_INVALID_VALUE);
2352 m_log << TestLog::EndSection;
2354 glDeleteTextures (1, &texture);
2356 ES3F_ADD_API_CASE(texsubimage3d_neg_width_height, "Invalid glTexSubImage3D() usage",
2358 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2359 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2360 expectError(GL_INVALID_VALUE);
2361 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2362 expectError(GL_INVALID_VALUE);
2363 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2364 expectError(GL_INVALID_VALUE);
2365 glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2366 expectError(GL_INVALID_VALUE);
2367 m_log << TestLog::EndSection;
2369 ES3F_ADD_API_CASE(texsubimage3d_invalid_buffer_target, "Invalid glTexSubImage3D() usage",
2373 std::vector<GLubyte> data(512);
2375 glGenTextures (1, &texture);
2376 glBindTexture (GL_TEXTURE_3D, texture);
2377 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2378 glGenBuffers (1, &buf);
2379 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2380 glBufferData (GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2381 expectError (GL_NO_ERROR);
2383 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...");
2385 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2386 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 512, GL_MAP_WRITE_BIT);
2387 glTexSubImage3D (GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2388 expectError (GL_INVALID_OPERATION);
2389 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2390 m_log << TestLog::EndSection;
2392 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.");
2393 glTexSubImage3D (GL_TEXTURE_3D, 0, 0, 0, 0, 16, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2394 expectError (GL_INVALID_OPERATION);
2395 m_log << TestLog::EndSection;
2397 m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2398 m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2399 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
2400 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2401 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2402 expectError (GL_NO_ERROR);
2403 glTexSubImage3D (GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
2404 expectError (GL_INVALID_OPERATION);
2405 m_log << TestLog::EndSection;
2407 m_log << TestLog::EndSection;
2409 glDeleteBuffers (1, &buf);
2410 glDeleteTextures (1, &texture);
2413 // glCopyTexSubImage3D
2415 ES3F_ADD_API_CASE(copytexsubimage3d, "Invalid glCopyTexSubImage3D() usage",
2418 glGenTextures (1, &texture);
2419 glBindTexture (GL_TEXTURE_3D, texture);
2420 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2422 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2423 glCopyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 4);
2424 expectError(GL_INVALID_ENUM);
2425 m_log << TestLog::EndSection;
2427 glDeleteTextures(1, &texture);
2429 ES3F_ADD_API_CASE(copytexsubimage3d_neg_level, "Invalid glCopyTexSubImage3D() usage",
2431 deUint32 textures[2];
2432 glGenTextures (2, &textures[0]);
2433 glBindTexture (GL_TEXTURE_3D, textures[0]);
2434 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2435 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2436 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2437 expectError (GL_NO_ERROR);
2439 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2440 glCopyTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 4);
2441 expectError(GL_INVALID_VALUE);
2442 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
2443 expectError(GL_INVALID_VALUE);
2444 m_log << TestLog::EndSection;
2446 glDeleteTextures(2, &textures[0]);
2448 ES3F_ADD_API_CASE(copytexsubimage3d_max_level, "Invalid glCopyTexSubImage3D() usage",
2450 deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2451 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2453 deUint32 textures[2];
2454 glGenTextures (2, &textures[0]);
2455 glBindTexture (GL_TEXTURE_3D, textures[0]);
2456 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2457 glBindTexture (GL_TEXTURE_2D_ARRAY, textures[1]);
2458 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2459 expectError (GL_NO_ERROR);
2461 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2462 glCopyTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 4);
2463 expectError(GL_INVALID_VALUE);
2464 m_log << TestLog::EndSection;
2466 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2467 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 4);
2468 expectError(GL_INVALID_VALUE);
2469 m_log << TestLog::EndSection;
2471 glDeleteTextures(2, &textures[0]);
2473 ES3F_ADD_API_CASE(copytexsubimage3d_neg_offset, "Invalid glCopyTexSubImage3D() usage",
2476 glGenTextures (1, &texture);
2477 glBindTexture (GL_TEXTURE_3D, texture);
2478 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2480 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.");
2481 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 4, 4);
2482 expectError(GL_INVALID_VALUE);
2483 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4);
2484 expectError(GL_INVALID_VALUE);
2485 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4);
2486 expectError(GL_INVALID_VALUE);
2487 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4);
2488 expectError(GL_INVALID_VALUE);
2489 m_log << TestLog::EndSection;
2491 glDeleteTextures(1, &texture);
2493 ES3F_ADD_API_CASE(copytexsubimage3d_invalid_offset, "Invalid glCopyTexSubImage3D() usage",
2496 glGenTextures (1, &texture);
2497 glBindTexture (GL_TEXTURE_3D, texture);
2498 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2500 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2501 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4);
2502 expectError(GL_INVALID_VALUE);
2503 m_log << TestLog::EndSection;
2505 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2506 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4);
2507 expectError(GL_INVALID_VALUE);
2508 m_log << TestLog::EndSection;
2510 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + 1 > texture_depth.");
2511 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4);
2512 expectError(GL_INVALID_VALUE);
2513 m_log << TestLog::EndSection;
2515 glDeleteTextures(1, &texture);
2517 ES3F_ADD_API_CASE(copytexsubimage3d_neg_width_height, "Invalid glCopyTexSubImage3D() usage",
2520 glGenTextures (1, &texture);
2521 glBindTexture (GL_TEXTURE_3D, texture);
2522 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2524 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width < 0.");
2525 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4);
2526 expectError(GL_INVALID_VALUE);
2527 m_log << TestLog::EndSection;
2529 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if height < 0.");
2530 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4);
2531 expectError(GL_INVALID_VALUE);
2532 m_log << TestLog::EndSection;
2534 glDeleteTextures(1, &texture);
2536 ES3F_ADD_API_CASE(copytexsubimage3d_incomplete_framebuffer, "Invalid glCopyTexSubImage3D() usage",
2541 glGenTextures (2, texture);
2542 glBindTexture (GL_TEXTURE_3D, texture[0]);
2543 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2544 glBindTexture (GL_TEXTURE_2D_ARRAY, texture[1]);
2545 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2546 glGenFramebuffers (1, &fbo);
2547 glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo);
2548 glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
2550 m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
2551 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4);
2552 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2553 glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
2554 expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2555 m_log << tcu::TestLog::EndSection;
2557 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2558 glDeleteFramebuffers(1, &fbo);
2559 glDeleteTextures(2, texture);
2562 // glCompressedTexImage3D
2564 ES3F_ADD_API_CASE(compressedteximage3d, "Invalid glCompressedTexImage3D() usage",
2566 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2567 glCompressedTexImage3D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2568 expectError(GL_INVALID_ENUM);
2569 glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2570 expectError(GL_INVALID_ENUM);
2571 m_log << TestLog::EndSection;
2573 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.");
2574 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, 0);
2575 expectError(GL_INVALID_ENUM);
2576 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 0, 0, 0, 0, 0, 0);
2577 expectError(GL_INVALID_ENUM);
2578 m_log << TestLog::EndSection;
2580 ES3F_ADD_API_CASE(compressedteximage3d_neg_level, "Invalid glCompressedTexImage3D() usage",
2582 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2583 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2584 expectError(GL_INVALID_VALUE);
2585 m_log << TestLog::EndSection;
2587 ES3F_ADD_API_CASE(compressedteximage3d_max_level, "Invalid glCompressedTexImage3D() usage",
2589 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2590 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2591 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2592 expectError(GL_INVALID_VALUE);
2593 m_log << TestLog::EndSection;
2595 ES3F_ADD_API_CASE(compressedteximage3d_neg_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2597 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2598 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0, 0);
2599 expectError(GL_INVALID_VALUE);
2600 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0, 0);
2601 expectError(GL_INVALID_VALUE);
2602 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0, 0);
2603 expectError(GL_INVALID_VALUE);
2604 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, 0, 0);
2605 expectError(GL_INVALID_VALUE);
2606 m_log << TestLog::EndSection;
2608 ES3F_ADD_API_CASE(compressedteximage3d_max_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2610 int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2612 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2613 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, 0, 0);
2614 expectError(GL_INVALID_VALUE);
2615 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, 0, 0);
2616 expectError(GL_INVALID_VALUE);
2617 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureSize, 0, 0, 0);
2618 expectError(GL_INVALID_VALUE);
2619 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, maxTextureSize, 0, 0, 0);
2620 expectError(GL_INVALID_VALUE);
2621 m_log << TestLog::EndSection;
2623 ES3F_ADD_API_CASE(compressedteximage3d_invalid_border, "Invalid glCompressedTexImage3D() usage",
2625 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
2626 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0, 0);
2627 expectError(GL_INVALID_VALUE);
2628 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, 0, 0);
2629 expectError(GL_INVALID_VALUE);
2630 m_log << TestLog::EndSection;
2632 ES3F_ADD_API_CASE(compressedteximage3d_invalid_size, "Invalid glCompressedTexImage3D() usage",
2634 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.");
2635 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, -1, 0);
2636 expectError(GL_INVALID_VALUE);
2637 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*8, 0);
2638 expectError(GL_INVALID_VALUE);
2639 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, 4*4*16, 0);
2640 expectError(GL_INVALID_VALUE);
2641 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, 4*4*16, 0);
2642 expectError(GL_INVALID_VALUE);
2643 m_log << TestLog::EndSection;
2645 ES3F_ADD_API_CASE(compressedteximage3d_invalid_buffer_target, "Invalid glCompressedTexImage3D() usage",
2648 std::vector<GLubyte> data(512);
2650 glGenBuffers (1, &buf);
2651 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2652 glBufferData (GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
2653 expectError (GL_NO_ERROR);
2655 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.");
2656 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, 64, GL_MAP_WRITE_BIT);
2657 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 1, 0, etc2DataSize(4, 4), 0);
2658 expectError (GL_INVALID_OPERATION);
2659 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2660 m_log << TestLog::EndSection;
2662 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.");
2663 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, etc2DataSize(16, 16), 0);
2664 expectError (GL_INVALID_OPERATION);
2665 m_log << TestLog::EndSection;
2667 glDeleteBuffers (1, &buf);
2669 ES3F_ADD_API_CASE(compressedteximage3d_invalid_astc_target, "Invalid glCompressedTexImage3D() ASTC 3D targets",
2671 // GLES 3.0.4, Sec 3.8.6, p.147: For example, the
2672 // compressed image format might be supported only for 2D
2673 // textures ... result in an INVALID_OPERATION error.
2674 // Also, if LDR is supported, formats cannot be invalid enums
2675 // \todo [2015-05-14 kalle] The test is subject to change from Khronos bug 13921 and 13862
2677 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2678 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
2680 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
2684 const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
2686 if (requiredError == GL_INVALID_OPERATION)
2687 m_log.writeMessage("GL_INVALID_OPERATION should be generated if any TexImage3D target works with LDR ASTC.");
2689 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
2691 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
2693 const GLuint format = s_astcFormats[formatNdx];
2694 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
2695 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
2696 const size_t blockBytes = getBlockSize(tcuFormat);
2697 const vector<deUint8> dummyData (blockBytes);
2699 glCompressedTexImage3D(GL_TEXTURE_3D, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0, blockBytes, &dummyData[0]);
2700 expectError(requiredError);
2702 glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0, blockBytes, &dummyData[0]);
2703 expectError(requiredError);
2708 // glCompressedTexSubImage3D
2710 ES3F_ADD_API_CASE(compressedtexsubimage3d, "Invalid glCompressedTexSubImage3D() usage",
2712 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2713 glCompressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2714 expectError(GL_INVALID_ENUM);
2715 m_log << TestLog::EndSection;
2718 glGenTextures (1, &texture);
2719 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2720 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0, etc2EacDataSize(18, 18), 0);
2721 expectError (GL_NO_ERROR);
2723 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
2724 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
2725 expectError(GL_INVALID_OPERATION);
2726 m_log << TestLog::EndSection;
2728 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.");
2729 glCompressedTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(18, 18), 0);
2730 expectError(GL_INVALID_OPERATION);
2731 m_log << TestLog::EndSection;
2733 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.");
2734 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
2735 expectError(GL_INVALID_OPERATION);
2736 m_log << TestLog::EndSection;
2738 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.");
2739 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
2740 expectError(GL_INVALID_OPERATION);
2741 m_log << TestLog::EndSection;
2743 m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
2744 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2745 expectError(GL_INVALID_OPERATION);
2746 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2747 expectError(GL_INVALID_OPERATION);
2748 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2749 expectError(GL_INVALID_OPERATION);
2750 m_log << TestLog::EndSection;
2752 glDeleteTextures (1, &texture);
2754 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_level, "Invalid glCompressedTexSubImage3D() usage",
2757 glGenTextures (1, &texture);
2758 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2759 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2760 expectError (GL_NO_ERROR);
2762 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2763 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2764 expectError(GL_INVALID_VALUE);
2765 m_log << TestLog::EndSection;
2767 glDeleteTextures (1, &texture);
2769 ES3F_ADD_API_CASE(compressedtexsubimage3d_max_level, "Invalid glCompressedTexSubImage3D() usage",
2772 glGenTextures (1, &texture);
2773 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2774 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2775 expectError (GL_NO_ERROR);
2777 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2778 deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2779 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2780 expectError(GL_INVALID_VALUE);
2781 m_log << TestLog::EndSection;
2783 glDeleteTextures (1, &texture);
2785 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_offset, "Invalid glCompressedTexSubImage3D() usage",
2788 glGenTextures (1, &texture);
2789 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2790 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2791 expectError (GL_NO_ERROR);
2793 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.");
2794 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2795 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2796 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2797 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2798 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2799 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2800 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2801 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2802 m_log << TestLog::EndSection;
2804 glDeleteTextures (1, &texture);
2806 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_offset, "Invalid glCompressedTexSubImage3D() usage",
2809 glGenTextures (1, &texture);
2810 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2811 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, etc2EacDataSize(4, 4), 0);
2812 expectError (GL_NO_ERROR);
2814 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
2816 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
2817 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2818 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
2819 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2820 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2821 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2822 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
2823 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2824 m_log << TestLog::EndSection;
2826 glDeleteTextures (1, &texture);
2828 ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_width_height_depth, "Invalid glCompressedTexSubImage3D() usage",
2831 glGenTextures (1, &texture);
2832 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2833 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2834 expectError (GL_NO_ERROR);
2836 m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width, height or depth are negative.");
2837 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2838 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2839 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2840 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2841 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2842 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2843 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2844 expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2845 m_log << TestLog::EndSection;
2847 glDeleteTextures (1, &texture);
2849 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_size, "Invalid glCompressedTexSubImage3D() usage",
2852 glGenTextures (1, &texture);
2853 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2854 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*16, 0);
2855 expectError (GL_NO_ERROR);
2857 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.");
2858 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2859 expectError(GL_INVALID_VALUE);
2861 glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2862 expectError(GL_INVALID_VALUE);
2863 m_log << TestLog::EndSection;
2865 glDeleteTextures (1, &texture);
2867 ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_buffer_target, "Invalid glCompressedTexSubImage3D() usage",
2871 GLsizei bufferSize = etc2EacDataSize(4, 4);
2872 std::vector<GLubyte> data(bufferSize);
2874 glGenTextures (1, &texture);
2875 glBindTexture (GL_TEXTURE_2D_ARRAY, texture);
2876 glCompressedTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2877 glGenBuffers (1, &buf);
2878 glBindBuffer (GL_PIXEL_UNPACK_BUFFER, buf);
2879 glBufferData (GL_PIXEL_UNPACK_BUFFER, bufferSize, &data[0], GL_DYNAMIC_COPY);
2880 expectError (GL_NO_ERROR);
2882 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...");
2883 m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2884 glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, GL_MAP_WRITE_BIT);
2885 glCompressedTexSubImage3D (GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2886 expectError (GL_INVALID_OPERATION);
2887 glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
2888 m_log << TestLog::EndSection;
2890 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.");
2891 glCompressedTexSubImage3D (GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2892 expectError (GL_INVALID_OPERATION);
2893 m_log << TestLog::EndSection;
2894 m_log << TestLog::EndSection;
2896 glDeleteBuffers (1, &buf);
2897 glDeleteTextures (1, &texture);
2902 ES3F_ADD_API_CASE(texstorage2d, "Invalid glTexStorage2D() usage",
2905 glGenTextures (1, &texture);
2906 glBindTexture (GL_TEXTURE_2D, texture);
2908 m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
2909 glTexStorage2D (GL_TEXTURE_2D, 1, 0, 16, 16);
2910 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
2911 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, 16, 16);
2912 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
2913 m_log << TestLog::EndSection;
2915 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
2916 glTexStorage2D (0, 1, GL_RGBA8, 16, 16);
2917 expectError (GL_INVALID_ENUM);
2918 glTexStorage2D (GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16);
2919 expectError (GL_INVALID_ENUM);
2920 glTexStorage2D (GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16);
2921 expectError (GL_INVALID_ENUM);
2922 m_log << TestLog::EndSection;
2924 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height are less than 1.");
2925 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 0, 16);
2926 expectError (GL_INVALID_VALUE);
2927 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 0);
2928 expectError (GL_INVALID_VALUE);
2929 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 0, 0);
2930 expectError (GL_INVALID_VALUE);
2931 m_log << TestLog::EndSection;
2933 glDeleteTextures(1, &texture);
2936 ES3F_ADD_API_CASE(texstorage2d_invalid_binding, "Invalid glTexStorage2D() usage",
2938 glBindTexture (GL_TEXTURE_2D, 0);
2940 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
2941 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2942 expectError (GL_INVALID_OPERATION);
2943 m_log << TestLog::EndSection;
2946 glGenTextures (1, &texture);
2947 glBindTexture (GL_TEXTURE_2D, texture);
2949 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.");
2950 deInt32 immutable = -1;
2951 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
2952 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
2953 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2954 expectError (GL_NO_ERROR);
2955 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
2956 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
2957 glTexStorage2D (GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2958 expectError (GL_INVALID_OPERATION);
2959 m_log << TestLog::EndSection;
2961 glDeleteTextures(1, &texture);
2963 ES3F_ADD_API_CASE(texstorage2d_invalid_levels, "Invalid glTexStorage2D() usage",
2966 glGenTextures (1, &texture);
2967 glBindTexture (GL_TEXTURE_2D, texture);
2969 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
2970 glTexStorage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16);
2971 expectError (GL_INVALID_VALUE);
2972 glTexStorage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0);
2973 expectError (GL_INVALID_VALUE);
2974 m_log << TestLog::EndSection;
2976 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1");
2977 deUint32 log2MaxSize = deLog2Floor32(deMax32(16, 4)) + 1 + 1;
2978 glTexStorage2D (GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 4);
2979 expectError (GL_INVALID_OPERATION);
2980 glTexStorage2D (GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 4, 16);
2981 expectError (GL_INVALID_OPERATION);
2982 glTexStorage2D (GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 16);
2983 expectError (GL_INVALID_OPERATION);
2984 m_log << TestLog::EndSection;
2986 glDeleteTextures(1, &texture);
2988 ES3F_ADD_API_CASE(texstorage2d_invalid_astc_target, "Invalid glTexStorage2D() ASTC 2D targets",
2990 // GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
2991 // for which this command would have been valid, an
2992 // INVALID_OPERATION error is generated. Also: If
2993 // executing the pseudo-code would result in any other
2994 // error, the error is generated and the command will have
2996 // In conclusion: Expect same errors as with TexImage?D
2998 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2999 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3001 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3005 const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
3007 if (requiredError == GL_INVALID_OPERATION)
3008 m_log.writeMessage("GL_INVALID_OPERATION should be generated if the cube map targets work with LDR ASTC.");
3010 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
3012 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3014 const GLuint format = s_astcFormats[formatNdx];
3015 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
3016 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
3018 glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, format, blockPixels.x(), blockPixels.y());
3019 expectError(requiredError);
3026 ES3F_ADD_API_CASE(texstorage3d, "Invalid glTexStorage3D() usage",
3029 glGenTextures (1, &texture);
3030 glBindTexture (GL_TEXTURE_3D, texture);
3032 m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3033 glTexStorage3D (GL_TEXTURE_3D, 1, 0, 4, 4, 4);
3034 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
3035 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA_INTEGER, 4, 4, 4);
3036 expectError (GL_INVALID_ENUM, GL_INVALID_VALUE);
3037 m_log << TestLog::EndSection;
3039 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3040 glTexStorage3D (0, 1, GL_RGBA8, 4, 4, 4);
3041 expectError (GL_INVALID_ENUM);
3042 glTexStorage3D (GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 4, 4, 4);
3043 expectError (GL_INVALID_ENUM);
3044 glTexStorage3D (GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 4);
3045 expectError (GL_INVALID_ENUM);
3046 m_log << TestLog::EndSection;
3048 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth are less than 1.");
3049 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 0, 4, 4);
3050 expectError (GL_INVALID_VALUE);
3051 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 0, 4);
3052 expectError (GL_INVALID_VALUE);
3053 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 0);
3054 expectError (GL_INVALID_VALUE);
3055 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 0, 0, 0);
3056 expectError (GL_INVALID_VALUE);
3057 m_log << TestLog::EndSection;
3059 glDeleteTextures(1, &texture);
3061 ES3F_ADD_API_CASE(texstorage3d_invalid_binding, "Invalid glTexStorage3D() usage",
3063 glBindTexture (GL_TEXTURE_3D, 0);
3065 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3066 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3067 expectError (GL_INVALID_OPERATION);
3068 m_log << TestLog::EndSection;
3071 glGenTextures (1, &texture);
3072 glBindTexture (GL_TEXTURE_3D, texture);
3074 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.");
3075 deInt32 immutable = -1;
3076 glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3077 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3078 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3079 expectError (GL_NO_ERROR);
3080 glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3081 m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3082 glTexStorage3D (GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3083 expectError (GL_INVALID_OPERATION);
3084 m_log << TestLog::EndSection;
3086 glDeleteTextures(1, &texture);
3088 ES3F_ADD_API_CASE(texstorage3d_invalid_levels, "Invalid glTexStorage3D() usage",
3091 glGenTextures (1, &texture);
3092 glBindTexture (GL_TEXTURE_3D, texture);
3094 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
3095 glTexStorage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4);
3096 expectError (GL_INVALID_VALUE);
3097 glTexStorage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 0, 0, 0);
3098 expectError (GL_INVALID_VALUE);
3099 m_log << TestLog::EndSection;
3101 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1");
3102 deUint32 log2MaxSize = deLog2Floor32(8) + 1 + 1;
3103 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 2, 2);
3104 expectError (GL_INVALID_OPERATION);
3105 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 8, 2);
3106 expectError (GL_INVALID_OPERATION);
3107 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 2, 8);
3108 expectError (GL_INVALID_OPERATION);
3109 glTexStorage3D (GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 8, 8);
3110 expectError (GL_INVALID_OPERATION);
3111 m_log << TestLog::EndSection;
3113 glDeleteTextures(1, &texture);
3116 ES3F_ADD_API_CASE(texstorage3d_invalid_astc_target, "Invalid glTexStorage3D() ASTC 3D targets",
3118 // GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
3119 // for which this command would have been valid, an
3120 // INVALID_OPERATION error is generated. Also: If
3121 // executing the pseudo-code would result in any other
3122 // error, the error is generated and the command will have
3124 // In conclusion: Expect same errors as with TexImage?D
3126 if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
3127 m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3129 m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3133 const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
3135 if (requiredError == GL_INVALID_OPERATION)
3136 m_log.writeMessage("GL_INVALID_OPERATION should be generated if any TexStorage3D target works with LDR.");
3138 m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
3140 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3142 const GLuint format = s_astcFormats[formatNdx];
3143 const CompressedTexFormat tcuFormat = mapGLCompressedTexFormat(format);
3144 const IVec3 blockPixels = getBlockPixelSize(tcuFormat);
3146 glTexStorage3D(GL_TEXTURE_3D, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3147 expectError(requiredError);
3149 glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3150 expectError(requiredError);