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