es3fNegativeTextureApiTests.cpp revision 52d6edcdcca76e37a086b9e1938cd0f86f3feaa4
1/*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Negative Texture API tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "es3fNegativeTextureApiTests.hpp"
25#include "es3fApiCase.hpp"
26#include "gluContextInfo.hpp"
27#include "tcuFormatUtil.hpp"
28#include "gluTextureUtil.hpp"
29
30#include <vector>
31#include <algorithm>
32
33#include "glwDefs.hpp"
34#include "glwEnums.hpp"
35
36using namespace glw; // GL types
37
38namespace deqp
39{
40namespace gles3
41{
42namespace Functional
43{
44
45using tcu::TestLog;
46using tcu::CompressedTexFormat;
47using tcu::getBlockSize;
48using tcu::getBlockPixelSize;
49using tcu::IVec3;
50using glu::mapGLCompressedTexFormat;
51using std::vector;
52
53static inline int divRoundUp (int a, int b)
54{
55	return a/b + (a%b != 0 ? 1 : 0);
56}
57
58static inline int etc2DataSize (int width, int height)
59{
60	return (int)(divRoundUp(width, 4) * divRoundUp(height, 4) * sizeof(deUint64));
61}
62
63static inline int etc2EacDataSize (int width, int height)
64{
65	return 2 * etc2DataSize(width, height);
66}
67
68static const GLuint s_astcFormats[] =
69{
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
98};
99
100static deUint32 cubeFaceToGLFace (tcu::CubeFace face)
101{
102	switch (face)
103	{
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;
110		default:
111			DE_ASSERT(DE_FALSE);
112			return GL_NONE;
113	}
114}
115
116#define FOR_CUBE_FACES(FACE_GL_VAR, BODY)												\
117	do																					\
118	{																					\
119		for (int faceIterTcu = 0; faceIterTcu < tcu::CUBEFACE_LAST; faceIterTcu++)		\
120		{																				\
121			const GLenum FACE_GL_VAR = cubeFaceToGLFace((tcu::CubeFace)faceIterTcu);	\
122			BODY																		\
123		}																				\
124	} while (false)
125
126NegativeTextureApiTests::NegativeTextureApiTests (Context& context)
127	: TestCaseGroup(context, "texture", "Negative Texture API Cases")
128{
129}
130
131NegativeTextureApiTests::~NegativeTextureApiTests (void)
132{
133}
134
135void NegativeTextureApiTests::init (void)
136{
137	// glActiveTexture
138
139	ES3F_ADD_API_CASE(activetexture, "Invalid glActiveTexture() usage",
140		{
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).");
142			glActiveTexture(-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;
148		});
149
150	// glBindTexture
151
152	ES3F_ADD_API_CASE(bindtexture, "Invalid glBindTexture() usage",
153		{
154			GLuint texture[2];
155			glGenTextures(2, texture);
156
157			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the allowable values.");
158			glBindTexture(0, 1);
159			expectError(GL_INVALID_ENUM);
160			glBindTexture(GL_FRAMEBUFFER, 1);
161			expectError(GL_INVALID_ENUM);
162			m_log << TestLog::EndSection;
163
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);
173
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;
183
184			glDeleteTextures(2, texture);
185		});
186
187	// glCompressedTexImage2D
188
189	ES3F_ADD_API_CASE(compressedteximage2d_invalid_target, "Invalid glCompressedTexImage2D() usage",
190		{
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;
197		});
198	ES3F_ADD_API_CASE(compressedteximage2d_invalid_format, "Invalid glCompressedTexImage2D() usage",
199		{
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;
220		});
221	ES3F_ADD_API_CASE(compressedteximage2d_neg_level, "Invalid glCompressedTexImage2D() usage",
222		{
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;
239		});
240	ES3F_ADD_API_CASE(compressedteximage2d_max_level, "Invalid glCompressedTexImage2D() usage",
241		{
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;
247
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;
263		});
264	ES3F_ADD_API_CASE(compressedteximage2d_neg_width_height, "Invalid glCompressedTexImage2D() usage",
265		{
266			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
267
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;
276
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;
285
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;
294
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;
303
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;
312
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;
321
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;
330
331			m_log << TestLog::EndSection;
332		});
333	ES3F_ADD_API_CASE(compressedteximage2d_max_width_height, "Invalid glCompressedTexImage2D() usage",
334		{
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.");
338
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;
347
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;
356
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;
365
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;
374
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;
383
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;
392
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;
401
402			m_log << TestLog::EndSection;
403		});
404	ES3F_ADD_API_CASE(compressedteximage2d_invalid_border, "Invalid glCompressedTexImage2D() usage",
405		{
406			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
407
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;
414
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;
421
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;
428
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;
435
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;
442
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;
449
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;
456
457			m_log << TestLog::EndSection;
458		});
459	ES3F_ADD_API_CASE(compressedteximage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
460		{
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;
471		});
472	ES3F_ADD_API_CASE(compressedteximage2d_invalid_buffer_target, "Invalid glCompressedTexImage2D() usage",
473		{
474			deUint32				buf;
475			std::vector<GLubyte>	data(64);
476
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);
481
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;
488
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;
493
494			glDeleteBuffers			(1, &buf);
495		});
496	ES3F_ADD_API_CASE(compressedteximage2d_invalid_astc_target, "Invalid glCompressedTexImage2D() ASTC 2D targets",
497		{
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
502
503			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
504				m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
505			{
506				m_log.writeMessage("Full ASTC supported. No negative API requirements.");
507			}
508			else
509			{
510				const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
511
512				if (requiredError == GL_INVALID_OPERATION)
513					m_log.writeMessage("GL_INVALID_OPERATION should be generated if cube map targets work with LDR ASTC.");
514				else
515					m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
516
517				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
518				{
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);
524
525					FOR_CUBE_FACES(faceGL,
526					{
527						glCompressedTexImage2D(faceGL, 0, format, blockPixels.x(), blockPixels.y(), 0, blockBytes, &dummyData[0]);
528						expectError(requiredError);
529					});
530				}
531			}
532		});
533
534	// glCopyTexImage2D
535
536	ES3F_ADD_API_CASE(copyteximage2d_invalid_target, "Invalid glCopyTexImage2D() usage",
537		{
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;
542		});
543	ES3F_ADD_API_CASE(copyteximage2d_invalid_format, "Invalid glCopyTexImage2D() usage",
544		{
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;
561		});
562	ES3F_ADD_API_CASE(copyteximage2d_inequal_width_height_cube, "Invalid glCopyTexImage2D() usage",
563		{
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;
578		});
579	ES3F_ADD_API_CASE(copyteximage2d_neg_level, "Invalid glCopyTexImage2D() usage",
580		{
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;
597		});
598	ES3F_ADD_API_CASE(copyteximage2d_max_level, "Invalid glCopyTexImage2D() usage",
599		{
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;
605
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;
621		});
622	ES3F_ADD_API_CASE(copyteximage2d_neg_width_height, "Invalid glCopyTexImage2D() usage",
623		{
624			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
625
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;
634
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;
643
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;
652
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;
661
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;
670
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;
679
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;
688
689			m_log << TestLog::EndSection;
690		});
691	ES3F_ADD_API_CASE(copyteximage2d_max_width_height, "Invalid glCopyTexImage2D() usage",
692		{
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;
695
696			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
697
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;
706
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;
715
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;
724
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;
733
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;
742
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;
751
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;
760
761			m_log << TestLog::EndSection;
762		});
763	ES3F_ADD_API_CASE(copyteximage2d_invalid_border, "Invalid glCopyTexImage2D() usage",
764		{
765			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
766
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;
773
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;
780
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;
787
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;
794
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;
801
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;
808
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;
815
816			m_log << TestLog::EndSection;
817		});
818	ES3F_ADD_API_CASE(copyteximage2d_incomplete_framebuffer, "Invalid glCopyTexImage2D() usage",
819		{
820			GLuint fbo;
821			glGenFramebuffers		(1, &fbo);
822			glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
823			glCheckFramebufferStatus(GL_FRAMEBUFFER);
824
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;
841
842			glBindFramebuffer	(GL_FRAMEBUFFER, 0);
843			glDeleteFramebuffers(1, &fbo);
844		});
845
846	// glCopyTexSubImage2D
847
848	ES3F_ADD_API_CASE(copytexsubimage2d_invalid_target, "Invalid glCopyTexSubImage2D() usage",
849		{
850			GLuint texture;
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);
854
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;
859
860			glDeleteTextures(1, &texture);
861		});
862	ES3F_ADD_API_CASE(copytexsubimage2d_neg_level, "Invalid glCopyTexSubImage2D() usage",
863		{
864			GLuint textures[2];
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););
870
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,
875			{
876				glCopyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4);
877				expectError(GL_INVALID_VALUE);
878			});
879			m_log << TestLog::EndSection;
880
881			glDeleteTextures(2, &textures[0]);
882		});
883	ES3F_ADD_API_CASE(copytexsubimage2d_max_level, "Invalid glCopyTexSubImage2D() usage",
884		{
885			GLuint textures[2];
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););
891
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;
897
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,
901			{
902				glCopyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4);
903				expectError(GL_INVALID_VALUE);
904			});
905			m_log << TestLog::EndSection;
906
907			glDeleteTextures(2, &textures[0]);
908		});
909	ES3F_ADD_API_CASE(copytexsubimage2d_neg_offset, "Invalid glCopyTexSubImage2D() usage",
910		{
911			GLuint texture;
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);
915
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;
924
925			glDeleteTextures(1, &texture);
926		});
927	ES3F_ADD_API_CASE(copytexsubimage2d_invalid_offset, "Invalid glCopyTexSubImage2D() usage",
928		{
929			GLuint texture;
930			glGenTextures	(1, &texture);
931			glBindTexture	(GL_TEXTURE_2D, texture);
932			glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
933
934			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + 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;
942
943			glDeleteTextures(1, &texture);
944		});
945	ES3F_ADD_API_CASE(copytexsubimage2d_neg_width_height, "Invalid glCopyTexSubImage2D() usage",
946		{
947			GLuint texture;
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);
951
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;
960
961			glDeleteTextures(1, &texture);
962		});
963	ES3F_ADD_API_CASE(copytexsubimage2d_incomplete_framebuffer, "Invalid glCopyTexSubImage2D() usage",
964		{
965			m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
966
967			GLuint texture[2];
968			GLuint fbo;
969
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);
981
982			glGenFramebuffers(1, &fbo);
983			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
984			glCheckFramebufferStatus(GL_FRAMEBUFFER);
985			expectError(GL_NO_ERROR);
986
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);
1001
1002			glBindFramebuffer(GL_FRAMEBUFFER, 0);
1003			glDeleteFramebuffers(1, &fbo);
1004			glDeleteTextures(2, texture);
1005
1006			m_log << tcu::TestLog::EndSection;
1007		});
1008
1009	// glDeleteTextures
1010
1011	ES3F_ADD_API_CASE(deletetextures, "Invalid glDeleteTextures() usage",
1012		{
1013			GLuint texture;
1014			glGenTextures(1, &texture);
1015
1016			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1017			glDeleteTextures(-1, 0);
1018			expectError(GL_INVALID_VALUE);
1019
1020			glBindTexture(GL_TEXTURE_2D, texture);
1021			glDeleteTextures(-1, 0);
1022			expectError(GL_INVALID_VALUE);
1023			m_log << TestLog::EndSection;
1024
1025			glDeleteTextures(1, &texture);
1026		});
1027
1028	// glGenerateMipmap
1029
1030	ES3F_ADD_API_CASE(generatemipmap, "Invalid glGenerateMipmap() usage",
1031		{
1032			GLuint texture[2];
1033			glGenTextures(2, texture);
1034
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;
1039
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);
1046
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;
1057
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;
1064
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);
1072
1073			if (!(m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") && m_context.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
1074			{
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);
1078			}
1079
1080			m_log << TestLog::EndSection;
1081
1082			glDeleteTextures(2, texture);
1083		});
1084
1085	// glGenTextures
1086
1087	ES3F_ADD_API_CASE(gentextures, "Invalid glGenTextures() usage",
1088		{
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;
1093		});
1094
1095	// glPixelStorei
1096
1097	ES3F_ADD_API_CASE(pixelstorei, "Invalid glPixelStorei() usage",
1098		{
1099			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1100			glPixelStorei(0,1);
1101			expectError(GL_INVALID_ENUM);
1102			m_log << TestLog::EndSection;
1103
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;
1130		});
1131
1132	// glTexImage2D
1133
1134	ES3F_ADD_API_CASE(teximage2d, "Invalid glTexImage2D() usage",
1135		{
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;
1140
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;
1145
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;
1158		});
1159	ES3F_ADD_API_CASE(teximage2d_inequal_width_height_cube, "Invalid glTexImage2D() usage",
1160		{
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;
1175		});
1176	ES3F_ADD_API_CASE(teximage2d_neg_level, "Invalid glTexImage2D() usage",
1177		{
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;
1182
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;
1197		});
1198	ES3F_ADD_API_CASE(teximage2d_max_level, "Invalid glTexImage2D() usage",
1199		{
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;
1205
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;
1221		});
1222	ES3F_ADD_API_CASE(teximage2d_neg_width_height, "Invalid glTexImage2D() usage",
1223		{
1224			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1225
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;
1234
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;
1243
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;
1252
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;
1261
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;
1270
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;
1279
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;
1288
1289			m_log << TestLog::EndSection;
1290		});
1291	ES3F_ADD_API_CASE(teximage2d_max_width_height, "Invalid glTexImage2D() usage",
1292		{
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;
1295
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;
1304
1305			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1306
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;
1315
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;
1324
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;
1333
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;
1342
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;
1351
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;
1360
1361			m_log << TestLog::EndSection;
1362		});
1363	ES3F_ADD_API_CASE(teximage2d_invalid_border, "Invalid glTexImage2D() usage",
1364		{
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;
1383		});
1384	ES3F_ADD_API_CASE(teximage2d_invalid_buffer_target, "Invalid glTexImage2D() usage",
1385		{
1386			deUint32				buf;
1387			deUint32				texture;
1388			std::vector<GLubyte>	data(64);
1389
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);
1396
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;
1404
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;
1409
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;
1416
1417			glDeleteBuffers			(1, &buf);
1418			glDeleteTextures		(1, &texture);
1419		});
1420
1421	// glTexSubImage2D
1422
1423	ES3F_ADD_API_CASE(texsubimage2d, "Invalid glTexSubImage2D() usage",
1424		{
1425			deUint32			texture;
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);
1430
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;
1435
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;
1440
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;
1445
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;
1460
1461			glDeleteTextures	(1, &texture);
1462		});
1463	ES3F_ADD_API_CASE(texsubimage2d_neg_level, "Invalid glTexSubImage2D() usage",
1464		{
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);
1472
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;
1477
1478			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1479			FOR_CUBE_FACES(faceGL,
1480			{
1481				glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1482				expectError(GL_INVALID_VALUE);
1483			});
1484			m_log << TestLog::EndSection;
1485
1486			glDeleteTextures(2, &textures[0]);
1487		});
1488	ES3F_ADD_API_CASE(texsubimage2d_max_level, "Invalid glTexSubImage2D() usage",
1489		{
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);
1497
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;
1503
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,
1507			{
1508				glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1509				expectError(GL_INVALID_VALUE);
1510			});
1511			m_log << TestLog::EndSection;
1512
1513			glDeleteTextures(2, &textures[0]);
1514		});
1515	ES3F_ADD_API_CASE(texsubimage2d_neg_offset, "Invalid glTexSubImage2D() usage",
1516		{
1517			deUint32 texture;
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);
1522
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;
1531
1532			glDeleteTextures(1, &texture);
1533		});
1534	ES3F_ADD_API_CASE(texsubimage2d_invalid_offset, "Invalid glTexSubImage2D() usage",
1535		{
1536			deUint32			texture;
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);
1541
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;
1550
1551			glDeleteTextures	(1, &texture);
1552		});
1553	ES3F_ADD_API_CASE(texsubimage2d_neg_width_height, "Invalid glTexSubImage2D() usage",
1554		{
1555			deUint32			texture;
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);
1560
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;
1569
1570			glDeleteTextures	(1, &texture);
1571		});
1572	ES3F_ADD_API_CASE(texsubimage2d_invalid_buffer_target, "Invalid glTexSubImage2D() usage",
1573		{
1574			deUint32				buf;
1575			deUint32				texture;
1576			std::vector<GLubyte>	data(64);
1577
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);
1585
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;
1593
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;
1598
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;
1609
1610			glDeleteBuffers			(1, &buf);
1611			glDeleteTextures		(1, &texture);
1612		});
1613
1614	// glTexParameteri
1615
1616	ES3F_ADD_API_CASE(texparameteri, "Invalid glTexParameteri() usage",
1617		{
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;
1626
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;
1637
1638			GLuint texture;
1639			glGenTextures(1, &texture);
1640			glBindTexture(GL_TEXTURE_2D, texture);
1641
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;
1650
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;
1661
1662			glDeleteTextures(1, &texture);
1663		});
1664
1665	// glTexParameterf
1666
1667	ES3F_ADD_API_CASE(texparameterf, "Invalid glTexParameterf() usage",
1668		{
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;
1677
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;
1688
1689			GLuint texture;
1690			glGenTextures(1, &texture);
1691			glBindTexture(GL_TEXTURE_2D, texture);
1692
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;
1701
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;
1712
1713			glDeleteTextures(1, &texture);
1714		});
1715
1716	// glTexParameteriv
1717
1718	ES3F_ADD_API_CASE(texparameteriv, "Invalid glTexParameteriv() usage",
1719		{
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, &params[0]);
1723			expectError(GL_INVALID_ENUM);
1724			glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
1725			expectError(GL_INVALID_ENUM);
1726			glTexParameteriv(0, 0, &params[0]);
1727			expectError(GL_INVALID_ENUM);
1728			m_log << TestLog::EndSection;
1729
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.");
1731			params[0] = 0;
1732			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1733			expectError(GL_INVALID_ENUM);
1734			params[0] = GL_REPEAT;
1735			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1736			expectError(GL_INVALID_ENUM);
1737			params[0] = 0;
1738			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1739			expectError(GL_INVALID_ENUM);
1740			params[0] = GL_NEAREST;
1741			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1742			expectError(GL_INVALID_ENUM);
1743			m_log << TestLog::EndSection;
1744
1745			GLuint texture;
1746			glGenTextures(1, &texture);
1747			glBindTexture(GL_TEXTURE_2D, texture);
1748
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, &params[0]);
1752			expectError(GL_INVALID_ENUM);
1753			glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
1754			expectError(GL_INVALID_ENUM);
1755			glTexParameteriv(0, 0, &params[0]);
1756			expectError(GL_INVALID_ENUM);
1757			m_log << TestLog::EndSection;
1758
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.");
1760			params[0] = 0;
1761			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1762			expectError(GL_INVALID_ENUM);
1763			params[0] = GL_REPEAT;
1764			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1765			expectError(GL_INVALID_ENUM);
1766			params[0] = 0;
1767			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1768			expectError(GL_INVALID_ENUM);
1769			params[0] = GL_NEAREST;
1770			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1771			expectError(GL_INVALID_ENUM);
1772			m_log << TestLog::EndSection;
1773
1774			glDeleteTextures(1, &texture);
1775		});
1776
1777	// glTexParameterfv
1778
1779	ES3F_ADD_API_CASE(texparameterfv, "Invalid glTexParameterfv() usage",
1780		{
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, &params[0]);
1784			expectError(GL_INVALID_ENUM);
1785			glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
1786			expectError(GL_INVALID_ENUM);
1787			glTexParameterfv(0, 0, &params[0]);
1788			expectError(GL_INVALID_ENUM);
1789			m_log << TestLog::EndSection;
1790
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.");
1792			params[0] = 0.0f;
1793			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1794			expectError(GL_INVALID_ENUM);
1795			params[0] = GL_REPEAT;
1796			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1797			expectError(GL_INVALID_ENUM);
1798			params[0] = 0.0f;
1799			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1800			expectError(GL_INVALID_ENUM);
1801			params[0] = GL_NEAREST;
1802			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1803			expectError(GL_INVALID_ENUM);
1804			m_log << TestLog::EndSection;
1805
1806			GLuint texture;
1807			glGenTextures(1, &texture);
1808			glBindTexture(GL_TEXTURE_2D, texture);
1809
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, &params[0]);
1813			expectError(GL_INVALID_ENUM);
1814			glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
1815			expectError(GL_INVALID_ENUM);
1816			glTexParameterfv(0, 0, &params[0]);
1817			expectError(GL_INVALID_ENUM);
1818			m_log << TestLog::EndSection;
1819
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.");
1821			params[0] = 0.0f;
1822			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1823			expectError(GL_INVALID_ENUM);
1824			params[0] = GL_REPEAT;
1825			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1826			expectError(GL_INVALID_ENUM);
1827			params[0] = 0.0f;
1828			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1829			expectError(GL_INVALID_ENUM);
1830			params[0] = GL_NEAREST;
1831			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1832			expectError(GL_INVALID_ENUM);
1833			m_log << TestLog::EndSection;
1834
1835			glDeleteTextures(1, &texture);
1836		});
1837
1838	// glCompressedTexSubImage2D
1839
1840	ES3F_ADD_API_CASE(compressedtexsubimage2d, "Invalid glCompressedTexSubImage2D() usage",
1841		{
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;
1846
1847			deUint32				texture;
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);
1852
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;
1857
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;
1862
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;
1867
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;
1876
1877			glDeleteTextures		(1, &texture);
1878		});
1879	ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_level, "Invalid glCompressedTexSubImage2D() usage",
1880		{
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);
1888
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;
1893
1894			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1895			FOR_CUBE_FACES(faceGL,
1896			{
1897				glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1898				expectError(GL_INVALID_VALUE);
1899			});
1900			m_log << TestLog::EndSection;
1901
1902			glDeleteTextures(2, &textures[0]);
1903		});
1904	ES3F_ADD_API_CASE(compressedtexsubimage2d_max_level, "Invalid glCompressedTexSubImage2D() usage",
1905		{
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);
1913
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;
1919
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,
1923			{
1924				glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1925				expectError(GL_INVALID_VALUE);
1926			});
1927			m_log << TestLog::EndSection;
1928
1929			glDeleteTextures(2, &textures[0]);
1930		});
1931		ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_offset, "Invalid glCompressedTexSubImage2D() usage",
1932		{
1933			GLuint texture;
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);
1937
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.");
1942
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);
1949
1950			m_log << TestLog::EndSection;
1951
1952			glDeleteTextures(1, &texture);
1953		});
1954	ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_offset, "Invalid glCompressedTexSubImage2D() usage",
1955		{
1956			deUint32				texture;
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);
1961
1962			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1963
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;
1971
1972			glDeleteTextures		(1, &texture);
1973		});
1974	ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_width_height, "Invalid glCompressedTexSubImage2D() usage",
1975		{
1976			deUint32				texture;
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);
1981
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;
1990
1991			glDeleteTextures(1,		&texture);
1992		});
1993	ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
1994		{
1995			deUint32				texture;
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);
2000
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);
2004
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;
2008
2009			glDeleteTextures		(1, &texture);
2010		});
2011	ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_buffer_target, "Invalid glCompressedTexSubImage2D() usage",
2012		{
2013			deUint32					buf;
2014			deUint32					texture;
2015			std::vector<GLubyte>		data(128);
2016
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);
2024
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;
2032
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;
2038
2039			glDeleteBuffers			(1, &buf);
2040			glDeleteTextures		(1, &texture);
2041		});
2042
2043	// glTexImage3D
2044
2045	ES3F_ADD_API_CASE(teximage3d, "Invalid glTexImage3D() usage",
2046		{
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;
2053
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;
2058
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;
2063
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;
2069
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;
2076
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;
2089		});
2090	ES3F_ADD_API_CASE(teximage3d_neg_level, "Invalid glTexImage3D() usage",
2091		{
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;
2098		});
2099	ES3F_ADD_API_CASE(teximage3d_max_level, "Invalid glTexImage3D() usage",
2100		{
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;
2106
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;
2112		});
2113	ES3F_ADD_API_CASE(teximage3d_neg_width_height_depth, "Invalid glTexImage3D() usage",
2114		{
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);
2124
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;
2134		});
2135	ES3F_ADD_API_CASE(teximage3d_max_width_height_depth, "Invalid glTexImage3D() usage",
2136		{
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;
2139
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;
2150
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;
2161		});
2162	ES3F_ADD_API_CASE(teximage3d_invalid_border, "Invalid glTexImage3D() usage",
2163		{
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;
2174		});
2175	ES3F_ADD_API_CASE(teximage3d_invalid_buffer_target, "Invalid glTexImage3D() usage",
2176		{
2177			deUint32				buf;
2178			deUint32				texture;
2179			std::vector<GLubyte>	data(512);
2180
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);
2187
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...");
2189
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;
2196
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;
2201
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;
2207
2208			m_log << TestLog::EndSection;
2209
2210			glDeleteBuffers			(1, &buf);
2211			glDeleteTextures		(1, &texture);
2212		});
2213
2214	// glTexSubImage3D
2215
2216	ES3F_ADD_API_CASE(texsubimage3d, "Invalid glTexSubImage3D() usage",
2217		{
2218			deUint32			texture;
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);
2223
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;
2230
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;
2235
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;
2240
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;
2253
2254			glDeleteTextures	(1, &texture);
2255		});
2256	ES3F_ADD_API_CASE(texsubimage3d_neg_level, "Invalid glTexSubImage3D() usage",
2257		{
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);
2265
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;
2272
2273			glDeleteTextures	(2, &textures[0]);
2274		});
2275	ES3F_ADD_API_CASE(texsubimage3d_max_level, "Invalid glTexSubImage3D() usage",
2276		{
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);
2284
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;
2287
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;
2292
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;
2297
2298			glDeleteTextures	(2, &textures[0]);
2299		});
2300	ES3F_ADD_API_CASE(texsubimage3d_neg_offset, "Invalid glTexSubImage3D() usage",
2301		{
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);
2309
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;
2328
2329			glDeleteTextures	(2, &textures[0]);
2330		});
2331	ES3F_ADD_API_CASE(texsubimage3d_invalid_offset, "Invalid glTexSubImage3D() usage",
2332		{
2333			deUint32			texture;
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);
2338
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;
2343
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;
2348
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;
2353
2354			glDeleteTextures	(1, &texture);
2355		});
2356	ES3F_ADD_API_CASE(texsubimage3d_neg_width_height, "Invalid glTexSubImage3D() usage",
2357		{
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;
2368		});
2369	ES3F_ADD_API_CASE(texsubimage3d_invalid_buffer_target, "Invalid glTexSubImage3D() usage",
2370		{
2371			deUint32				buf;
2372			deUint32				texture;
2373			std::vector<GLubyte>	data(512);
2374
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);
2382
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...");
2384
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;
2391
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;
2396
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;
2406
2407			m_log << TestLog::EndSection;
2408
2409			glDeleteBuffers			(1, &buf);
2410			glDeleteTextures		(1, &texture);
2411		});
2412
2413	// glCopyTexSubImage3D
2414
2415	ES3F_ADD_API_CASE(copytexsubimage3d, "Invalid glCopyTexSubImage3D() usage",
2416		{
2417			GLuint texture;
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);
2421
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;
2426
2427			glDeleteTextures(1, &texture);
2428		});
2429	ES3F_ADD_API_CASE(copytexsubimage3d_neg_level, "Invalid glCopyTexSubImage3D() usage",
2430		{
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);
2438
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;
2445
2446			glDeleteTextures(2, &textures[0]);
2447		});
2448	ES3F_ADD_API_CASE(copytexsubimage3d_max_level, "Invalid glCopyTexSubImage3D() usage",
2449		{
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;
2452
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);
2460
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;
2465
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;
2470
2471			glDeleteTextures(2, &textures[0]);
2472		});
2473	ES3F_ADD_API_CASE(copytexsubimage3d_neg_offset, "Invalid glCopyTexSubImage3D() usage",
2474		{
2475			GLuint texture;
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);
2479
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;
2490
2491			glDeleteTextures(1, &texture);
2492		});
2493	ES3F_ADD_API_CASE(copytexsubimage3d_invalid_offset, "Invalid glCopyTexSubImage3D() usage",
2494		{
2495			GLuint texture;
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);
2499
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;
2504
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;
2509
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;
2514
2515			glDeleteTextures(1, &texture);
2516		});
2517	ES3F_ADD_API_CASE(copytexsubimage3d_neg_width_height, "Invalid glCopyTexSubImage3D() usage",
2518		{
2519			GLuint texture;
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);
2523
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;
2528
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;
2533
2534			glDeleteTextures(1, &texture);
2535		});
2536	ES3F_ADD_API_CASE(copytexsubimage3d_incomplete_framebuffer, "Invalid glCopyTexSubImage3D() usage",
2537		{
2538			GLuint fbo;
2539			GLuint texture[2];
2540
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);
2549
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;
2556
2557			glBindFramebuffer(GL_FRAMEBUFFER, 0);
2558			glDeleteFramebuffers(1, &fbo);
2559			glDeleteTextures(2, texture);
2560		});
2561
2562	// glCompressedTexImage3D
2563
2564	ES3F_ADD_API_CASE(compressedteximage3d, "Invalid glCompressedTexImage3D() usage",
2565		{
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;
2572
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;
2579		});
2580	ES3F_ADD_API_CASE(compressedteximage3d_neg_level, "Invalid glCompressedTexImage3D() usage",
2581		{
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;
2586		});
2587	ES3F_ADD_API_CASE(compressedteximage3d_max_level, "Invalid glCompressedTexImage3D() usage",
2588		{
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;
2594		});
2595	ES3F_ADD_API_CASE(compressedteximage3d_neg_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2596		{
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;
2607		});
2608	ES3F_ADD_API_CASE(compressedteximage3d_max_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2609		{
2610			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2611
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;
2622		});
2623	ES3F_ADD_API_CASE(compressedteximage3d_invalid_border, "Invalid glCompressedTexImage3D() usage",
2624		{
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;
2631		});
2632	ES3F_ADD_API_CASE(compressedteximage3d_invalid_size, "Invalid glCompressedTexImage3D() usage",
2633		{
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;
2644		});
2645	ES3F_ADD_API_CASE(compressedteximage3d_invalid_buffer_target, "Invalid glCompressedTexImage3D() usage",
2646		{
2647			deUint32				buf;
2648			std::vector<GLubyte>	data(512);
2649
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);
2654
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;
2661
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;
2666
2667			glDeleteBuffers			(1, &buf);
2668		});
2669	ES3F_ADD_API_CASE(compressedteximage3d_invalid_astc_target, "Invalid glCompressedTexImage3D() ASTC 3D targets",
2670		{
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
2676
2677			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2678				m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
2679			{
2680				m_log.writeMessage("Full ASTC supported. No negative API requirements.");
2681			}
2682			else
2683			{
2684				const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
2685
2686				if (requiredError == GL_INVALID_OPERATION)
2687					m_log.writeMessage("GL_INVALID_OPERATION should be  generated if any TexImage3D target works with LDR ASTC.");
2688				else
2689					m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
2690
2691				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
2692				{
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);
2698
2699					glCompressedTexImage3D(GL_TEXTURE_3D, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0, blockBytes, &dummyData[0]);
2700					expectError(requiredError);
2701
2702					glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0, blockBytes, &dummyData[0]);
2703					expectError(requiredError);
2704				}
2705			}
2706		});
2707
2708	// glCompressedTexSubImage3D
2709
2710	ES3F_ADD_API_CASE(compressedtexsubimage3d, "Invalid glCompressedTexSubImage3D() usage",
2711		{
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;
2716
2717			deUint32				texture;
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);
2722
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;
2727
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;
2732
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;
2737
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;
2742
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;
2751
2752			glDeleteTextures		(1, &texture);
2753		});
2754	ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_level, "Invalid glCompressedTexSubImage3D() usage",
2755		{
2756			deUint32				texture;
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);
2761
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;
2766
2767			glDeleteTextures		(1, &texture);
2768		});
2769	ES3F_ADD_API_CASE(compressedtexsubimage3d_max_level, "Invalid glCompressedTexSubImage3D() usage",
2770		{
2771			deUint32				texture;
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);
2776
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;
2782
2783			glDeleteTextures		(1, &texture);
2784		});
2785	ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_offset, "Invalid glCompressedTexSubImage3D() usage",
2786		{
2787			deUint32				texture;
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);
2792
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;
2803
2804			glDeleteTextures		(1, &texture);
2805		});
2806	ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_offset, "Invalid glCompressedTexSubImage3D() usage",
2807		{
2808			deUint32				texture;
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);
2813
2814			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
2815
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;
2825
2826			glDeleteTextures		(1, &texture);
2827		});
2828	ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_width_height_depth, "Invalid glCompressedTexSubImage3D() usage",
2829		{
2830			deUint32				texture;
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);
2835
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;
2846
2847			glDeleteTextures		(1, &texture);
2848		});
2849	ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_size, "Invalid glCompressedTexSubImage3D() usage",
2850		{
2851			deUint32				texture;
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);
2856
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);
2860
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;
2864
2865			glDeleteTextures		(1, &texture);
2866		});
2867	ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_buffer_target, "Invalid glCompressedTexSubImage3D() usage",
2868		{
2869			deUint32					buf;
2870			deUint32					texture;
2871			GLsizei						bufferSize = etc2EacDataSize(4, 4);
2872			std::vector<GLubyte>		data(bufferSize);
2873
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);
2881
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;
2889
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;
2895
2896			glDeleteBuffers			(1, &buf);
2897			glDeleteTextures		(1, &texture);
2898		});
2899
2900	// glTexStorage2D
2901
2902	ES3F_ADD_API_CASE(texstorage2d, "Invalid glTexStorage2D() usage",
2903		{
2904			deUint32		texture;
2905			glGenTextures	(1, &texture);
2906			glBindTexture	(GL_TEXTURE_2D, texture);
2907
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;
2914
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;
2923
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;
2932
2933			glDeleteTextures(1, &texture);
2934		});
2935
2936	ES3F_ADD_API_CASE(texstorage2d_invalid_binding, "Invalid glTexStorage2D() usage",
2937		{
2938			glBindTexture	(GL_TEXTURE_2D, 0);
2939
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;
2944
2945			deUint32		texture;
2946			glGenTextures	(1, &texture);
2947			glBindTexture	(GL_TEXTURE_2D, texture);
2948
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;
2960
2961			glDeleteTextures(1, &texture);
2962		});
2963	ES3F_ADD_API_CASE(texstorage2d_invalid_levels, "Invalid glTexStorage2D() usage",
2964		{
2965			deUint32		texture;
2966			glGenTextures	(1, &texture);
2967			glBindTexture	(GL_TEXTURE_2D, texture);
2968
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;
2975
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;
2985
2986			glDeleteTextures(1, &texture);
2987		});
2988	ES3F_ADD_API_CASE(texstorage2d_invalid_astc_target, "Invalid glTexStorage2D() ASTC 2D targets",
2989		{
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
2995			// no effect.
2996			// In conclusion: Expect same errors as with TexImage?D
2997
2998			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2999				m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3000			{
3001				m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3002			}
3003			else
3004			{
3005				const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
3006
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.");
3009				else
3010					m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
3011
3012				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3013				{
3014					const GLuint 				format 		= s_astcFormats[formatNdx];
3015					const CompressedTexFormat 	tcuFormat 	= mapGLCompressedTexFormat(format);
3016					const IVec3 				blockPixels = getBlockPixelSize(tcuFormat);
3017
3018					glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, format, blockPixels.x(), blockPixels.y());
3019					expectError(requiredError);
3020				}
3021			}
3022		});
3023
3024	// glTexStorage3D
3025
3026	ES3F_ADD_API_CASE(texstorage3d, "Invalid glTexStorage3D() usage",
3027		{
3028			deUint32		texture;
3029			glGenTextures	(1, &texture);
3030			glBindTexture	(GL_TEXTURE_3D, texture);
3031
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;
3038
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;
3047
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;
3058
3059			glDeleteTextures(1, &texture);
3060		});
3061	ES3F_ADD_API_CASE(texstorage3d_invalid_binding, "Invalid glTexStorage3D() usage",
3062		{
3063			glBindTexture	(GL_TEXTURE_3D, 0);
3064
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;
3069
3070			deUint32		texture;
3071			glGenTextures	(1, &texture);
3072			glBindTexture	(GL_TEXTURE_3D, texture);
3073
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;
3085
3086			glDeleteTextures(1, &texture);
3087		});
3088	ES3F_ADD_API_CASE(texstorage3d_invalid_levels, "Invalid glTexStorage3D() usage",
3089		{
3090			deUint32		texture;
3091			glGenTextures	(1, &texture);
3092			glBindTexture	(GL_TEXTURE_3D, texture);
3093
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;
3100
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;
3112
3113			glDeleteTextures(1, &texture);
3114		});
3115
3116	ES3F_ADD_API_CASE(texstorage3d_invalid_astc_target, "Invalid glTexStorage3D() ASTC 3D targets",
3117		{
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
3123			// no effect.
3124			// In conclusion: Expect same errors as with TexImage?D
3125
3126			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
3127				m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3128			{
3129				m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3130			}
3131			else
3132			{
3133				const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
3134
3135				if (requiredError == GL_INVALID_OPERATION)
3136					m_log.writeMessage("GL_INVALID_OPERATION should be generated if any TexStorage3D target works with LDR.");
3137				else
3138					m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
3139
3140				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3141				{
3142					const GLuint 				format 		= s_astcFormats[formatNdx];
3143					const CompressedTexFormat 	tcuFormat 	= mapGLCompressedTexFormat(format);
3144					const IVec3 				blockPixels = getBlockPixelSize(tcuFormat);
3145
3146					glTexStorage3D(GL_TEXTURE_3D, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3147					expectError(requiredError);
3148
3149					glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3150					expectError(requiredError);
3151				}
3152			}
3153		});
3154}
3155
3156} // Functional
3157} // gles3
3158} // deqp
3159