• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative Texture API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fNegativeTextureApiTests.hpp"
25 #include "es3fApiCase.hpp"
26 #include "gluContextInfo.hpp"
27 #include "tcuFormatUtil.hpp"
28 #include "gluTextureUtil.hpp"
29 
30 #include <vector>
31 #include <algorithm>
32 
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
35 
36 using namespace glw; // GL types
37 
38 namespace deqp
39 {
40 namespace gles3
41 {
42 namespace Functional
43 {
44 
45 using tcu::TestLog;
46 using tcu::CompressedTexFormat;
47 using tcu::getBlockSize;
48 using tcu::getBlockPixelSize;
49 using tcu::IVec3;
50 using glu::mapGLCompressedTexFormat;
51 using std::vector;
52 
divRoundUp(int a,int b)53 static inline int divRoundUp (int a, int b)
54 {
55 	return a/b + (a%b != 0 ? 1 : 0);
56 }
57 
etc2DataSize(int width,int height)58 static inline int etc2DataSize (int width, int height)
59 {
60 	return (int)(divRoundUp(width, 4) * divRoundUp(height, 4) * sizeof(deUint64));
61 }
62 
etc2EacDataSize(int width,int height)63 static inline int etc2EacDataSize (int width, int height)
64 {
65 	return 2 * etc2DataSize(width, height);
66 }
67 
68 static const GLuint s_astcFormats[] =
69 {
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 
cubeFaceToGLFace(tcu::CubeFace face)100 static 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 
NegativeTextureApiTests(Context & context)126 NegativeTextureApiTests::NegativeTextureApiTests (Context& context)
127 	: TestCaseGroup(context, "texture", "Negative Texture API Cases")
128 {
129 }
130 
~NegativeTextureApiTests(void)131 NegativeTextureApiTests::~NegativeTextureApiTests (void)
132 {
133 }
134 
init(void)135 void 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 			bool	isES = glu::isContextTypeES(m_context.getRenderContext().getType());
407 			GLenum	error = isES ? GL_INVALID_VALUE : GL_INVALID_OPERATION;
408 
409 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
410 
411 			m_log << TestLog::Section("", "GL_TEXTURE_2D target");
412 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
413 			expectError(error);
414 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
415 			expectError(error);
416 			m_log << TestLog::EndSection;
417 
418 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
419 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
420 			expectError(error);
421 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
422 			expectError(error);
423 			m_log << TestLog::EndSection;
424 
425 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
426 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
427 			expectError(error);
428 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
429 			expectError(error);
430 			m_log << TestLog::EndSection;
431 
432 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
433 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
434 			expectError(error);
435 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
436 			expectError(error);
437 			m_log << TestLog::EndSection;
438 
439 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
440 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
441 			expectError(error);
442 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
443 			expectError(error);
444 			m_log << TestLog::EndSection;
445 
446 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
447 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
448 			expectError(error);
449 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
450 			expectError(error);
451 			m_log << TestLog::EndSection;
452 
453 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
454 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
455 			expectError(error);
456 			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
457 			expectError(error);
458 			m_log << TestLog::EndSection;
459 
460 			m_log << TestLog::EndSection;
461 		});
462 	ES3F_ADD_API_CASE(compressedteximage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
463 		{
464 			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.");
465 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0);
466 			expectError(GL_INVALID_VALUE);
467 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, 4*4*8, 0);
468 			expectError(GL_INVALID_VALUE);
469 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, 4*4*16, 0);
470 			expectError(GL_INVALID_VALUE);
471 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 0, 4*4*16, 0);
472 			expectError(GL_INVALID_VALUE);
473 			m_log << TestLog::EndSection;
474 		});
475 	ES3F_ADD_API_CASE(compressedteximage2d_invalid_buffer_target, "Invalid glCompressedTexImage2D() usage",
476 		{
477 			deUint32				buf;
478 			std::vector<GLubyte>	data(64);
479 
480 			glGenBuffers			(1, &buf);
481 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
482 			glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
483 			expectError				(GL_NO_ERROR);
484 
485 			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.");
486 			glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
487 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 0, etc2DataSize(4, 4), 0);
488 			expectError				(GL_INVALID_OPERATION);
489 			glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
490 			m_log << TestLog::EndSection;
491 
492 			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.");
493 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
494 			expectError				(GL_INVALID_OPERATION);
495 			m_log << TestLog::EndSection;
496 
497 			glDeleteBuffers			(1, &buf);
498 		});
499 	ES3F_ADD_API_CASE(compressedteximage2d_invalid_astc_target, "ASTC formats should not be supported without a proper extension.",
500 		{
501 			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
502 			{
503 				m_log.writeMessage("ASTC supported. No negative API requirements.");
504 			}
505 			else
506 			{
507 				m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
508 
509 				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
510 				{
511 					const GLuint				format		= s_astcFormats[formatNdx];
512 					const CompressedTexFormat	tcuFormat	= mapGLCompressedTexFormat(format);
513 					const IVec3					blockPixels = getBlockPixelSize(tcuFormat);
514 					{
515 						const size_t			blockBytes	= getBlockSize(tcuFormat);
516 						const vector<deUint8>	unusedData	(blockBytes);
517 
518 						glCompressedTexImage2D(GL_TEXTURE_2D, 0, format, blockPixels.x(), blockPixels.y(), 0, (int)blockBytes, &unusedData[0]);
519 						expectError(GL_INVALID_ENUM);
520 					}
521 					FOR_CUBE_FACES(faceGL,
522 					{
523 						const deInt32			cubeSize	= blockPixels.x() * blockPixels.y(); // Divisible by the block size and square
524 						const size_t			blockBytes	= getBlockSize(tcuFormat) * cubeSize; // We have a x * y grid of blocks
525 						const vector<deUint8>	unusedData	(blockBytes);
526 
527 						glCompressedTexImage2D(faceGL, 0, format, cubeSize, cubeSize, 0, (int)blockBytes, &unusedData[0]);
528 						expectError(GL_INVALID_ENUM);
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 			if (glu::isContextTypeES(m_context.getRenderContext().getType()))
1059 			{
1060 				m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
1061 				glBindTexture(GL_TEXTURE_2D, texture[1]);
1062 				glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1063 				glGenerateMipmap(GL_TEXTURE_2D);
1064 				expectError(GL_INVALID_OPERATION);
1065 				m_log << TestLog::EndSection;
1066 
1067 				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.");
1068 				glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 0, 0, 0, GL_RGB, GL_BYTE, 0);
1069 				glGenerateMipmap(GL_TEXTURE_2D);
1070 				expectError(GL_INVALID_OPERATION);
1071 				glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, 0);
1072 				glGenerateMipmap(GL_TEXTURE_2D);
1073 				expectError(GL_INVALID_OPERATION);
1074 
1075 				if (!(m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") && m_context.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
1076 				{
1077 					glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
1078 					glGenerateMipmap(GL_TEXTURE_2D);
1079 					expectError(GL_INVALID_OPERATION);
1080 				}
1081 
1082 				m_log << TestLog::EndSection;
1083 			}
1084 
1085 			glDeleteTextures(2, texture);
1086 		});
1087 
1088 	// glGenTextures
1089 
1090 	ES3F_ADD_API_CASE(gentextures, "Invalid glGenTextures() usage",
1091 		{
1092 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1093 			glGenTextures(-1, 0);
1094 			expectError(GL_INVALID_VALUE);
1095 			m_log << TestLog::EndSection;
1096 		});
1097 
1098 	// glPixelStorei
1099 
1100 	ES3F_ADD_API_CASE(pixelstorei, "Invalid glPixelStorei() usage",
1101 		{
1102 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1103 			glPixelStorei(0,1);
1104 			expectError(GL_INVALID_ENUM);
1105 			m_log << TestLog::EndSection;
1106 
1107 			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.");
1108 			glPixelStorei(GL_PACK_ROW_LENGTH, -1);
1109 			expectError(GL_INVALID_VALUE);
1110 			glPixelStorei(GL_PACK_SKIP_ROWS, -1);
1111 			expectError(GL_INVALID_VALUE);
1112 			glPixelStorei(GL_PACK_SKIP_PIXELS, -1);
1113 			expectError(GL_INVALID_VALUE);
1114 			glPixelStorei(GL_UNPACK_ROW_LENGTH, -1);
1115 			expectError(GL_INVALID_VALUE);
1116 			glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, -1);
1117 			expectError(GL_INVALID_VALUE);
1118 			glPixelStorei(GL_UNPACK_SKIP_ROWS, -1);
1119 			expectError(GL_INVALID_VALUE);
1120 			glPixelStorei(GL_UNPACK_SKIP_PIXELS, -1);
1121 			expectError(GL_INVALID_VALUE);
1122 			glPixelStorei(GL_UNPACK_SKIP_IMAGES, -1);
1123 			expectError(GL_INVALID_VALUE);
1124 			glPixelStorei(GL_PACK_ALIGNMENT, 0);
1125 			expectError(GL_INVALID_VALUE);
1126 			glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
1127 			expectError(GL_INVALID_VALUE);
1128 			glPixelStorei(GL_PACK_ALIGNMENT, 16);
1129 			expectError(GL_INVALID_VALUE);
1130 			glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
1131 			expectError(GL_INVALID_VALUE);
1132 			m_log << TestLog::EndSection;
1133 		});
1134 
1135 	// glTexImage2D
1136 
1137 	ES3F_ADD_API_CASE(teximage2d, "Invalid glTexImage2D() usage",
1138 		{
1139 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1140 			glTexImage2D(0, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1141 			expectError(GL_INVALID_ENUM);
1142 			m_log << TestLog::EndSection;
1143 
1144 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1145 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 0, 0);
1146 			expectError(GL_INVALID_ENUM);
1147 			m_log << TestLog::EndSection;
1148 
1149 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
1150 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1151 			expectError(GL_INVALID_OPERATION);
1152 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1153 			expectError(GL_INVALID_OPERATION);
1154 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
1155 			expectError(GL_INVALID_OPERATION);
1156 			if (glu::isContextTypeES(m_context.getRenderContext().getType()))
1157 			{
1158 				glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1159 				expectError(GL_INVALID_OPERATION);
1160 				glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
1161 				expectError(GL_INVALID_OPERATION);
1162 			}
1163 			m_log << TestLog::EndSection;
1164 		});
1165 	ES3F_ADD_API_CASE(teximage2d_inequal_width_height_cube, "Invalid glTexImage2D() usage",
1166 		{
1167 			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.");
1168 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1169 			expectError(GL_INVALID_VALUE);
1170 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1171 			expectError(GL_INVALID_VALUE);
1172 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1173 			expectError(GL_INVALID_VALUE);
1174 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1175 			expectError(GL_INVALID_VALUE);
1176 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1177 			expectError(GL_INVALID_VALUE);
1178 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1179 			expectError(GL_INVALID_VALUE);
1180 			m_log << TestLog::EndSection;
1181 		});
1182 	ES3F_ADD_API_CASE(teximage2d_neg_level, "Invalid glTexImage2D() usage",
1183 		{
1184 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1185 			glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1186 			expectError(GL_INVALID_VALUE);
1187 			m_log << TestLog::EndSection;
1188 
1189 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1190 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1191 			expectError(GL_INVALID_VALUE);
1192 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1193 			expectError(GL_INVALID_VALUE);
1194 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1195 			expectError(GL_INVALID_VALUE);
1196 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1197 			expectError(GL_INVALID_VALUE);
1198 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1199 			expectError(GL_INVALID_VALUE);
1200 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1201 			expectError(GL_INVALID_VALUE);
1202 			m_log << TestLog::EndSection;
1203 		});
1204 	ES3F_ADD_API_CASE(teximage2d_max_level, "Invalid glTexImage2D() usage",
1205 		{
1206 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1207 			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1208 			glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1209 			expectError(GL_INVALID_VALUE);
1210 			m_log << TestLog::EndSection;
1211 
1212 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1213 			deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1214 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1215 			expectError(GL_INVALID_VALUE);
1216 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1217 			expectError(GL_INVALID_VALUE);
1218 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1219 			expectError(GL_INVALID_VALUE);
1220 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1221 			expectError(GL_INVALID_VALUE);
1222 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1223 			expectError(GL_INVALID_VALUE);
1224 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1225 			expectError(GL_INVALID_VALUE);
1226 			m_log << TestLog::EndSection;
1227 		});
1228 	ES3F_ADD_API_CASE(teximage2d_neg_width_height, "Invalid glTexImage2D() usage",
1229 		{
1230 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1231 
1232 			m_log << TestLog::Section("", "GL_TEXTURE_2D target");
1233 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1234 			expectError(GL_INVALID_VALUE);
1235 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1236 			expectError(GL_INVALID_VALUE);
1237 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1238 			expectError(GL_INVALID_VALUE);
1239 			m_log << TestLog::EndSection;
1240 
1241 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1242 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1243 			expectError(GL_INVALID_VALUE);
1244 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1245 			expectError(GL_INVALID_VALUE);
1246 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1247 			expectError(GL_INVALID_VALUE);
1248 			m_log << TestLog::EndSection;
1249 
1250 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1251 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1252 			expectError(GL_INVALID_VALUE);
1253 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1254 			expectError(GL_INVALID_VALUE);
1255 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1256 			expectError(GL_INVALID_VALUE);
1257 			m_log << TestLog::EndSection;
1258 
1259 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1260 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1261 			expectError(GL_INVALID_VALUE);
1262 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1263 			expectError(GL_INVALID_VALUE);
1264 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1265 			expectError(GL_INVALID_VALUE);
1266 			m_log << TestLog::EndSection;
1267 
1268 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1269 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1270 			expectError(GL_INVALID_VALUE);
1271 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1272 			expectError(GL_INVALID_VALUE);
1273 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1274 			expectError(GL_INVALID_VALUE);
1275 			m_log << TestLog::EndSection;
1276 
1277 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1278 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1279 			expectError(GL_INVALID_VALUE);
1280 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1281 			expectError(GL_INVALID_VALUE);
1282 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1283 			expectError(GL_INVALID_VALUE);
1284 			m_log << TestLog::EndSection;
1285 
1286 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1287 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1288 			expectError(GL_INVALID_VALUE);
1289 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1290 			expectError(GL_INVALID_VALUE);
1291 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1292 			expectError(GL_INVALID_VALUE);
1293 			m_log << TestLog::EndSection;
1294 
1295 			m_log << TestLog::EndSection;
1296 		});
1297 	ES3F_ADD_API_CASE(teximage2d_max_width_height, "Invalid glTexImage2D() usage",
1298 		{
1299 			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
1300 			int maxCubemapSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1301 
1302 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
1303 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1304 			expectError(GL_INVALID_VALUE);
1305 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1306 			expectError(GL_INVALID_VALUE);
1307 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1308 			expectError(GL_INVALID_VALUE);
1309 			m_log << TestLog::EndSection;
1310 
1311 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1312 
1313 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1314 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1315 			expectError(GL_INVALID_VALUE);
1316 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1317 			expectError(GL_INVALID_VALUE);
1318 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1319 			expectError(GL_INVALID_VALUE);
1320 			m_log << TestLog::EndSection;
1321 
1322 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1323 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1324 			expectError(GL_INVALID_VALUE);
1325 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1326 			expectError(GL_INVALID_VALUE);
1327 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1328 			expectError(GL_INVALID_VALUE);
1329 			m_log << TestLog::EndSection;
1330 
1331 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1332 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1333 			expectError(GL_INVALID_VALUE);
1334 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1335 			expectError(GL_INVALID_VALUE);
1336 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1337 			expectError(GL_INVALID_VALUE);
1338 			m_log << TestLog::EndSection;
1339 
1340 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1341 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1342 			expectError(GL_INVALID_VALUE);
1343 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1344 			expectError(GL_INVALID_VALUE);
1345 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1346 			expectError(GL_INVALID_VALUE);
1347 			m_log << TestLog::EndSection;
1348 
1349 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1350 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1351 			expectError(GL_INVALID_VALUE);
1352 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1353 			expectError(GL_INVALID_VALUE);
1354 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1355 			expectError(GL_INVALID_VALUE);
1356 			m_log << TestLog::EndSection;
1357 
1358 			m_log << TestLog::Section("", "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1359 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1360 			expectError(GL_INVALID_VALUE);
1361 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1362 			expectError(GL_INVALID_VALUE);
1363 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1364 			expectError(GL_INVALID_VALUE);
1365 			m_log << TestLog::EndSection;
1366 
1367 			m_log << TestLog::EndSection;
1368 		});
1369 	ES3F_ADD_API_CASE(teximage2d_invalid_border, "Invalid glTexImage2D() usage",
1370 		{
1371 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
1372 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1373 			expectError(GL_INVALID_VALUE);
1374 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1375 			expectError(GL_INVALID_VALUE);
1376 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1377 			expectError(GL_INVALID_VALUE);
1378 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1379 			expectError(GL_INVALID_VALUE);
1380 			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1381 			expectError(GL_INVALID_VALUE);
1382 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1383 			expectError(GL_INVALID_VALUE);
1384 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1385 			expectError(GL_INVALID_VALUE);
1386 			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1387 			expectError(GL_INVALID_VALUE);
1388 			m_log << TestLog::EndSection;
1389 		});
1390 	ES3F_ADD_API_CASE(teximage2d_invalid_buffer_target, "Invalid glTexImage2D() usage",
1391 		{
1392 			deUint32				buf;
1393 			deUint32				texture;
1394 			std::vector<GLubyte>	data(64);
1395 
1396 			glGenBuffers			(1, &buf);
1397 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
1398 			glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1399 			glGenTextures			(1, &texture);
1400 			glBindTexture			(GL_TEXTURE_2D, texture);
1401 			expectError				(GL_NO_ERROR);
1402 
1403 			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...");
1404 			m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1405 			glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1406 			glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1407 			expectError				(GL_INVALID_OPERATION);
1408 			glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
1409 			m_log << TestLog::EndSection;
1410 
1411 			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.");
1412 			glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1413 			expectError				(GL_INVALID_OPERATION);
1414 			m_log << TestLog::EndSection;
1415 
1416 			m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1417 			m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1418 			glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGB5_A1, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
1419 			expectError				(GL_INVALID_OPERATION);
1420 			m_log << TestLog::EndSection;
1421 			m_log << TestLog::EndSection;
1422 
1423 			glDeleteBuffers			(1, &buf);
1424 			glDeleteTextures		(1, &texture);
1425 		});
1426 
1427 	// glTexSubImage2D
1428 
1429 	ES3F_ADD_API_CASE(texsubimage2d, "Invalid glTexSubImage2D() usage",
1430 		{
1431 			deUint32			texture;
1432 			glGenTextures		(1, &texture);
1433 			glBindTexture		(GL_TEXTURE_2D, texture);
1434 			glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1435 			expectError			(GL_NO_ERROR);
1436 
1437 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1438 			glTexSubImage2D(0, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1439 			expectError(GL_INVALID_ENUM);
1440 			m_log << TestLog::EndSection;
1441 
1442 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
1443 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, GL_UNSIGNED_BYTE, 0);
1444 			expectError(GL_INVALID_ENUM);
1445 			m_log << TestLog::EndSection;
1446 
1447 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
1448 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, 0, 0);
1449 			expectError(GL_INVALID_ENUM);
1450 			m_log << TestLog::EndSection;
1451 
1452 			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.");
1453 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
1454 			expectError(GL_INVALID_OPERATION);
1455 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1456 			expectError(GL_INVALID_OPERATION);
1457 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1458 			expectError(GL_INVALID_OPERATION);
1459 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1460 			expectError(GL_INVALID_OPERATION);
1461 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
1462 			expectError(GL_INVALID_OPERATION);
1463 			if (glu::isContextTypeES(m_context.getRenderContext().getType()))
1464 			{
1465 				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_FLOAT, 0);
1466 				expectError(GL_INVALID_OPERATION);
1467 			}
1468 			m_log << tcu::TestLog::EndSection;
1469 
1470 			glDeleteTextures	(1, &texture);
1471 		});
1472 	ES3F_ADD_API_CASE(texsubimage2d_neg_level, "Invalid glTexSubImage2D() usage",
1473 		{
1474 			deUint32			textures[2];
1475 			glGenTextures		(2, &textures[0]);
1476 			glBindTexture		(GL_TEXTURE_2D, textures[0]);
1477 			glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1478 			glBindTexture		(GL_TEXTURE_2D, textures[1]);
1479 			FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1480 			expectError			(GL_NO_ERROR);
1481 
1482 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1483 			glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1484 			expectError(GL_INVALID_VALUE);
1485 			m_log << TestLog::EndSection;
1486 
1487 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1488 			FOR_CUBE_FACES(faceGL,
1489 			{
1490 				glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1491 				expectError(GL_INVALID_VALUE);
1492 			});
1493 			m_log << TestLog::EndSection;
1494 
1495 			glDeleteTextures(2, &textures[0]);
1496 		});
1497 	ES3F_ADD_API_CASE(texsubimage2d_max_level, "Invalid glTexSubImage2D() usage",
1498 		{
1499 			deUint32			textures[2];
1500 			glGenTextures		(2, &textures[0]);
1501 			glBindTexture		(GL_TEXTURE_2D, textures[0]);
1502 			glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1503 			glBindTexture		(GL_TEXTURE_CUBE_MAP, textures[1]);
1504 			FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1505 			expectError			(GL_NO_ERROR);
1506 
1507 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1508 			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1509 			glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1510 			expectError(GL_INVALID_VALUE);
1511 			m_log << TestLog::EndSection;
1512 
1513 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1514 			deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1515 			FOR_CUBE_FACES(faceGL,
1516 			{
1517 				glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1518 				expectError(GL_INVALID_VALUE);
1519 			});
1520 			m_log << TestLog::EndSection;
1521 
1522 			glDeleteTextures(2, &textures[0]);
1523 		});
1524 	ES3F_ADD_API_CASE(texsubimage2d_neg_offset, "Invalid glTexSubImage2D() usage",
1525 		{
1526 			deUint32 texture;
1527 			glGenTextures(1, &texture);
1528 			glBindTexture(GL_TEXTURE_2D, texture);
1529 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1530 			expectError(GL_NO_ERROR);
1531 
1532 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
1533 			glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1534 			expectError(GL_INVALID_VALUE);
1535 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1536 			expectError(GL_INVALID_VALUE);
1537 			glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1538 			expectError(GL_INVALID_VALUE);
1539 			m_log << TestLog::EndSection;
1540 
1541 			glDeleteTextures(1, &texture);
1542 		});
1543 	ES3F_ADD_API_CASE(texsubimage2d_invalid_offset, "Invalid glTexSubImage2D() usage",
1544 		{
1545 			deUint32			texture;
1546 			glGenTextures		(1, &texture);
1547 			glBindTexture		(GL_TEXTURE_2D, texture);
1548 			glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1549 			expectError			(GL_NO_ERROR);
1550 
1551 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1552 			glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1553 			expectError(GL_INVALID_VALUE);
1554 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1555 			expectError(GL_INVALID_VALUE);
1556 			glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1557 			expectError(GL_INVALID_VALUE);
1558 			m_log << TestLog::EndSection;
1559 
1560 			glDeleteTextures	(1, &texture);
1561 		});
1562 	ES3F_ADD_API_CASE(texsubimage2d_neg_width_height, "Invalid glTexSubImage2D() usage",
1563 		{
1564 			deUint32			texture;
1565 			glGenTextures		(1, &texture);
1566 			glBindTexture		(GL_TEXTURE_2D, texture);
1567 			glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1568 			expectError			(GL_NO_ERROR);
1569 
1570 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1571 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1572 			expectError(GL_INVALID_VALUE);
1573 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1574 			expectError(GL_INVALID_VALUE);
1575 			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1576 			expectError(GL_INVALID_VALUE);
1577 			m_log << TestLog::EndSection;
1578 
1579 			glDeleteTextures	(1, &texture);
1580 		});
1581 	ES3F_ADD_API_CASE(texsubimage2d_invalid_buffer_target, "Invalid glTexSubImage2D() usage",
1582 		{
1583 			deUint32				buf;
1584 			deUint32				texture;
1585 			std::vector<GLubyte>	data(64);
1586 
1587 			glGenTextures			(1, &texture);
1588 			glBindTexture			(GL_TEXTURE_2D, texture);
1589 			glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1590 			glGenBuffers			(1, &buf);
1591 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
1592 			glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1593 			expectError				(GL_NO_ERROR);
1594 
1595 			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...");
1596 			m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
1597 			glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1598 			glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1599 			expectError				(GL_INVALID_OPERATION);
1600 			glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
1601 			m_log << TestLog::EndSection;
1602 
1603 			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.");
1604 			glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1605 			expectError				(GL_INVALID_OPERATION);
1606 			m_log << TestLog::EndSection;
1607 
1608 			m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1609 			m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1610 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, 0);
1611 			glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1612 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
1613 			expectError				(GL_NO_ERROR);
1614 			glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
1615 			expectError				(GL_INVALID_OPERATION);
1616 			m_log << TestLog::EndSection;
1617 			m_log << TestLog::EndSection;
1618 
1619 			glDeleteBuffers			(1, &buf);
1620 			glDeleteTextures		(1, &texture);
1621 		});
1622 
1623 	// glTexParameteri
1624 
1625 	ES3F_ADD_API_CASE(texparameteri, "Invalid glTexParameteri() usage",
1626 		{
1627 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1628 			glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1629 			expectError(GL_INVALID_ENUM);
1630 			glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1631 			expectError(GL_INVALID_ENUM);
1632 			glTexParameteri(0, 0, GL_LINEAR);
1633 			expectError(GL_INVALID_ENUM);
1634 			m_log << TestLog::EndSection;
1635 
1636 			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.");
1637 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1638 			expectError(GL_INVALID_ENUM);
1639 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1640 			expectError(GL_INVALID_ENUM);
1641 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1642 			expectError(GL_INVALID_ENUM);
1643 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1644 			expectError(GL_INVALID_ENUM);
1645 			m_log << TestLog::EndSection;
1646 
1647 			GLuint texture;
1648 			glGenTextures(1, &texture);
1649 			glBindTexture(GL_TEXTURE_2D, texture);
1650 
1651 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1652 			glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1653 			expectError(GL_INVALID_ENUM);
1654 			glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1655 			expectError(GL_INVALID_ENUM);
1656 			glTexParameteri(0, 0, GL_LINEAR);
1657 			expectError(GL_INVALID_ENUM);
1658 			m_log << TestLog::EndSection;
1659 
1660 			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.");
1661 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1662 			expectError(GL_INVALID_ENUM);
1663 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1664 			expectError(GL_INVALID_ENUM);
1665 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1666 			expectError(GL_INVALID_ENUM);
1667 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1668 			expectError(GL_INVALID_ENUM);
1669 			m_log << TestLog::EndSection;
1670 
1671 			glDeleteTextures(1, &texture);
1672 		});
1673 
1674 	// glTexParameterf
1675 
1676 	ES3F_ADD_API_CASE(texparameterf, "Invalid glTexParameterf() usage",
1677 		{
1678 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1679 			glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1680 			expectError(GL_INVALID_ENUM);
1681 			glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1682 			expectError(GL_INVALID_ENUM);
1683 			glTexParameterf(0, 0, GL_LINEAR);
1684 			expectError(GL_INVALID_ENUM);
1685 			m_log << TestLog::EndSection;
1686 
1687 			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.");
1688 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1689 			expectError(GL_INVALID_ENUM);
1690 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1691 			expectError(GL_INVALID_ENUM);
1692 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1693 			expectError(GL_INVALID_ENUM);
1694 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1695 			expectError(GL_INVALID_ENUM);
1696 			m_log << TestLog::EndSection;
1697 
1698 			GLuint texture;
1699 			glGenTextures(1, &texture);
1700 			glBindTexture(GL_TEXTURE_2D, texture);
1701 
1702 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1703 			glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1704 			expectError(GL_INVALID_ENUM);
1705 			glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1706 			expectError(GL_INVALID_ENUM);
1707 			glTexParameterf(0, 0, GL_LINEAR);
1708 			expectError(GL_INVALID_ENUM);
1709 			m_log << TestLog::EndSection;
1710 
1711 			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.");
1712 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1713 			expectError(GL_INVALID_ENUM);
1714 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1715 			expectError(GL_INVALID_ENUM);
1716 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1717 			expectError(GL_INVALID_ENUM);
1718 			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1719 			expectError(GL_INVALID_ENUM);
1720 			m_log << TestLog::EndSection;
1721 
1722 			glDeleteTextures(1, &texture);
1723 		});
1724 
1725 	// glTexParameteriv
1726 
1727 	ES3F_ADD_API_CASE(texparameteriv, "Invalid glTexParameteriv() usage",
1728 		{
1729 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1730 			GLint params[1] = {GL_LINEAR};
1731 			glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1732 			expectError(GL_INVALID_ENUM);
1733 			glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
1734 			expectError(GL_INVALID_ENUM);
1735 			glTexParameteriv(0, 0, &params[0]);
1736 			expectError(GL_INVALID_ENUM);
1737 			m_log << TestLog::EndSection;
1738 
1739 			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.");
1740 			params[0] = 0;
1741 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1742 			expectError(GL_INVALID_ENUM);
1743 			params[0] = GL_REPEAT;
1744 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1745 			expectError(GL_INVALID_ENUM);
1746 			params[0] = 0;
1747 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1748 			expectError(GL_INVALID_ENUM);
1749 			params[0] = GL_NEAREST;
1750 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1751 			expectError(GL_INVALID_ENUM);
1752 			m_log << TestLog::EndSection;
1753 
1754 			GLuint texture;
1755 			glGenTextures(1, &texture);
1756 			glBindTexture(GL_TEXTURE_2D, texture);
1757 
1758 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1759 			params[0] = GL_LINEAR;
1760 			glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1761 			expectError(GL_INVALID_ENUM);
1762 			glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
1763 			expectError(GL_INVALID_ENUM);
1764 			glTexParameteriv(0, 0, &params[0]);
1765 			expectError(GL_INVALID_ENUM);
1766 			m_log << TestLog::EndSection;
1767 
1768 			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.");
1769 			params[0] = 0;
1770 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1771 			expectError(GL_INVALID_ENUM);
1772 			params[0] = GL_REPEAT;
1773 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1774 			expectError(GL_INVALID_ENUM);
1775 			params[0] = 0;
1776 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1777 			expectError(GL_INVALID_ENUM);
1778 			params[0] = GL_NEAREST;
1779 			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1780 			expectError(GL_INVALID_ENUM);
1781 			m_log << TestLog::EndSection;
1782 
1783 			glDeleteTextures(1, &texture);
1784 		});
1785 
1786 	// glTexParameterfv
1787 
1788 	ES3F_ADD_API_CASE(texparameterfv, "Invalid glTexParameterfv() usage",
1789 		{
1790 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1791 			GLfloat params[1] = {GL_LINEAR};
1792 			glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1793 			expectError(GL_INVALID_ENUM);
1794 			glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
1795 			expectError(GL_INVALID_ENUM);
1796 			glTexParameterfv(0, 0, &params[0]);
1797 			expectError(GL_INVALID_ENUM);
1798 			m_log << TestLog::EndSection;
1799 
1800 			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.");
1801 			params[0] = 0.0f;
1802 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1803 			expectError(GL_INVALID_ENUM);
1804 			params[0] = GL_REPEAT;
1805 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1806 			expectError(GL_INVALID_ENUM);
1807 			params[0] = 0.0f;
1808 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1809 			expectError(GL_INVALID_ENUM);
1810 			params[0] = GL_NEAREST;
1811 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1812 			expectError(GL_INVALID_ENUM);
1813 			m_log << TestLog::EndSection;
1814 
1815 			GLuint texture;
1816 			glGenTextures(1, &texture);
1817 			glBindTexture(GL_TEXTURE_2D, texture);
1818 
1819 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1820 			params[0] = GL_LINEAR;
1821 			glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1822 			expectError(GL_INVALID_ENUM);
1823 			glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
1824 			expectError(GL_INVALID_ENUM);
1825 			glTexParameterfv(0, 0, &params[0]);
1826 			expectError(GL_INVALID_ENUM);
1827 			m_log << TestLog::EndSection;
1828 
1829 			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.");
1830 			params[0] = 0.0f;
1831 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1832 			expectError(GL_INVALID_ENUM);
1833 			params[0] = GL_REPEAT;
1834 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1835 			expectError(GL_INVALID_ENUM);
1836 			params[0] = 0.0f;
1837 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1838 			expectError(GL_INVALID_ENUM);
1839 			params[0] = GL_NEAREST;
1840 			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1841 			expectError(GL_INVALID_ENUM);
1842 			m_log << TestLog::EndSection;
1843 
1844 			glDeleteTextures(1, &texture);
1845 		});
1846 
1847 	// glCompressedTexSubImage2D
1848 
1849 	ES3F_ADD_API_CASE(compressedtexsubimage2d, "Invalid glCompressedTexSubImage2D() usage",
1850 		{
1851 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1852 			glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1853 			expectError(GL_INVALID_ENUM);
1854 			m_log << TestLog::EndSection;
1855 
1856 			deUint32				texture;
1857 			glGenTextures			(1, &texture);
1858 			glBindTexture			(GL_TEXTURE_2D, texture);
1859 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1860 			expectError				(GL_NO_ERROR);
1861 
1862 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
1863 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
1864 			expectError(GL_INVALID_OPERATION);
1865 			m_log << TestLog::EndSection;
1866 
1867 			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.");
1868 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 4, 0, 10, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
1869 			expectError(GL_INVALID_OPERATION);
1870 			m_log << TestLog::EndSection;
1871 
1872 			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.");
1873 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 4, 4, 10, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
1874 			expectError(GL_INVALID_OPERATION);
1875 			m_log << TestLog::EndSection;
1876 
1877 			m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
1878 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1879 			expectError(GL_INVALID_OPERATION);
1880 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1881 			expectError(GL_INVALID_OPERATION);
1882 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
1883 			expectError(GL_INVALID_OPERATION);
1884 			m_log << TestLog::EndSection;
1885 
1886 			glDeleteTextures		(1, &texture);
1887 		});
1888 	ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_level, "Invalid glCompressedTexSubImage2D() usage",
1889 		{
1890 			deUint32				textures[2];
1891 			glGenTextures			(2, &textures[0]);
1892 			glBindTexture			(GL_TEXTURE_2D, textures[0]);
1893 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1894 			glBindTexture			(GL_TEXTURE_CUBE_MAP, textures[1]);
1895 			FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
1896 			expectError				(GL_NO_ERROR);
1897 
1898 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1899 			glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1900 			expectError(GL_INVALID_VALUE);
1901 			m_log << TestLog::EndSection;
1902 
1903 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1904 			FOR_CUBE_FACES(faceGL,
1905 			{
1906 				glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1907 				expectError(GL_INVALID_VALUE);
1908 			});
1909 			m_log << TestLog::EndSection;
1910 
1911 			glDeleteTextures(2, &textures[0]);
1912 		});
1913 	ES3F_ADD_API_CASE(compressedtexsubimage2d_max_level, "Invalid glCompressedTexSubImage2D() usage",
1914 		{
1915 			deUint32				textures[2];
1916 			glGenTextures			(2, &textures[0]);
1917 			glBindTexture			(GL_TEXTURE_2D, textures[0]);
1918 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
1919 			glBindTexture			(GL_TEXTURE_CUBE_MAP, textures[1]);
1920 			FOR_CUBE_FACES(faceGL, glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
1921 			expectError				(GL_NO_ERROR);
1922 
1923 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1924 			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1925 			glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1926 			expectError(GL_INVALID_VALUE);
1927 			m_log << TestLog::EndSection;
1928 
1929 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1930 			deUint32 log2MaxCubemapSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1931 			FOR_CUBE_FACES(faceGL,
1932 			{
1933 				glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1934 				expectError(GL_INVALID_VALUE);
1935 			});
1936 			m_log << TestLog::EndSection;
1937 
1938 			glDeleteTextures(2, &textures[0]);
1939 		});
1940 		ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_offset, "Invalid glCompressedTexSubImage2D() usage",
1941 		{
1942 			GLuint texture;
1943 			glGenTextures(1, &texture);
1944 			glBindTexture(GL_TEXTURE_2D, texture);
1945 			glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, etc2EacDataSize(8, 8), 0);
1946 
1947 			// \note Both GL_INVALID_VALUE and GL_INVALID_OPERATION are valid here since implementation may
1948 			//		 first check if offsets are valid for certain format and only after that check that they
1949 			//		 are not negative.
1950 			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset or yoffset are negative.");
1951 
1952 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1953 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1954 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1955 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1956 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1957 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1958 
1959 			m_log << TestLog::EndSection;
1960 
1961 			glDeleteTextures(1, &texture);
1962 		});
1963 	ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_offset, "Invalid glCompressedTexSubImage2D() usage",
1964 		{
1965 			deUint32				texture;
1966 			glGenTextures			(1, &texture);
1967 			glBindTexture			(GL_TEXTURE_2D, texture);
1968 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1969 			expectError				(GL_NO_ERROR);
1970 
1971 			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1972 
1973 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 0, 8, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
1974 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1975 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 12, 4, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
1976 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1977 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 12, 8, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
1978 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1979 			m_log << TestLog::EndSection;
1980 
1981 			glDeleteTextures		(1, &texture);
1982 		});
1983 	ES3F_ADD_API_CASE(compressedtexsubimage2d_neg_width_height, "Invalid glCompressedTexSubImage2D() usage",
1984 		{
1985 			deUint32				texture;
1986 			glGenTextures			(1, &texture);
1987 			glBindTexture			(GL_TEXTURE_2D, texture);
1988 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
1989 			expectError				(GL_NO_ERROR);
1990 
1991 			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width or height is less than 0.");
1992 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1993 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1994 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1995 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1996 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
1997 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
1998 			m_log << TestLog::EndSection;
1999 
2000 			glDeleteTextures(1,		&texture);
2001 		});
2002 	ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
2003 		{
2004 			deUint32				texture;
2005 			glGenTextures			(1, &texture);
2006 			glBindTexture			(GL_TEXTURE_2D, texture);
2007 			glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2008 			expectError				(GL_NO_ERROR);
2009 
2010 			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.");
2011 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2012 			expectError(GL_INVALID_VALUE);
2013 
2014 			glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2015 			expectError(GL_INVALID_VALUE);
2016 			m_log << TestLog::EndSection;
2017 
2018 			glDeleteTextures		(1, &texture);
2019 		});
2020 	ES3F_ADD_API_CASE(compressedtexsubimage2d_invalid_buffer_target, "Invalid glCompressedTexSubImage2D() usage",
2021 		{
2022 			deUint32					buf;
2023 			deUint32					texture;
2024 			std::vector<GLubyte>		data(128);
2025 
2026 			glGenTextures				(1, &texture);
2027 			glBindTexture				(GL_TEXTURE_2D, texture);
2028 			glCompressedTexImage2D		(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2029 			glGenBuffers				(1, &buf);
2030 			glBindBuffer				(GL_PIXEL_UNPACK_BUFFER, buf);
2031 			glBufferData				(GL_PIXEL_UNPACK_BUFFER, 128, &data[0], GL_DYNAMIC_COPY);
2032 			expectError					(GL_NO_ERROR);
2033 
2034 			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...");
2035 			m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2036 			glMapBufferRange			(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2037 			glCompressedTexSubImage2D	(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2038 			expectError					(GL_INVALID_OPERATION);
2039 			glUnmapBuffer				(GL_PIXEL_UNPACK_BUFFER);
2040 			m_log << TestLog::EndSection;
2041 
2042 			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.");
2043 			glCompressedTexSubImage2D	(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2044 			expectError					(GL_INVALID_OPERATION);
2045 			m_log << TestLog::EndSection;
2046 			m_log << TestLog::EndSection;
2047 
2048 			glDeleteBuffers			(1, &buf);
2049 			glDeleteTextures		(1, &texture);
2050 		});
2051 
2052 	// glTexImage3D
2053 
2054 	ES3F_ADD_API_CASE(teximage3d, "Invalid glTexImage3D() usage",
2055 		{
2056 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2057 			glTexImage3D(0, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2058 			expectError(GL_INVALID_ENUM);
2059 			glTexImage3D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2060 			expectError(GL_INVALID_ENUM);
2061 			m_log << TestLog::EndSection;
2062 
2063 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2064 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 0, 0);
2065 			expectError(GL_INVALID_ENUM);
2066 			m_log << TestLog::EndSection;
2067 
2068 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2069 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
2070 			expectError(GL_INVALID_ENUM);
2071 			m_log << TestLog::EndSection;
2072 
2073 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants "
2074 										  "or GL_INVALID_OPERATION is generated if internalformat, format and type are not compatible.");
2075 			glTexImage3D(GL_TEXTURE_3D, 0, 0, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2076 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2077 			m_log << TestLog::EndSection;
2078 
2079 			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.");
2080 			glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_STENCIL, 1, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
2081 			expectError(GL_INVALID_OPERATION);
2082 			glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_COMPONENT, 1, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
2083 			expectError(GL_INVALID_OPERATION);
2084 			m_log << TestLog::EndSection;
2085 
2086 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
2087 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2088 			expectError(GL_INVALID_OPERATION);
2089 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2090 			expectError(GL_INVALID_OPERATION);
2091 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB10_A2, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
2092 			expectError(GL_INVALID_OPERATION);
2093 			if (glu::isContextTypeES(m_context.getRenderContext().getType()))
2094 			{
2095 				glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2096 				expectError(GL_INVALID_OPERATION);
2097 				glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, 1, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
2098 				expectError(GL_INVALID_OPERATION);
2099 			}
2100 			m_log << TestLog::EndSection;
2101 		});
2102 	ES3F_ADD_API_CASE(teximage3d_neg_level, "Invalid glTexImage3D() usage",
2103 		{
2104 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2105 			glTexImage3D(GL_TEXTURE_3D, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2106 			expectError(GL_INVALID_VALUE);
2107 			glTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2108 			expectError(GL_INVALID_VALUE);
2109 			m_log << TestLog::EndSection;
2110 		});
2111 	ES3F_ADD_API_CASE(teximage3d_max_level, "Invalid glTexImage3D() usage",
2112 		{
2113 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2114 			deUint32 log2Max3DTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2115 			glTexImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2116 			expectError(GL_INVALID_VALUE);
2117 			m_log << TestLog::EndSection;
2118 
2119 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2120 			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2121 			glTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2122 			expectError(GL_INVALID_VALUE);
2123 			m_log << TestLog::EndSection;
2124 		});
2125 	ES3F_ADD_API_CASE(teximage3d_neg_width_height_depth, "Invalid glTexImage3D() usage",
2126 		{
2127 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
2128 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2129 			expectError(GL_INVALID_VALUE);
2130 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2131 			expectError(GL_INVALID_VALUE);
2132 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2133 			expectError(GL_INVALID_VALUE);
2134 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2135 			expectError(GL_INVALID_VALUE);
2136 
2137 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2138 			expectError(GL_INVALID_VALUE);
2139 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2140 			expectError(GL_INVALID_VALUE);
2141 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2142 			expectError(GL_INVALID_VALUE);
2143 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2144 			expectError(GL_INVALID_VALUE);
2145 			m_log << TestLog::EndSection;
2146 		});
2147 	ES3F_ADD_API_CASE(teximage3d_max_width_height_depth, "Invalid glTexImage3D() usage",
2148 		{
2149 			int max3DTextureSize	= m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE) + 1;
2150 			int maxTextureSize		= m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2151 			int maxTextureLayers	= m_context.getContextInfo().getInt(GL_MAX_ARRAY_TEXTURE_LAYERS) + 1;
2152 
2153 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_3D_TEXTURE_SIZE.");
2154 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2155 			expectError(GL_INVALID_VALUE);
2156 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, max3DTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2157 			expectError(GL_INVALID_VALUE);
2158 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2159 			expectError(GL_INVALID_VALUE);
2160 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2161 			expectError(GL_INVALID_VALUE);
2162 			m_log << TestLog::EndSection;
2163 
2164 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2165 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2166 			expectError(GL_INVALID_VALUE);
2167 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, maxTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2168 			expectError(GL_INVALID_VALUE);
2169 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, maxTextureLayers, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2170 			expectError(GL_INVALID_VALUE);
2171 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, maxTextureSize, maxTextureLayers, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2172 			expectError(GL_INVALID_VALUE);
2173 			m_log << TestLog::EndSection;
2174 		});
2175 	ES3F_ADD_API_CASE(teximage3d_invalid_border, "Invalid glTexImage3D() usage",
2176 		{
2177 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0 or 1.");
2178 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2179 			expectError(GL_INVALID_VALUE);
2180 			glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2181 			expectError(GL_INVALID_VALUE);
2182 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2183 			expectError(GL_INVALID_VALUE);
2184 			glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2185 			expectError(GL_INVALID_VALUE);
2186 			m_log << TestLog::EndSection;
2187 		});
2188 	ES3F_ADD_API_CASE(teximage3d_invalid_buffer_target, "Invalid glTexImage3D() usage",
2189 		{
2190 			deUint32				buf;
2191 			deUint32				texture;
2192 			std::vector<GLubyte>	data(512);
2193 
2194 			glGenBuffers			(1, &buf);
2195 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
2196 			glBufferData			(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2197 			glGenTextures			(1, &texture);
2198 			glBindTexture			(GL_TEXTURE_3D, texture);
2199 			expectError				(GL_NO_ERROR);
2200 
2201 			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...");
2202 
2203 			m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2204 			glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2205 			glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2206 			expectError				(GL_INVALID_OPERATION);
2207 			glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
2208 			m_log << TestLog::EndSection;
2209 
2210 			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.");
2211 			glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 64, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2212 			expectError				(GL_INVALID_OPERATION);
2213 			m_log << TestLog::EndSection;
2214 
2215 			m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2216 			m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2217 			glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGB5_A1, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
2218 			expectError				(GL_INVALID_OPERATION);
2219 			m_log << TestLog::EndSection;
2220 
2221 			m_log << TestLog::EndSection;
2222 
2223 			glDeleteBuffers			(1, &buf);
2224 			glDeleteTextures		(1, &texture);
2225 		});
2226 
2227 	// glTexSubImage3D
2228 
2229 	ES3F_ADD_API_CASE(texsubimage3d, "Invalid glTexSubImage3D() usage",
2230 		{
2231 			deUint32			texture;
2232 			glGenTextures		(1, &texture);
2233 			glBindTexture		(GL_TEXTURE_3D, texture);
2234 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2235 			expectError			(GL_NO_ERROR);
2236 
2237 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2238 			glTexSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2239 			expectError(GL_INVALID_ENUM);
2240 			glTexSubImage3D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2241 			expectError(GL_INVALID_ENUM);
2242 			m_log << TestLog::EndSection;
2243 
2244 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2245 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, GL_UNSIGNED_BYTE, 0);
2246 			expectError(GL_INVALID_ENUM);
2247 			m_log << TestLog::EndSection;
2248 
2249 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if type is not a type constant.");
2250 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, 0, 0);
2251 			expectError(GL_INVALID_ENUM);
2252 			m_log << TestLog::EndSection;
2253 
2254 			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.");
2255 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2256 			expectError(GL_INVALID_OPERATION);
2257 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2258 			expectError(GL_INVALID_OPERATION);
2259 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2260 			expectError(GL_INVALID_OPERATION);
2261 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
2262 			expectError(GL_INVALID_OPERATION);
2263 			if (glu::isContextTypeES(m_context.getRenderContext().getType()))
2264 			{
2265 				glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_FLOAT, 0);
2266 				expectError(GL_INVALID_OPERATION);
2267 			}
2268 			m_log << tcu::TestLog::EndSection;
2269 
2270 			glDeleteTextures	(1, &texture);
2271 		});
2272 	ES3F_ADD_API_CASE(texsubimage3d_neg_level, "Invalid glTexSubImage3D() usage",
2273 		{
2274 			deUint32			textures[2];
2275 			glGenTextures		(2, &textures[0]);
2276 			glBindTexture		(GL_TEXTURE_3D, textures[0]);
2277 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2278 			glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2279 			glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2280 			expectError			(GL_NO_ERROR);
2281 
2282 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2283 			glTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2284 			expectError(GL_INVALID_VALUE);
2285 			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2286 			expectError(GL_INVALID_VALUE);
2287 			m_log << TestLog::EndSection;
2288 
2289 			glDeleteTextures	(2, &textures[0]);
2290 		});
2291 	ES3F_ADD_API_CASE(texsubimage3d_max_level, "Invalid glTexSubImage3D() usage",
2292 		{
2293 			deUint32			textures[2];
2294 			glGenTextures		(2, &textures[0]);
2295 			glBindTexture		(GL_TEXTURE_3D, textures[0]);
2296 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2297 			glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2298 			glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2299 			expectError			(GL_NO_ERROR);
2300 
2301 			deUint32 log2Max3DTextureSize	= deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2302 			deUint32 log2MaxTextureSize		= deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2303 
2304 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2305 			glTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2306 			expectError(GL_INVALID_VALUE);
2307 			m_log << TestLog::EndSection;
2308 
2309 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2310 			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2311 			expectError(GL_INVALID_VALUE);
2312 			m_log << TestLog::EndSection;
2313 
2314 			glDeleteTextures	(2, &textures[0]);
2315 		});
2316 	ES3F_ADD_API_CASE(texsubimage3d_neg_offset, "Invalid glTexSubImage3D() usage",
2317 		{
2318 			deUint32			textures[2];
2319 			glGenTextures		(2, &textures[0]);
2320 			glBindTexture		(GL_TEXTURE_3D, textures[0]);
2321 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2322 			glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2323 			glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2324 			expectError			(GL_NO_ERROR);
2325 
2326 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.");
2327 			glTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2328 			expectError(GL_INVALID_VALUE);
2329 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2330 			expectError(GL_INVALID_VALUE);
2331 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2332 			expectError(GL_INVALID_VALUE);
2333 			glTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2334 			expectError(GL_INVALID_VALUE);
2335 			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2336 			expectError(GL_INVALID_VALUE);
2337 			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2338 			expectError(GL_INVALID_VALUE);
2339 			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2340 			expectError(GL_INVALID_VALUE);
2341 			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2342 			expectError(GL_INVALID_VALUE);
2343 			m_log << TestLog::EndSection;
2344 
2345 			glDeleteTextures	(2, &textures[0]);
2346 		});
2347 	ES3F_ADD_API_CASE(texsubimage3d_invalid_offset, "Invalid glTexSubImage3D() usage",
2348 		{
2349 			deUint32			texture;
2350 			glGenTextures		(1, &texture);
2351 			glBindTexture		(GL_TEXTURE_3D, texture);
2352 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2353 			expectError			(GL_NO_ERROR);
2354 
2355 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2356 			glTexSubImage3D(GL_TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2357 			expectError(GL_INVALID_VALUE);
2358 			m_log << TestLog::EndSection;
2359 
2360 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2361 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2362 			expectError(GL_INVALID_VALUE);
2363 			m_log << TestLog::EndSection;
2364 
2365 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + depth > texture_depth.");
2366 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2367 			expectError(GL_INVALID_VALUE);
2368 			m_log << TestLog::EndSection;
2369 
2370 			glDeleteTextures	(1, &texture);
2371 		});
2372 	ES3F_ADD_API_CASE(texsubimage3d_neg_width_height, "Invalid glTexSubImage3D() usage",
2373 		{
2374 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2375 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2376 			expectError(GL_INVALID_VALUE);
2377 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2378 			expectError(GL_INVALID_VALUE);
2379 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2380 			expectError(GL_INVALID_VALUE);
2381 			glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2382 			expectError(GL_INVALID_VALUE);
2383 			m_log << TestLog::EndSection;
2384 		});
2385 	ES3F_ADD_API_CASE(texsubimage3d_invalid_buffer_target, "Invalid glTexSubImage3D() usage",
2386 		{
2387 			deUint32				buf;
2388 			deUint32				texture;
2389 			std::vector<GLubyte>	data(512);
2390 
2391 			glGenTextures			(1, &texture);
2392 			glBindTexture			(GL_TEXTURE_3D, texture);
2393 			glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2394 			glGenBuffers			(1, &buf);
2395 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
2396 			glBufferData			(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2397 			expectError				(GL_NO_ERROR);
2398 
2399 			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...");
2400 
2401 			m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2402 			glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 512, GL_MAP_WRITE_BIT);
2403 			glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2404 			expectError				(GL_INVALID_OPERATION);
2405 			glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
2406 			m_log << TestLog::EndSection;
2407 
2408 			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.");
2409 			glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 16, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2410 			expectError				(GL_INVALID_OPERATION);
2411 			m_log << TestLog::EndSection;
2412 
2413 			m_log << TestLog::Section("", "...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2414 			m_log << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2415 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, 0);
2416 			glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2417 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
2418 			expectError				(GL_NO_ERROR);
2419 			glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
2420 			expectError				(GL_INVALID_OPERATION);
2421 			m_log << TestLog::EndSection;
2422 
2423 			m_log << TestLog::EndSection;
2424 
2425 			glDeleteBuffers			(1, &buf);
2426 			glDeleteTextures		(1, &texture);
2427 		});
2428 
2429 	// glCopyTexSubImage3D
2430 
2431 	ES3F_ADD_API_CASE(copytexsubimage3d, "Invalid glCopyTexSubImage3D() usage",
2432 		{
2433 			GLuint texture;
2434 			glGenTextures	(1, &texture);
2435 			glBindTexture	(GL_TEXTURE_3D, texture);
2436 			glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2437 
2438 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2439 			glCopyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 4);
2440 			expectError(GL_INVALID_ENUM);
2441 			m_log << TestLog::EndSection;
2442 
2443 			glDeleteTextures(1, &texture);
2444 		});
2445 	ES3F_ADD_API_CASE(copytexsubimage3d_neg_level, "Invalid glCopyTexSubImage3D() usage",
2446 		{
2447 			deUint32			textures[2];
2448 			glGenTextures		(2, &textures[0]);
2449 			glBindTexture		(GL_TEXTURE_3D, textures[0]);
2450 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2451 			glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2452 			glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2453 			expectError			(GL_NO_ERROR);
2454 
2455 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2456 			glCopyTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 4);
2457 			expectError(GL_INVALID_VALUE);
2458 			glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
2459 			expectError(GL_INVALID_VALUE);
2460 			m_log << TestLog::EndSection;
2461 
2462 			glDeleteTextures(2, &textures[0]);
2463 		});
2464 	ES3F_ADD_API_CASE(copytexsubimage3d_max_level, "Invalid glCopyTexSubImage3D() usage",
2465 		{
2466 			deUint32	log2Max3DTextureSize	= deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2467 			deUint32	log2MaxTextureSize		= deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2468 
2469 			deUint32			textures[2];
2470 			glGenTextures		(2, &textures[0]);
2471 			glBindTexture		(GL_TEXTURE_3D, textures[0]);
2472 			glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2473 			glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2474 			glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2475 			expectError			(GL_NO_ERROR);
2476 
2477 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2478 			glCopyTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 4);
2479 			expectError(GL_INVALID_VALUE);
2480 			m_log << TestLog::EndSection;
2481 
2482 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2483 			glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 4);
2484 			expectError(GL_INVALID_VALUE);
2485 			m_log << TestLog::EndSection;
2486 
2487 			glDeleteTextures(2, &textures[0]);
2488 		});
2489 	ES3F_ADD_API_CASE(copytexsubimage3d_neg_offset, "Invalid glCopyTexSubImage3D() usage",
2490 		{
2491 			GLuint texture;
2492 			glGenTextures	(1, &texture);
2493 			glBindTexture	(GL_TEXTURE_3D, texture);
2494 			glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2495 
2496 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.");
2497 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0,  0, 0, 0, 4, 4);
2498 			expectError(GL_INVALID_VALUE);
2499 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4);
2500 			expectError(GL_INVALID_VALUE);
2501 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4);
2502 			expectError(GL_INVALID_VALUE);
2503 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4);
2504 			expectError(GL_INVALID_VALUE);
2505 			m_log << TestLog::EndSection;
2506 
2507 			glDeleteTextures(1, &texture);
2508 		});
2509 	ES3F_ADD_API_CASE(copytexsubimage3d_invalid_offset, "Invalid glCopyTexSubImage3D() usage",
2510 		{
2511 			GLuint texture;
2512 			glGenTextures	(1, &texture);
2513 			glBindTexture	(GL_TEXTURE_3D, texture);
2514 			glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2515 
2516 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
2517 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4);
2518 			expectError(GL_INVALID_VALUE);
2519 			m_log << TestLog::EndSection;
2520 
2521 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
2522 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4);
2523 			expectError(GL_INVALID_VALUE);
2524 			m_log << TestLog::EndSection;
2525 
2526 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if zoffset + 1 > texture_depth.");
2527 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4);
2528 			expectError(GL_INVALID_VALUE);
2529 			m_log << TestLog::EndSection;
2530 
2531 			glDeleteTextures(1, &texture);
2532 		});
2533 	ES3F_ADD_API_CASE(copytexsubimage3d_neg_width_height, "Invalid glCopyTexSubImage3D() usage",
2534 		{
2535 			GLuint texture;
2536 			glGenTextures	(1, &texture);
2537 			glBindTexture	(GL_TEXTURE_3D, texture);
2538 			glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2539 
2540 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width < 0.");
2541 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4);
2542 			expectError(GL_INVALID_VALUE);
2543 			m_log << TestLog::EndSection;
2544 
2545 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if height < 0.");
2546 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4);
2547 			expectError(GL_INVALID_VALUE);
2548 			m_log << TestLog::EndSection;
2549 
2550 			glDeleteTextures(1, &texture);
2551 		});
2552 	ES3F_ADD_API_CASE(copytexsubimage3d_incomplete_framebuffer, "Invalid glCopyTexSubImage3D() usage",
2553 		{
2554 			GLuint fbo;
2555 			GLuint texture[2];
2556 
2557 			glGenTextures			(2, texture);
2558 			glBindTexture			(GL_TEXTURE_3D, texture[0]);
2559 			glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2560 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture[1]);
2561 			glTexImage3D			(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2562 			glGenFramebuffers		(1, &fbo);
2563 			glBindFramebuffer		(GL_READ_FRAMEBUFFER, fbo);
2564 			glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
2565 
2566 			m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
2567 			glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4);
2568 			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2569 			glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
2570 			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2571 			m_log << tcu::TestLog::EndSection;
2572 
2573 			glBindFramebuffer(GL_FRAMEBUFFER, 0);
2574 			glDeleteFramebuffers(1, &fbo);
2575 			glDeleteTextures(2, texture);
2576 		});
2577 
2578 	// glCompressedTexImage3D
2579 
2580 	ES3F_ADD_API_CASE(compressedteximage3d, "Invalid glCompressedTexImage3D() usage",
2581 		{
2582 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2583 			glCompressedTexImage3D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2584 			expectError(GL_INVALID_ENUM);
2585 			glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2586 			expectError(GL_INVALID_ENUM);
2587 			m_log << TestLog::EndSection;
2588 
2589 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.");
2590 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, 0);
2591 			expectError(GL_INVALID_ENUM);
2592 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 0, 0, 0, 0, 0, 0);
2593 			expectError(GL_INVALID_ENUM);
2594 			m_log << TestLog::EndSection;
2595 		});
2596 	ES3F_ADD_API_CASE(compressedteximage3d_neg_level, "Invalid glCompressedTexImage3D() usage",
2597 		{
2598 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2599 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2600 			expectError(GL_INVALID_VALUE);
2601 			m_log << TestLog::EndSection;
2602 		});
2603 	ES3F_ADD_API_CASE(compressedteximage3d_max_level, "Invalid glCompressedTexImage3D() usage",
2604 		{
2605 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2606 			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2607 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
2608 			expectError(GL_INVALID_VALUE);
2609 			m_log << TestLog::EndSection;
2610 		});
2611 	ES3F_ADD_API_CASE(compressedteximage3d_neg_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2612 		{
2613 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
2614 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0, 0);
2615 			expectError(GL_INVALID_VALUE);
2616 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0, 0);
2617 			expectError(GL_INVALID_VALUE);
2618 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0, 0);
2619 			expectError(GL_INVALID_VALUE);
2620 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, 0, 0);
2621 			expectError(GL_INVALID_VALUE);
2622 			m_log << TestLog::EndSection;
2623 		});
2624 	ES3F_ADD_API_CASE(compressedteximage3d_max_width_height_depth, "Invalid glCompressedTexImage3D() usage",
2625 		{
2626 			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
2627 			int maxTextureLayers = m_context.getContextInfo().getInt(GL_MAX_ARRAY_TEXTURE_LAYERS) + 1;
2628 
2629 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2630 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, 0, 0);
2631 			expectError(GL_INVALID_VALUE);
2632 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, 0, 0);
2633 			expectError(GL_INVALID_VALUE);
2634 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureLayers, 0, 0, 0);
2635 			expectError(GL_INVALID_VALUE);
2636 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, maxTextureLayers, 0, 0, 0);
2637 			expectError(GL_INVALID_VALUE);
2638 			m_log << TestLog::EndSection;
2639 		});
2640 	ES3F_ADD_API_CASE(compressedteximage3d_invalid_border, "Invalid glCompressedTexImage3D() usage",
2641 		{
2642 			bool	isES = glu::isContextTypeES(m_context.getRenderContext().getType());
2643 			GLenum	error = isES ? GL_INVALID_VALUE : GL_INVALID_OPERATION;
2644 
2645 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
2646 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0, 0);
2647 			expectError(error);
2648 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, 0, 0);
2649 			expectError(error);
2650 			m_log << TestLog::EndSection;
2651 		});
2652 	ES3F_ADD_API_CASE(compressedteximage3d_invalid_size, "Invalid glCompressedTexImage3D() usage",
2653 		{
2654 			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.");
2655 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, -1, 0);
2656 			expectError(GL_INVALID_VALUE);
2657 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*8, 0);
2658 			expectError(GL_INVALID_VALUE);
2659 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, 4*4*16, 0);
2660 			expectError(GL_INVALID_VALUE);
2661 			glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, 4*4*16, 0);
2662 			expectError(GL_INVALID_VALUE);
2663 			m_log << TestLog::EndSection;
2664 		});
2665 	ES3F_ADD_API_CASE(compressedteximage3d_invalid_buffer_target, "Invalid glCompressedTexImage3D() usage",
2666 		{
2667 			deUint32				buf;
2668 			std::vector<GLubyte>	data(512);
2669 
2670 			glGenBuffers			(1, &buf);
2671 			glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
2672 			glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
2673 			expectError				(GL_NO_ERROR);
2674 
2675 			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.");
2676 			glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 64, GL_MAP_WRITE_BIT);
2677 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 1, 0, etc2DataSize(4, 4), 0);
2678 			expectError				(GL_INVALID_OPERATION);
2679 			glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
2680 			m_log << TestLog::EndSection;
2681 
2682 			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.");
2683 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, etc2DataSize(16, 16), 0);
2684 			expectError				(GL_INVALID_OPERATION);
2685 			m_log << TestLog::EndSection;
2686 
2687 			glDeleteBuffers			(1, &buf);
2688 		});
2689 	ES3F_ADD_API_CASE(compressedteximage3d_invalid_astc_target, "Invalid glCompressedTexImage3D() ASTC 3D targets",
2690 		{
2691 			// GLES 3.0.4, Sec 3.8.6, p.147: For example, the
2692 			// compressed image format might be supported only for 2D
2693 			// textures ... result in an INVALID_OPERATION error.
2694 			// Also, if LDR is supported, formats cannot be invalid enums
2695 
2696 			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_sliced_3d") ||
2697 				m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
2698 				m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
2699 			{
2700 				m_log.writeMessage("Full ASTC supported. No negative API requirements.");
2701 			}
2702 			else
2703 			{
2704 				const GLuint requiredError = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr") ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
2705 
2706 				if (requiredError == GL_INVALID_OPERATION)
2707 					m_log.writeMessage("GL_INVALID_OPERATION should be generated if using TEXTURE_3D with LDR ASTC.");
2708 				else
2709 					m_log.writeMessage("GL_INVALID_ENUM should be generated if no ASTC extensions are present.");
2710 
2711 				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
2712 				{
2713 					const GLuint				format		= s_astcFormats[formatNdx];
2714 					const CompressedTexFormat	tcuFormat	= mapGLCompressedTexFormat(format);
2715 					const IVec3					blockPixels = getBlockPixelSize(tcuFormat);
2716 					const size_t				blockBytes	= getBlockSize(tcuFormat);
2717 					const vector<deUint8>		unusedData	(blockBytes);
2718 
2719 					glCompressedTexImage3D(GL_TEXTURE_3D, 0, format, blockPixels.x(), blockPixels.y(), blockPixels.z(), 0, (int)blockBytes, &unusedData[0]);
2720 					expectError(requiredError);
2721 				}
2722 			}
2723 		});
2724 
2725 	// glCompressedTexSubImage3D
2726 
2727 	ES3F_ADD_API_CASE(compressedtexsubimage3d, "Invalid glCompressedTexSubImage3D() usage",
2728 		{
2729 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
2730 			glCompressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2731 			expectError(GL_INVALID_ENUM);
2732 			m_log << TestLog::EndSection;
2733 
2734 			deUint32				texture;
2735 			glGenTextures			(1, &texture);
2736 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2737 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0, etc2EacDataSize(18, 18), 0);
2738 			expectError				(GL_NO_ERROR);
2739 
2740 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
2741 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
2742 			expectError(GL_INVALID_OPERATION);
2743 			m_log << TestLog::EndSection;
2744 
2745 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.");
2746 			glCompressedTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(18, 18), 0);
2747 			expectError(GL_INVALID_OPERATION);
2748 			m_log << TestLog::EndSection;
2749 
2750 			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.");
2751 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
2752 			expectError(GL_INVALID_OPERATION);
2753 			m_log << TestLog::EndSection;
2754 
2755 			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.");
2756 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
2757 			expectError(GL_INVALID_OPERATION);
2758 			m_log << TestLog::EndSection;
2759 
2760 			m_log << TestLog::Section("", "For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
2761 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2762 			expectError(GL_INVALID_OPERATION);
2763 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2764 			expectError(GL_INVALID_OPERATION);
2765 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2766 			expectError(GL_INVALID_OPERATION);
2767 			m_log << TestLog::EndSection;
2768 
2769 			glDeleteTextures		(1, &texture);
2770 		});
2771 	ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_level, "Invalid glCompressedTexSubImage3D() usage",
2772 		{
2773 			deUint32				texture;
2774 			glGenTextures			(1, &texture);
2775 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2776 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2777 			expectError				(GL_NO_ERROR);
2778 
2779 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2780 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2781 			expectError(GL_INVALID_VALUE);
2782 			m_log << TestLog::EndSection;
2783 
2784 			glDeleteTextures		(1, &texture);
2785 		});
2786 	ES3F_ADD_API_CASE(compressedtexsubimage3d_max_level, "Invalid glCompressedTexSubImage3D() usage",
2787 		{
2788 			deUint32				texture;
2789 			glGenTextures			(1, &texture);
2790 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2791 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2792 			expectError				(GL_NO_ERROR);
2793 
2794 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2795 			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2796 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2797 			expectError(GL_INVALID_VALUE);
2798 			m_log << TestLog::EndSection;
2799 
2800 			glDeleteTextures		(1, &texture);
2801 		});
2802 	ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_offset, "Invalid glCompressedTexSubImage3D() usage",
2803 		{
2804 			deUint32				texture;
2805 			glGenTextures			(1, &texture);
2806 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2807 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2808 			expectError				(GL_NO_ERROR);
2809 
2810 			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.");
2811 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2812 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2813 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2814 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2815 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2816 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2817 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2818 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2819 			m_log << TestLog::EndSection;
2820 
2821 			glDeleteTextures		(1, &texture);
2822 		});
2823 	ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_offset, "Invalid glCompressedTexSubImage3D() usage",
2824 		{
2825 			deUint32				texture;
2826 			glGenTextures			(1, &texture);
2827 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2828 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, etc2EacDataSize(4, 4), 0);
2829 			expectError				(GL_NO_ERROR);
2830 
2831 			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
2832 
2833 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
2834 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2835 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
2836 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2837 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2838 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2839 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
2840 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2841 			m_log << TestLog::EndSection;
2842 
2843 			glDeleteTextures		(1, &texture);
2844 		});
2845 	ES3F_ADD_API_CASE(compressedtexsubimage3d_neg_width_height_depth, "Invalid glCompressedTexSubImage3D() usage",
2846 		{
2847 			deUint32				texture;
2848 			glGenTextures			(1, &texture);
2849 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2850 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2851 			expectError				(GL_NO_ERROR);
2852 
2853 			m_log << TestLog::Section("", "GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width, height or depth are negative.");
2854 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2855 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2856 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2857 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2858 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2859 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2860 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2861 			expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2862 			m_log << TestLog::EndSection;
2863 
2864 			glDeleteTextures		(1, &texture);
2865 		});
2866 	ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_size, "Invalid glCompressedTexSubImage3D() usage",
2867 		{
2868 			deUint32				texture;
2869 			glGenTextures			(1, &texture);
2870 			glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
2871 			glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*16, 0);
2872 			expectError				(GL_NO_ERROR);
2873 
2874 			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.");
2875 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2876 			expectError(GL_INVALID_VALUE);
2877 
2878 			glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2879 			expectError(GL_INVALID_VALUE);
2880 			m_log << TestLog::EndSection;
2881 
2882 			glDeleteTextures		(1, &texture);
2883 		});
2884 	ES3F_ADD_API_CASE(compressedtexsubimage3d_invalid_buffer_target, "Invalid glCompressedTexSubImage3D() usage",
2885 		{
2886 			deUint32					buf;
2887 			deUint32					texture;
2888 			GLsizei						bufferSize = etc2EacDataSize(4, 4);
2889 			std::vector<GLubyte>		data(bufferSize);
2890 
2891 			glGenTextures				(1, &texture);
2892 			glBindTexture				(GL_TEXTURE_2D_ARRAY, texture);
2893 			glCompressedTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
2894 			glGenBuffers				(1, &buf);
2895 			glBindBuffer				(GL_PIXEL_UNPACK_BUFFER, buf);
2896 			glBufferData				(GL_PIXEL_UNPACK_BUFFER, bufferSize, &data[0], GL_DYNAMIC_COPY);
2897 			expectError					(GL_NO_ERROR);
2898 
2899 			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...");
2900 			m_log << TestLog::Section("", "...the buffer object's data store is currently mapped.");
2901 			glMapBufferRange			(GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, GL_MAP_WRITE_BIT);
2902 			glCompressedTexSubImage3D	(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2903 			expectError					(GL_INVALID_OPERATION);
2904 			glUnmapBuffer				(GL_PIXEL_UNPACK_BUFFER);
2905 			m_log << TestLog::EndSection;
2906 
2907 			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.");
2908 			glCompressedTexSubImage3D	(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2909 			expectError					(GL_INVALID_OPERATION);
2910 			m_log << TestLog::EndSection;
2911 			m_log << TestLog::EndSection;
2912 
2913 			glDeleteBuffers			(1, &buf);
2914 			glDeleteTextures		(1, &texture);
2915 		});
2916 
2917 	// glTexStorage2D
2918 
2919 	ES3F_ADD_API_CASE(texstorage2d, "Invalid glTexStorage2D() usage",
2920 		{
2921 			deUint32		texture;
2922 			glGenTextures	(1, &texture);
2923 			glBindTexture	(GL_TEXTURE_2D, texture);
2924 
2925 			m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
2926 			glTexStorage2D	(GL_TEXTURE_2D, 1, 0, 16, 16);
2927 			expectError		(GL_INVALID_ENUM, GL_INVALID_VALUE);
2928 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, 16, 16);
2929 			expectError		(GL_INVALID_ENUM, GL_INVALID_VALUE);
2930 			m_log << TestLog::EndSection;
2931 
2932 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
2933 			glTexStorage2D	(0, 1, GL_RGBA8, 16, 16);
2934 			expectError		(GL_INVALID_ENUM);
2935 			glTexStorage2D	(GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16);
2936 			expectError		(GL_INVALID_ENUM);
2937 			glTexStorage2D	(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16);
2938 			expectError		(GL_INVALID_ENUM);
2939 			m_log << TestLog::EndSection;
2940 
2941 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height are less than 1.");
2942 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 16);
2943 			expectError		(GL_INVALID_VALUE);
2944 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 0);
2945 			expectError		(GL_INVALID_VALUE);
2946 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 0);
2947 			expectError		(GL_INVALID_VALUE);
2948 			m_log << TestLog::EndSection;
2949 
2950 			glDeleteTextures(1, &texture);
2951 		});
2952 
2953 	ES3F_ADD_API_CASE(texstorage2d_invalid_binding, "Invalid glTexStorage2D() usage",
2954 		{
2955 			glBindTexture	(GL_TEXTURE_2D, 0);
2956 
2957 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
2958 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2959 			expectError		(GL_INVALID_OPERATION);
2960 			m_log << TestLog::EndSection;
2961 
2962 			deUint32		texture;
2963 			glGenTextures	(1, &texture);
2964 			glBindTexture	(GL_TEXTURE_2D, texture);
2965 
2966 			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.");
2967 			deInt32			immutable	= -1;
2968 			glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
2969 			m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
2970 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2971 			expectError		(GL_NO_ERROR);
2972 			glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
2973 			m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
2974 			glTexStorage2D	(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
2975 			expectError		(GL_INVALID_OPERATION);
2976 			m_log << TestLog::EndSection;
2977 
2978 			glDeleteTextures(1, &texture);
2979 		});
2980 	ES3F_ADD_API_CASE(texstorage2d_invalid_levels, "Invalid glTexStorage2D() usage",
2981 		{
2982 			deUint32		texture;
2983 			glGenTextures	(1, &texture);
2984 			glBindTexture	(GL_TEXTURE_2D, texture);
2985 
2986 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
2987 			glTexStorage2D	(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16);
2988 			expectError		(GL_INVALID_VALUE);
2989 			glTexStorage2D	(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0);
2990 			expectError		(GL_INVALID_VALUE);
2991 			m_log << TestLog::EndSection;
2992 
2993 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1");
2994 			deUint32 log2MaxSize = deLog2Floor32(deMax32(16, 4)) + 1 + 1;
2995 			glTexStorage2D	(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 4);
2996 			expectError		(GL_INVALID_OPERATION);
2997 			glTexStorage2D	(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 4, 16);
2998 			expectError		(GL_INVALID_OPERATION);
2999 			glTexStorage2D	(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 16);
3000 			expectError		(GL_INVALID_OPERATION);
3001 			m_log << TestLog::EndSection;
3002 
3003 			glDeleteTextures(1, &texture);
3004 		});
3005 	ES3F_ADD_API_CASE(texstorage2d_invalid_astc_target, "ASTC formats require extensions present.",
3006 		{
3007 			// GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
3008 			// for which this command would have been valid, an
3009 			// INVALID_OPERATION error is generated. Also: If
3010 			// executing the pseudo-code would result in any other
3011 			// error, the error is generated and the command will have
3012 			// no effect.
3013 			// In conclusion: Expect same errors as with TexImage?D
3014 
3015 			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
3016 			{
3017 				m_log.writeMessage("ASTC supported. No negative API requirements.");
3018 			}
3019 			else
3020 			{
3021 				// In earlier tests both codes are accepted for invalid target format.
3022 				m_log.writeMessage("GL_INVALID_ENUM or GL_INVALID_VALUE should be generated if no ASTC extensions are present.");
3023 
3024 				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3025 				{
3026 					const GLuint				format		= s_astcFormats[formatNdx];
3027 					const CompressedTexFormat	tcuFormat	= mapGLCompressedTexFormat(format);
3028 					const IVec3					blockPixels = getBlockPixelSize(tcuFormat);
3029 					const deInt32				cubeSize	= blockPixels.x() * blockPixels.y(); // Divisible by the block size and square
3030 					deUint32					texture		= 0;
3031 
3032 					glGenTextures	(1, &texture);
3033 					glBindTexture	(GL_TEXTURE_2D, texture);
3034 
3035 					glTexStorage2D	(GL_TEXTURE_2D, 1, format, blockPixels.x(), blockPixels.y());
3036 					expectError		(GL_INVALID_ENUM, GL_INVALID_VALUE);
3037 
3038 					glDeleteTextures(1, &texture);
3039 
3040 					glGenTextures	(1, &texture);
3041 					glBindTexture	(GL_TEXTURE_CUBE_MAP, texture);
3042 
3043 					glTexStorage2D	(GL_TEXTURE_CUBE_MAP, 1, format, cubeSize, cubeSize);
3044 					expectError		(GL_INVALID_ENUM, GL_INVALID_VALUE);
3045 
3046 					glDeleteTextures(1, &texture);
3047 				}
3048 			}
3049 		});
3050 
3051 	// glTexStorage3D
3052 
3053 	ES3F_ADD_API_CASE(texstorage3d, "Invalid glTexStorage3D() usage",
3054 		{
3055 			deUint32		texture;
3056 			glGenTextures	(1, &texture);
3057 			glBindTexture	(GL_TEXTURE_3D, texture);
3058 
3059 			m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3060 			glTexStorage3D	(GL_TEXTURE_3D, 1, 0, 4, 4, 4);
3061 			expectError		(GL_INVALID_ENUM, GL_INVALID_VALUE);
3062 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA_INTEGER, 4, 4, 4);
3063 			expectError		(GL_INVALID_ENUM, GL_INVALID_VALUE);
3064 			m_log << TestLog::EndSection;
3065 
3066 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3067 			glTexStorage3D	(0, 1, GL_RGBA8, 4, 4, 4);
3068 			expectError		(GL_INVALID_ENUM);
3069 			glTexStorage3D	(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 4, 4, 4);
3070 			expectError		(GL_INVALID_ENUM);
3071 			glTexStorage3D	(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 4);
3072 			expectError		(GL_INVALID_ENUM);
3073 			m_log << TestLog::EndSection;
3074 
3075 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width, height or depth are less than 1.");
3076 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 4, 4);
3077 			expectError		(GL_INVALID_VALUE);
3078 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 0, 4);
3079 			expectError		(GL_INVALID_VALUE);
3080 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 0);
3081 			expectError		(GL_INVALID_VALUE);
3082 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 0, 0);
3083 			expectError		(GL_INVALID_VALUE);
3084 			m_log << TestLog::EndSection;
3085 
3086 			glDeleteTextures(1, &texture);
3087 		});
3088 	ES3F_ADD_API_CASE(texstorage3d_invalid_binding, "Invalid glTexStorage3D() usage",
3089 		{
3090 			glBindTexture	(GL_TEXTURE_3D, 0);
3091 
3092 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3093 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3094 			expectError		(GL_INVALID_OPERATION);
3095 			m_log << TestLog::EndSection;
3096 
3097 			deUint32		texture;
3098 			glGenTextures	(1, &texture);
3099 			glBindTexture	(GL_TEXTURE_3D, texture);
3100 
3101 			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.");
3102 			deInt32			immutable	= -1;
3103 			glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3104 			m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3105 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3106 			expectError		(GL_NO_ERROR);
3107 			glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3108 			m_log << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3109 			glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3110 			expectError		(GL_INVALID_OPERATION);
3111 			m_log << TestLog::EndSection;
3112 
3113 			glDeleteTextures(1, &texture);
3114 		});
3115 	ES3F_ADD_API_CASE(texstorage3d_invalid_levels, "Invalid glTexStorage3D() usage",
3116 		{
3117 			deUint32		texture;
3118 			glGenTextures	(1, &texture);
3119 			glBindTexture	(GL_TEXTURE_3D, texture);
3120 
3121 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if levels is less than 1.");
3122 			glTexStorage3D	(GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4);
3123 			expectError		(GL_INVALID_VALUE);
3124 			glTexStorage3D	(GL_TEXTURE_3D, 0, GL_RGBA8, 0, 0, 0);
3125 			expectError		(GL_INVALID_VALUE);
3126 			m_log << TestLog::EndSection;
3127 
3128 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1");
3129 			deUint32 log2MaxSize = deLog2Floor32(8) + 1 + 1;
3130 			glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 2, 2);
3131 			expectError		(GL_INVALID_OPERATION);
3132 			glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 8, 2);
3133 			expectError		(GL_INVALID_OPERATION);
3134 			glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 2, 8);
3135 			expectError		(GL_INVALID_OPERATION);
3136 			glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 8, 8);
3137 			expectError		(GL_INVALID_OPERATION);
3138 			m_log << TestLog::EndSection;
3139 
3140 			glDeleteTextures(1, &texture);
3141 		});
3142 
3143 	ES3F_ADD_API_CASE(texstorage3d_invalid_astc_target, "Invalid glTexStorage3D() ASTC 3D targets",
3144 		{
3145 			// GLES 3.0.4, Sec 3.8.4, p.136: If there is no imageSize
3146 			// for which this command would have been valid, an
3147 			// INVALID_OPERATION error is generated. Also: If
3148 			// executing the pseudo-code would result in any other
3149 			// error, the error is generated and the command will have
3150 			// no effect.
3151 			// In conclusion: Expect same errors as with TexImage?D
3152 
3153 			if (m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_sliced_3d") ||
3154 				m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_hdr") ||
3155 				m_context.getContextInfo().isExtensionSupported("GL_OES_texture_compression_astc"))
3156 			{
3157 				m_log.writeMessage("Full ASTC supported. No negative API requirements.");
3158 			}
3159 			else
3160 			{
3161 				const bool ldrAstcSupported = m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr");
3162 				if (ldrAstcSupported)
3163 					m_log.writeMessage("GL_INVALID_OPERATION should be generated if using TEXTURE_3D with LDR.");
3164 				else
3165 					// In earlier tests both codes are accepted for invalid target format.
3166 					m_log.writeMessage("GL_INVALID_ENUM or GL_INVALID_VALUE should be generated if no ASTC extensions are present.");
3167 
3168 				for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_astcFormats); formatNdx++)
3169 				{
3170 					const GLuint				format		= s_astcFormats[formatNdx];
3171 					const CompressedTexFormat	tcuFormat	= mapGLCompressedTexFormat(format);
3172 					const IVec3					blockPixels = getBlockPixelSize(tcuFormat);
3173 					deUint32					texture		= 0;
3174 
3175 					glGenTextures	(1, &texture);
3176 					glBindTexture	(GL_TEXTURE_3D, texture);
3177 
3178 					glTexStorage3D	(GL_TEXTURE_3D, 1, format, blockPixels.x(), blockPixels.y(), blockPixels.z());
3179 
3180 					if (ldrAstcSupported)
3181 						expectError(GL_INVALID_OPERATION);
3182 					else
3183 						expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3184 
3185 					glDeleteTextures(1, &texture);
3186 				}
3187 			}
3188 		});
3189 }
3190 
3191 } // Functional
3192 } // gles3
3193 } // deqp
3194