1/*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.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 "es2fNegativeTextureApiTests.hpp"
25#include "es2fApiCase.hpp"
26#include "tcuFormatUtil.hpp"
27#include "gluContextInfo.hpp"
28
29#include <vector>
30#include <algorithm>
31
32#include "glwEnums.hpp"
33#include "glwDefs.hpp"
34
35using namespace glw; // GL types
36
37namespace deqp
38{
39namespace gles2
40{
41namespace Functional
42{
43
44using tcu::TestLog;
45using std::vector;
46
47static deUint32 cubeFaceToGLFace (tcu::CubeFace face)
48{
49	switch (face)
50	{
51		case tcu::CUBEFACE_NEGATIVE_X: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
52		case tcu::CUBEFACE_POSITIVE_X: return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
53		case tcu::CUBEFACE_NEGATIVE_Y: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
54		case tcu::CUBEFACE_POSITIVE_Y: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
55		case tcu::CUBEFACE_NEGATIVE_Z: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
56		case tcu::CUBEFACE_POSITIVE_Z: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
57		default:
58			DE_ASSERT(DE_FALSE);
59			return GL_NONE;
60	}
61}
62
63#define FOR_CUBE_FACES(FACE_GL_VAR, BODY)												\
64	do																					\
65	{																					\
66		for (int faceIterTcu = 0; faceIterTcu < tcu::CUBEFACE_LAST; faceIterTcu++)		\
67		{																				\
68			const GLenum FACE_GL_VAR = cubeFaceToGLFace((tcu::CubeFace)faceIterTcu);	\
69			BODY																		\
70		}																				\
71	} while (false)
72
73static void getCompressedTexSubImage2DFormat(const vector<deInt32>& supported, vector<deInt32>& accepted)
74{
75	// Find a supported compressed texture format that is accepted by compressedTexSubImage2D()
76
77	static const GLuint compressedTexSubImage2DFormats[] =
78	{
79		0x83F0,	// GL_COMPRESSED_RGB_S3TC_DXT1_EXT
80		0x83F1,	// GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
81		0x8C00,	// GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
82		0x8C01,	// GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
83		0x8C02,	// GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
84		0x8C03	// GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
85	};
86
87	for (int i = 0; i < (int)supported.size(); i++)
88	{
89		vector<deInt32>::const_iterator fmt = std::find(supported.begin(), supported.end(), compressedTexSubImage2DFormats[i]);
90		if (fmt != supported.end())
91			accepted.push_back(*fmt);
92	}
93}
94
95NegativeTextureApiTests::NegativeTextureApiTests (Context& context)
96	: TestCaseGroup(context, "texture", "Negative Texture API Cases")
97{
98}
99
100NegativeTextureApiTests::~NegativeTextureApiTests (void)
101{
102}
103
104void NegativeTextureApiTests::init (void)
105{
106	// glActiveTexture
107
108	ES2F_ADD_API_CASE(activetexture_invalid_texture, "Invalid glActiveTexture() usage",
109		{
110			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).");
111			glActiveTexture(-1);
112			expectError(GL_INVALID_ENUM);
113			int numMaxTextureUnits = m_context.getContextInfo().getInt(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
114			glActiveTexture(GL_TEXTURE0 + numMaxTextureUnits);
115			expectError(GL_INVALID_ENUM);
116			m_log << TestLog::EndSection;
117		});
118
119	// glBindTexture
120
121	ES2F_ADD_API_CASE(bindtexture_invalid_target, "Invalid glBindTexture() usage",
122		{
123			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the allowable values.");
124			glBindTexture(0, 1);
125			expectError(GL_INVALID_ENUM);
126			m_log << TestLog::EndSection;
127		});
128	ES2F_ADD_API_CASE(bindtexture_type_mismatch, "Invalid glBindTexture() usage",
129		{
130			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture was previously created with a target that doesn't match that of target.");
131			GLuint texture;
132			glGenTextures(1, &texture);
133			glBindTexture(GL_TEXTURE_2D, texture);
134			glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
135			expectError(GL_INVALID_OPERATION);
136			glDeleteTextures(1, &texture);
137			m_log << TestLog::EndSection;
138		});
139
140	// glCompressedTexImage2D
141
142	ES2F_ADD_API_CASE(compressedteximage_2d_invalid_target, "Invalid glCompressedTexImage2D() usage",
143		{
144			vector<deInt32> compressedFormats;
145			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
146			if (!compressedFormats.empty())
147			{
148				m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
149				glCompressedTexImage2D(0, 0, compressedFormats[0], 0, 0, 0, 0, 0);
150				expectError(GL_INVALID_ENUM);
151				m_log << TestLog::EndSection;
152			}
153		});
154	ES2F_ADD_API_CASE(compressedteximage_2d_invalid_format_tex2d, "Invalid glCompressedTexImage2D() usage",
155		{
156			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not a supported format returned in GL_COMPRESSED_TEXTURE_FORMATS.");
157			glCompressedTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
158			expectError(GL_INVALID_ENUM);
159			m_log << TestLog::EndSection;
160		});
161	ES2F_ADD_API_CASE(compressedteximage_2d_invalid_format_cube, "Invalid glCompressedTexImage2D() usage",
162		{
163			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not a supported format returned in GL_COMPRESSED_TEXTURE_FORMATS.");
164			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
165			expectError(GL_INVALID_ENUM);
166			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
167			expectError(GL_INVALID_ENUM);
168			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
169			expectError(GL_INVALID_ENUM);
170			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
171			expectError(GL_INVALID_ENUM);
172			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
173			expectError(GL_INVALID_ENUM);
174			glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
175			expectError(GL_INVALID_ENUM);
176			m_log << TestLog::EndSection;
177		});
178	ES2F_ADD_API_CASE(compressedteximage2d_neg_level_tex2d, "Invalid glCompressedTexImage2D() usage",
179		{
180			vector<deInt32> compressedFormats;
181			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
182			if (!compressedFormats.empty())
183			{
184				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
185				glCompressedTexImage2D(GL_TEXTURE_2D, -1, compressedFormats[0], 0, 0, 0, 0, 0);
186				expectError(GL_INVALID_VALUE);
187				m_log << TestLog::EndSection;
188			}
189		});
190	ES2F_ADD_API_CASE(compressedteximage2d_neg_level_cube, "Invalid glCompressedTexImage2D() usage",
191		{
192			vector<deInt32> compressedFormats;
193			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
194			if (!compressedFormats.empty())
195			{
196				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
197				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, compressedFormats[0], 0, 0, 0, 0, 0);
198				expectError(GL_INVALID_VALUE);
199				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, compressedFormats[0], 0, 0, 0, 0, 0);
200				expectError(GL_INVALID_VALUE);
201				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, compressedFormats[0], 0, 0, 0, 0, 0);
202				expectError(GL_INVALID_VALUE);
203				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, compressedFormats[0], 0, 0, 0, 0, 0);
204				expectError(GL_INVALID_VALUE);
205				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, compressedFormats[0], 0, 0, 0, 0, 0);
206				expectError(GL_INVALID_VALUE);
207				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, compressedFormats[0], 0, 0, 0, 0, 0);
208				expectError(GL_INVALID_VALUE);
209				m_log << TestLog::EndSection;
210			}
211		});
212	ES2F_ADD_API_CASE(compressedteximage2d_level_max_tex2d, "Invalid glCompressedTexImage2D() usage",
213		{
214			vector<deInt32> compressedFormats;
215			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
216			if (!compressedFormats.empty())
217			{
218				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
219				deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
220				glCompressedTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
221				expectError(GL_INVALID_VALUE);
222				m_log << TestLog::EndSection;
223			}
224		});
225	ES2F_ADD_API_CASE(compressedteximage2d_level_max_cube_pos, "Invalid glCompressedTexImage2D() usage",
226		{
227			vector<deInt32> compressedFormats;
228			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
229			if (!compressedFormats.empty())
230			{
231				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
232				deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
233				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
234				expectError(GL_INVALID_VALUE);
235				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
236				expectError(GL_INVALID_VALUE);
237				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
238				expectError(GL_INVALID_VALUE);
239				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
240				expectError(GL_INVALID_VALUE);
241				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
242				expectError(GL_INVALID_VALUE);
243				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxTextureSize, compressedFormats[0], 0, 0, 0, 0, 0);
244				expectError(GL_INVALID_VALUE);
245				m_log << TestLog::EndSection;
246			}
247		});
248	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_tex2d, "Invalid glCompressedTexImage2D() usage",
249		{
250			vector<deInt32> compressedFormats;
251			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
252			if (!compressedFormats.empty())
253			{
254				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
255				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], -1, 0, 0, 0, 0);
256				expectError(GL_INVALID_VALUE);
257				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], 0, -1, 0, 0, 0);
258				expectError(GL_INVALID_VALUE);
259				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], -1, -1, 0, 0, 0);
260				expectError(GL_INVALID_VALUE);
261				m_log << TestLog::EndSection;
262			}
263		});
264	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_cube_pos_x, "Invalid glCompressedTexImage2D() usage",
265		{
266			vector<deInt32> compressedFormats;
267			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
268			if (!compressedFormats.empty())
269			{
270				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
271				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], -1, 0, 0, 0, 0);
272				expectError(GL_INVALID_VALUE);
273				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], 0, -1, 0, 0, 0);
274				expectError(GL_INVALID_VALUE);
275				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], -1, -1, 0, 0, 0);
276				expectError(GL_INVALID_VALUE);
277				m_log << TestLog::EndSection;
278			}
279		});
280	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_cube_pos_y, "Invalid glCompressedTexImage2D() usage",
281		{
282			vector<deInt32> compressedFormats;
283			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
284			if (!compressedFormats.empty())
285			{
286				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
287				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], -1, 0, 0, 0, 0);
288				expectError(GL_INVALID_VALUE);
289				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], 0, -1, 0, 0, 0);
290				expectError(GL_INVALID_VALUE);
291				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], -1, -1, 0, 0, 0);
292				expectError(GL_INVALID_VALUE);
293				m_log << TestLog::EndSection;
294			}
295		});
296	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_cube_pos_z, "Invalid glCompressedTexImage2D() usage",
297		{
298			vector<deInt32> compressedFormats;
299			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
300			if (!compressedFormats.empty())
301			{
302				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
303				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], -1, 0, 0, 0, 0);
304				expectError(GL_INVALID_VALUE);
305				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], 0, -1, 0, 0, 0);
306				expectError(GL_INVALID_VALUE);
307				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], -1, -1, 0, 0, 0);
308				expectError(GL_INVALID_VALUE);
309				m_log << TestLog::EndSection;
310			}
311		});
312	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_cube_neg_x, "Invalid glCompressedTexImage2D() usage",
313		{
314			vector<deInt32> compressedFormats;
315			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
316			if (!compressedFormats.empty())
317			{
318				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
319				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], -1, 0, 0, 0, 0);
320				expectError(GL_INVALID_VALUE);
321				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], 0, -1, 0, 0, 0);
322				expectError(GL_INVALID_VALUE);
323				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], -1, -1, 0, 0, 0);
324				expectError(GL_INVALID_VALUE);
325				m_log << TestLog::EndSection;
326			}
327		});
328	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_cube_neg_y, "Invalid glCompressedTexImage2D() usage",
329		{
330			vector<deInt32> compressedFormats;
331			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
332			if (!compressedFormats.empty())
333			{
334				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
335				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], -1, 0, 0, 0, 0);
336				expectError(GL_INVALID_VALUE);
337				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], 0, -1, 0, 0, 0);
338				expectError(GL_INVALID_VALUE);
339				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], -1, -1, 0, 0, 0);
340				expectError(GL_INVALID_VALUE);
341				m_log << TestLog::EndSection;
342			}
343		});
344	ES2F_ADD_API_CASE(compressedteximage2d_neg_width_height_cube_neg_z, "Invalid glCompressedTexImage2D() usage",
345		{
346			vector<deInt32> compressedFormats;
347			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
348			if (!compressedFormats.empty())
349			{
350				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
351				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], -1, 0, 0, 0, 0);
352				expectError(GL_INVALID_VALUE);
353				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], 0, -1, 0, 0, 0);
354				expectError(GL_INVALID_VALUE);
355				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], -1, -1, 0, 0, 0);
356				expectError(GL_INVALID_VALUE);
357				m_log << TestLog::EndSection;
358			}
359		});
360	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_tex2d, "Invalid glCompressedTexImage2D() usage",
361		{
362			vector<deInt32> compressedFormats;
363			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
364			if (!compressedFormats.empty())
365			{
366				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
367				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
368				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
369				expectError(GL_INVALID_VALUE);
370				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
371				expectError(GL_INVALID_VALUE);
372				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
373				expectError(GL_INVALID_VALUE);
374				m_log << TestLog::EndSection;
375			}
376		});
377	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_cube_pos_x, "Invalid glCompressedTexImage2D() usage",
378		{
379			vector<deInt32> compressedFormats;
380			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
381			if (!compressedFormats.empty())
382			{
383				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
384				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
385				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
386				expectError(GL_INVALID_VALUE);
387				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
388				expectError(GL_INVALID_VALUE);
389				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
390				expectError(GL_INVALID_VALUE);
391				m_log << TestLog::EndSection;
392			}
393		});
394	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_cube_pos_y, "Invalid glCompressedTexImage2D() usage",
395		{
396			vector<deInt32> compressedFormats;
397			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
398			if (!compressedFormats.empty())
399			{
400				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
401				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
402				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
403				expectError(GL_INVALID_VALUE);
404				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
405				expectError(GL_INVALID_VALUE);
406				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
407				expectError(GL_INVALID_VALUE);
408				m_log << TestLog::EndSection;
409			}
410		});
411	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_cube_pos_z, "Invalid glCompressedTexImage2D() usage",
412		{
413			vector<deInt32> compressedFormats;
414			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
415			if (!compressedFormats.empty())
416			{
417				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
418				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
419				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
420				expectError(GL_INVALID_VALUE);
421				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
422				expectError(GL_INVALID_VALUE);
423				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
424				expectError(GL_INVALID_VALUE);
425				m_log << TestLog::EndSection;
426			}
427		});
428	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_cube_neg_x, "Invalid glCompressedTexImage2D() usage",
429		{
430			vector<deInt32> compressedFormats;
431			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
432			if (!compressedFormats.empty())
433			{
434				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
435				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
436				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
437				expectError(GL_INVALID_VALUE);
438				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
439				expectError(GL_INVALID_VALUE);
440				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
441				expectError(GL_INVALID_VALUE);
442				m_log << TestLog::EndSection;
443			}
444		});
445	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_cube_neg_y, "Invalid glCompressedTexImage2D() usage",
446		{
447			vector<deInt32> compressedFormats;
448			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
449			if (!compressedFormats.empty())
450			{
451				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
452				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
453				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
454				expectError(GL_INVALID_VALUE);
455				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
456				expectError(GL_INVALID_VALUE);
457				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
458				expectError(GL_INVALID_VALUE);
459				m_log << TestLog::EndSection;
460			}
461		});
462	ES2F_ADD_API_CASE(compressedteximage2d_width_height_max_cube_neg_z, "Invalid glCompressedTexImage2D() usage",
463		{
464			vector<deInt32> compressedFormats;
465			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
466			if (!compressedFormats.empty())
467			{
468				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
469				int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
470				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], maxTextureSize, 0, 0, 0, 0);
471				expectError(GL_INVALID_VALUE);
472				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], 0, maxTextureSize, 0, 0, 0);
473				expectError(GL_INVALID_VALUE);
474				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], maxTextureSize, maxTextureSize, 0, 0, 0);
475				expectError(GL_INVALID_VALUE);
476				m_log << TestLog::EndSection;
477			}
478		});
479	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border, "Invalid glCompressedTexImage2D() usage",
480		{
481			vector<deInt32> compressedFormats;
482			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
483			if (!compressedFormats.empty())
484			{
485				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
486				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], 0, 0, 1, 0, 0);
487				expectError(GL_INVALID_VALUE);
488				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], 0, 0, -1, 0, 0);
489				expectError(GL_INVALID_VALUE);
490				m_log << TestLog::EndSection;
491			}
492		});
493
494	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border_cube_pos_x, "Invalid glCompressedTexImage2D() usage",
495		{
496			vector<deInt32> compressedFormats;
497			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
498			if (!compressedFormats.empty())
499			{
500				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
501				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], 0, 0, 1, 0, 0);
502				expectError(GL_INVALID_VALUE);
503				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, compressedFormats[0], 0, 0, -1, 0, 0);
504				expectError(GL_INVALID_VALUE);
505				m_log << TestLog::EndSection;
506			}
507		});
508	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border_cube_pos_y, "Invalid glCompressedTexImage2D() usage",
509		{
510			vector<deInt32> compressedFormats;
511			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
512			if (!compressedFormats.empty())
513			{
514				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
515				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], 0, 0, 1, 0, 0);
516				expectError(GL_INVALID_VALUE);
517				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, compressedFormats[0], 0, 0, -1, 0, 0);
518				expectError(GL_INVALID_VALUE);
519				m_log << TestLog::EndSection;
520			}
521		});
522	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border_cube_pos_z, "Invalid glCompressedTexImage2D() usage",
523		{
524			vector<deInt32> compressedFormats;
525			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
526			if (!compressedFormats.empty())
527			{
528				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
529				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], 0, 0, 1, 0, 0);
530				expectError(GL_INVALID_VALUE);
531				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, compressedFormats[0], 0, 0, -1, 0, 0);
532				expectError(GL_INVALID_VALUE);
533				m_log << TestLog::EndSection;
534			}
535		});
536	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border_cube_neg_x, "Invalid glCompressedTexImage2D() usage",
537		{
538			vector<deInt32> compressedFormats;
539			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
540			if (!compressedFormats.empty())
541			{
542				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
543				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], 0, 0, 1, 0, 0);
544				expectError(GL_INVALID_VALUE);
545				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, compressedFormats[0], 0, 0, -1, 0, 0);
546				expectError(GL_INVALID_VALUE);
547				m_log << TestLog::EndSection;
548			}
549		});
550	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border_cube_neg_y, "Invalid glCompressedTexImage2D() usage",
551		{
552			vector<deInt32> compressedFormats;
553			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
554			if (!compressedFormats.empty())
555			{
556				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
557				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], 0, 0, 1, 0, 0);
558				expectError(GL_INVALID_VALUE);
559				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, compressedFormats[0], 0, 0, -1, 0, 0);
560				expectError(GL_INVALID_VALUE);
561				m_log << TestLog::EndSection;
562			}
563		});
564	ES2F_ADD_API_CASE(compressedteximage2d_invalid_border_cube_neg_z, "Invalid glCompressedTexImage2D() usage",
565		{
566			vector<deInt32> compressedFormats;
567			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
568			if (!compressedFormats.empty())
569			{
570				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
571				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], 0, 0, 1, 0, 0);
572				expectError(GL_INVALID_VALUE);
573				glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, compressedFormats[0], 0, 0, -1, 0, 0);
574				expectError(GL_INVALID_VALUE);
575				m_log << TestLog::EndSection;
576			}
577		});
578	ES2F_ADD_API_CASE(compressedteximage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
579		{
580			vector<deInt32> compressedFormats;
581			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
582			if (!compressedFormats.empty())
583			{
584				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.");
585				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], 0, 0, 0, -1, 0);
586				expectError(GL_INVALID_VALUE);
587				m_log << TestLog::EndSection;
588			}
589		});
590
591	// glCopyTexImage2D
592
593	ES2F_ADD_API_CASE(copyteximage2d_invalid_target, "Invalid glCopyTexImage2D() usage",
594		{
595			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
596			glCopyTexImage2D(0, 0, GL_RGB, 0, 0, 64, 64, 0);
597			expectError(GL_INVALID_ENUM);
598			m_log << TestLog::EndSection;
599		});
600	ES2F_ADD_API_CASE(copyteximage2d_invalid_format_tex2d, "Invalid glCopyTexImage2D() usage",
601		{
602			m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
603			glCopyTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0);
604			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
605			m_log << TestLog::EndSection;
606		});
607	ES2F_ADD_API_CASE(copyteximage2d_invalid_format_cube, "Invalid glCopyTexImage2D() usage",
608		{
609			m_log << TestLog::Section("", "GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
610			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0);
611			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
612			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0);
613			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
614			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0);
615			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
616			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0);
617			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
618			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0);
619			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
620			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0);
621			expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
622			m_log << TestLog::EndSection;
623		});
624	ES2F_ADD_API_CASE(copyteximage2d_inequal_width_height_cube, "Invalid glCopyTexImage2D() usage",
625		{
626			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.");
627			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
628			expectError(GL_INVALID_VALUE);
629			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
630			expectError(GL_INVALID_VALUE);
631			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
632			expectError(GL_INVALID_VALUE);
633			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
634			expectError(GL_INVALID_VALUE);
635			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
636			expectError(GL_INVALID_VALUE);
637			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
638			expectError(GL_INVALID_VALUE);
639			m_log << TestLog::EndSection;
640		});
641	ES2F_ADD_API_CASE(copyteximage2d_neg_level_tex2d, "Invalid glCopyTexImage2D() usage",
642		{
643			m_log << TestLog::Section("", "");
644			glCopyTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 0, 0, 64, 64, 0);
645			expectError(GL_INVALID_VALUE);
646			m_log << TestLog::EndSection;
647		});
648	ES2F_ADD_API_CASE(copyteximage2d_neg_level_cube, "Invalid glCopyTexImage2D() usage",
649		{
650			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
651			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
652			expectError(GL_INVALID_VALUE);
653			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
654			expectError(GL_INVALID_VALUE);
655			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
656			expectError(GL_INVALID_VALUE);
657			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
658			expectError(GL_INVALID_VALUE);
659			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
660			expectError(GL_INVALID_VALUE);
661			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
662			expectError(GL_INVALID_VALUE);
663			m_log << TestLog::EndSection;
664		});
665	ES2F_ADD_API_CASE(copyteximage2d_level_max_tex2d, "Invalid glCopyTexImage2D() usage",
666		{
667			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
668			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
669			glCopyTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 0, 0, 64, 64, 0);
670			expectError(GL_INVALID_VALUE);
671			m_log << TestLog::EndSection;
672		});
673	ES2F_ADD_API_CASE(copyteximage2d_level_max_cube, "Invalid glCopyTexImage2D() usage",
674		{
675			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
676			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
677			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxTextureSize, GL_RGB, 0, 0, 16, 16, 0);
678			expectError(GL_INVALID_VALUE);
679			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxTextureSize, GL_RGB, 0, 0, 16, 16, 0);
680			expectError(GL_INVALID_VALUE);
681			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxTextureSize, GL_RGB, 0, 0, 16, 16, 0);
682			expectError(GL_INVALID_VALUE);
683			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxTextureSize, GL_RGB, 0, 0, 16, 16, 0);
684			expectError(GL_INVALID_VALUE);
685			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxTextureSize, GL_RGB, 0, 0, 16, 16, 0);
686			expectError(GL_INVALID_VALUE);
687			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxTextureSize, GL_RGB, 0, 0, 16, 16, 0);
688			expectError(GL_INVALID_VALUE);
689			m_log << TestLog::EndSection;
690		});
691	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_tex2d, "Invalid glCopyTexImage2D() usage",
692		{
693			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
694			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, 1, 0);
695			expectError(GL_INVALID_VALUE);
696			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, -1, 0);
697			expectError(GL_INVALID_VALUE);
698			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, -1, 0);
699			expectError(GL_INVALID_VALUE);
700			m_log << TestLog::EndSection;
701		});
702	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_cube_pos_x, "Invalid glCopyTexImage2D() usage",
703		{
704			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
705			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
706			expectError(GL_INVALID_VALUE);
707			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
708			expectError(GL_INVALID_VALUE);
709			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
710			expectError(GL_INVALID_VALUE);
711			m_log << TestLog::EndSection;
712		});
713	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_cube_pos_y, "Invalid glCopyTexImage2D() usage",
714		{
715			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
716			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
717			expectError(GL_INVALID_VALUE);
718			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
719			expectError(GL_INVALID_VALUE);
720			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
721			expectError(GL_INVALID_VALUE);
722			m_log << TestLog::EndSection;
723		});
724	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_cube_pos_z, "Invalid glCopyTexImage2D() usage",
725		{
726			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
727			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
728			expectError(GL_INVALID_VALUE);
729			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
730			expectError(GL_INVALID_VALUE);
731			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
732			expectError(GL_INVALID_VALUE);
733			m_log << TestLog::EndSection;
734		});
735	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_cube_neg_x, "Invalid glCopyTexImage2D() usage",
736		{
737			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
738			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
739			expectError(GL_INVALID_VALUE);
740			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
741			expectError(GL_INVALID_VALUE);
742			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
743			expectError(GL_INVALID_VALUE);
744			m_log << TestLog::EndSection;
745		});
746	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_cube_neg_y, "Invalid glCopyTexImage2D() usage",
747		{
748			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
749			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
750			expectError(GL_INVALID_VALUE);
751			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
752			expectError(GL_INVALID_VALUE);
753			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
754			expectError(GL_INVALID_VALUE);
755			m_log << TestLog::EndSection;
756		});
757	ES2F_ADD_API_CASE(copyteximage2d_invalid_width_height_cube_neg_z, "Invalid glCopyTexImage2D() usage",
758		{
759			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
760			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
761			expectError(GL_INVALID_VALUE);
762			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
763			expectError(GL_INVALID_VALUE);
764			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
765			expectError(GL_INVALID_VALUE);
766			m_log << TestLog::EndSection;
767		});
768	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_tex2d, "Invalid glCopyTexImage2D() usage",
769		{
770			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
771			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
772			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
773			expectError(GL_INVALID_VALUE);
774			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
775			expectError(GL_INVALID_VALUE);
776			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
777			expectError(GL_INVALID_VALUE);
778			m_log << TestLog::EndSection;
779		});
780	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_cube_pos_x, "Invalid glCopyTexImage2D() usage",
781		{
782			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
783			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
784			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
785			expectError(GL_INVALID_VALUE);
786			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
787			expectError(GL_INVALID_VALUE);
788			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
789			expectError(GL_INVALID_VALUE);
790			m_log << TestLog::EndSection;
791		});
792	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_cube_pos_y, "Invalid glCopyTexImage2D() usage",
793		{
794			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
795			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
796			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
797			expectError(GL_INVALID_VALUE);
798			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
799			expectError(GL_INVALID_VALUE);
800			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
801			expectError(GL_INVALID_VALUE);
802			m_log << TestLog::EndSection;
803		});
804	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_cube_pos_z, "Invalid glCopyTexImage2D() usage",
805		{
806			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
807			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
808			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
809			expectError(GL_INVALID_VALUE);
810			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
811			expectError(GL_INVALID_VALUE);
812			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
813			expectError(GL_INVALID_VALUE);
814			m_log << TestLog::EndSection;
815		});
816	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_cube_neg_x, "Invalid glCopyTexImage2D() usage",
817		{
818			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
819			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
820			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
821			expectError(GL_INVALID_VALUE);
822			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
823			expectError(GL_INVALID_VALUE);
824			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
825			expectError(GL_INVALID_VALUE);
826			m_log << TestLog::EndSection;
827		});
828	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_cube_neg_y, "Invalid glCopyTexImage2D() usage",
829		{
830			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
831			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
832			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
833			expectError(GL_INVALID_VALUE);
834			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
835			expectError(GL_INVALID_VALUE);
836			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
837			expectError(GL_INVALID_VALUE);
838			m_log << TestLog::EndSection;
839		});
840	ES2F_ADD_API_CASE(copyteximage2d_width_height_max_cube_neg_z, "Invalid glCopyTexImage2D() usage",
841		{
842			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
843			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
844			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
845			expectError(GL_INVALID_VALUE);
846			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
847			expectError(GL_INVALID_VALUE);
848			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
849			expectError(GL_INVALID_VALUE);
850			m_log << TestLog::EndSection;
851		});
852	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_tex2d, "Invalid glCopyTexImage2D() usage",
853		{
854			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
855			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 64, 64, -1);
856			expectError(GL_INVALID_VALUE);
857			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 64, 64, 1);
858			expectError(GL_INVALID_VALUE);
859			m_log << TestLog::EndSection;
860		});
861	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_cube_pos_x, "Invalid glCopyTexImage2D() usage",
862		{
863			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
864			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 16, -1);
865			expectError(GL_INVALID_VALUE);
866			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 16, 1);
867			expectError(GL_INVALID_VALUE);
868			m_log << TestLog::EndSection;
869		});
870	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_cube_pos_y, "Invalid glCopyTexImage2D() usage",
871		{
872			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
873			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 16, -1);
874			expectError(GL_INVALID_VALUE);
875			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 16, 1);
876			expectError(GL_INVALID_VALUE);
877			m_log << TestLog::EndSection;
878		});
879	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_cube_pos_z, "Invalid glCopyTexImage2D() usage",
880		{
881			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
882			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 16, -1);
883			expectError(GL_INVALID_VALUE);
884			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 16, 1);
885			expectError(GL_INVALID_VALUE);
886			m_log << TestLog::EndSection;
887		});
888	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_cube_neg_x, "Invalid glCopyTexImage2D() usage",
889		{
890			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
891			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 16, -1);
892			expectError(GL_INVALID_VALUE);
893			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 16, 1);
894			expectError(GL_INVALID_VALUE);
895			m_log << TestLog::EndSection;
896		});
897	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_cube_neg_y, "Invalid glCopyTexImage2D() usage",
898		{
899			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
900			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 16, -1);
901			expectError(GL_INVALID_VALUE);
902			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 16, 1);
903			expectError(GL_INVALID_VALUE);
904			m_log << TestLog::EndSection;
905		});
906	ES2F_ADD_API_CASE(copyteximage2d_invalid_border_cube_neg_z, "Invalid glCopyTexImage2D() usage",
907		{
908			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
909			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 16, -1);
910			expectError(GL_INVALID_VALUE);
911			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 16, 1);
912			expectError(GL_INVALID_VALUE);
913			m_log << TestLog::EndSection;
914		});
915
916	ES2F_ADD_API_CASE(copyteximage2d_incomplete_framebuffer, "Invalid glCopyTexImage2D() usage",
917		{
918			m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
919			GLuint fbo;
920			glGenFramebuffers(1, &fbo);
921			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
922			glCheckFramebufferStatus(GL_FRAMEBUFFER);
923
924			glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 64, 64, 0);
925			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
926			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 16, 0);
927			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
928			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 16, 0);
929			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
930			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 16, 0);
931			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
932			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 16, 0);
933			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
934			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 16, 0);
935			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
936			glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 16, 0);
937			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
938
939			glBindFramebuffer(GL_FRAMEBUFFER, 0);
940			glDeleteFramebuffers(1, &fbo);
941			m_log << tcu::TestLog::EndSection;
942		});
943
944	// glCopyTexSubImage2D
945
946	ES2F_ADD_API_CASE(copytexsubimage2d_invalid_target, "Invalid glCopyTexSubImage2D() usage",
947		{
948			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
949			glCopyTexSubImage2D(0, 0, 0, 0, 0, 0, 0, 0);
950			expectError(GL_INVALID_ENUM);
951			m_log << TestLog::EndSection;
952		});
953	ES2F_ADD_API_CASE(copytexsubimage2d_neg_level_tex2d, "Invalid glCopyTexSubImage2D() usage",
954		{
955			GLuint texture;
956			glGenTextures(1, &texture);
957			glBindTexture(GL_TEXTURE_2D, texture);
958			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
959
960			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
961			glCopyTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 0);
962			expectError(GL_INVALID_VALUE);
963			m_log << TestLog::EndSection;
964
965			glDeleteTextures(1, &texture);
966		});
967	ES2F_ADD_API_CASE(copytexsubimage2d_neg_level_cube, "Invalid glCopyTexSubImage2D() usage",
968		{
969			GLuint texture;
970			glGenTextures(1, &texture);
971			glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
972			FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL););
973
974			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
975			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, 0, 0, 0, 0, 0, 0);
976			expectError(GL_INVALID_VALUE);
977			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, 0, 0, 0, 0, 0, 0);
978			expectError(GL_INVALID_VALUE);
979			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, 0, 0, 0, 0, 0, 0);
980			expectError(GL_INVALID_VALUE);
981			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, 0, 0, 0, 0, 0, 0);
982			expectError(GL_INVALID_VALUE);
983			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, 0, 0, 0, 0, 0, 0);
984			expectError(GL_INVALID_VALUE);
985			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, 0, 0, 0, 0, 0, 0);
986			expectError(GL_INVALID_VALUE);
987			m_log << TestLog::EndSection;
988
989			glDeleteTextures(1, &texture);
990		});
991	ES2F_ADD_API_CASE(copytexsubimage2d_level_max_tex2d, "Invalid glCopyTexSubImage2D() usage",
992		{
993			GLuint texture;
994			glGenTextures(1, &texture);
995			glBindTexture(GL_TEXTURE_2D, texture);
996			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
997
998			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
999			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1000			glCopyTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1001			expectError(GL_INVALID_VALUE);
1002			m_log << TestLog::EndSection;
1003
1004			glDeleteTextures(1, &texture);
1005		});
1006	ES2F_ADD_API_CASE(copytexsubimage2d_level_max_cube_pos, "Invalid glCopyTexSubImage2D() usage",
1007		{
1008			GLuint texture;
1009			glGenTextures(1, &texture);
1010			glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
1011			FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL););
1012
1013			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_SIZE).");
1014			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1015			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1016			expectError(GL_INVALID_VALUE);
1017			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1018			expectError(GL_INVALID_VALUE);
1019			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1020			expectError(GL_INVALID_VALUE);
1021			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1022			expectError(GL_INVALID_VALUE);
1023			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1024			expectError(GL_INVALID_VALUE);
1025			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxTextureSize, 0, 0, 0, 0, 0, 0);
1026			expectError(GL_INVALID_VALUE);
1027			m_log << TestLog::EndSection;
1028
1029			glDeleteTextures(1, &texture);
1030		});
1031	ES2F_ADD_API_CASE(copytexsubimage2d_neg_offset, "Invalid glCopyTexSubImage2D() usage",
1032		{
1033			GLuint texture;
1034			glGenTextures(1, &texture);
1035			glBindTexture(GL_TEXTURE_2D, texture);
1036			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1037
1038			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.");
1039			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, 0, 0);
1040			expectError(GL_INVALID_VALUE);
1041			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, 0, 0);
1042			expectError(GL_INVALID_VALUE);
1043			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, 0, 0);
1044			expectError(GL_INVALID_VALUE);
1045			m_log << TestLog::EndSection;
1046
1047			glDeleteTextures(1, &texture);
1048		});
1049	ES2F_ADD_API_CASE(copytexsubimage2d_offset_allowed, "Invalid glCopyTexSubImage2D() usage",
1050		{
1051			GLuint texture;
1052			glGenTextures(1, &texture);
1053			glBindTexture(GL_TEXTURE_2D, texture);
1054			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1055
1056			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1057			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 8, 4, 0, 0, 10, 10);
1058			expectError(GL_INVALID_VALUE);
1059			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 4, 8, 0, 0, 10, 10);
1060			expectError(GL_INVALID_VALUE);
1061			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 8, 8, 0, 0, 10, 10);
1062			expectError(GL_INVALID_VALUE);
1063			m_log << TestLog::EndSection;
1064
1065			glDeleteTextures(1, &texture);
1066		});
1067	ES2F_ADD_API_CASE(copytexsubimage2d_neg_wdt_hgt, "Invalid glCopyTexSubImage2D() usage",
1068		{
1069			GLuint texture;
1070			glGenTextures(1, &texture);
1071			glBindTexture(GL_TEXTURE_2D, texture);
1072			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1073
1074			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1075			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0);
1076			expectError(GL_INVALID_VALUE);
1077			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1);
1078			expectError(GL_INVALID_VALUE);
1079			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1);
1080			expectError(GL_INVALID_VALUE);
1081			m_log << TestLog::EndSection;
1082
1083			glDeleteTextures(1, &texture);
1084		});
1085	ES2F_ADD_API_CASE(copytexsubimage2d_incomplete_framebuffer, "Invalid glCopyTexSubImage2D() usage",
1086		{
1087			GLuint texture;
1088			glGenTextures(1, &texture);
1089			glBindTexture(GL_TEXTURE_2D, texture);
1090			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1091
1092			m_log << tcu::TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1093			GLuint fbo;
1094			glGenFramebuffers(1, &fbo);
1095			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1096			glCheckFramebufferStatus(GL_FRAMEBUFFER);
1097
1098			glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
1099			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1100			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
1101			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1102			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
1103			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1104			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1105			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1106			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
1107			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1108			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
1109			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1110			glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1111			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1112
1113			glBindFramebuffer(GL_FRAMEBUFFER, 0);
1114			glDeleteFramebuffers(1, &fbo);
1115			m_log << tcu::TestLog::EndSection;
1116
1117			glDeleteTextures(1, &texture);
1118		});
1119
1120	// glDeleteTextures
1121
1122	ES2F_ADD_API_CASE(deletetextures_invalid_number, "Invalid glDeleteTextures() usage",
1123		{
1124			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1125			glDeleteTextures(-1,0);
1126			expectError(GL_INVALID_VALUE);
1127			m_log << TestLog::EndSection;
1128		});
1129	ES2F_ADD_API_CASE(deletetextures_invalid_number_bind, "Invalid glDeleteTextures() usage",
1130		{
1131			GLuint texture;
1132			glGenTextures(1, &texture);
1133
1134			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1135			glBindTexture(GL_TEXTURE_2D, texture);
1136			glDeleteTextures(-1,0);
1137			expectError(GL_INVALID_VALUE);
1138			m_log << TestLog::EndSection;
1139
1140			glDeleteTextures(1, &texture);
1141		});
1142
1143	// glGenerateMipmap
1144
1145	ES2F_ADD_API_CASE(generatemipmap_invalid_target, "Invalid glGenerateMipmap() usage",
1146		{
1147			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.");
1148			glGenerateMipmap(0);
1149			expectError(GL_INVALID_ENUM);
1150			m_log << TestLog::EndSection;
1151		});
1152	ES2F_ADD_API_CASE(generatemipmap_invalid_target_bind, "Invalid glGenerateMipmap() usage",
1153		{
1154			GLuint texture;
1155			glGenTextures(1, &texture);
1156
1157			m_log << TestLog::Section("", "INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
1158			glBindTexture(GL_TEXTURE_2D, texture);
1159			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1160			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1161			glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1162			expectError(GL_INVALID_OPERATION);
1163			m_log << TestLog::EndSection;
1164
1165			glDeleteTextures(1, &texture);
1166		});
1167	ES2F_ADD_API_CASE(generatemipmap_npot_wdt_hgt, "Invalid glGenerateMipmap() usage",
1168		{
1169			GLuint texture;
1170			glActiveTexture(GL_TEXTURE0);
1171			glGenTextures(1, &texture);
1172			glBindTexture(GL_TEXTURE_2D, texture);
1173
1174			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if either the width or height of the zero level array is not a power of two.");
1175			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 257, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1176			glGenerateMipmap(GL_TEXTURE_2D);
1177			expectError(GL_INVALID_OPERATION);
1178			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 257, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1179			glGenerateMipmap(GL_TEXTURE_2D);
1180			expectError(GL_INVALID_OPERATION);
1181			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 257, 257, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1182			glGenerateMipmap(GL_TEXTURE_2D);
1183			expectError(GL_INVALID_OPERATION);
1184			m_log << TestLog::EndSection;
1185
1186			glDeleteTextures(1, &texture);
1187		});
1188	ES2F_ADD_API_CASE(generatemipmap_zero_level_array_compressed, "Invalid glGenerateMipmap() usage",
1189		{
1190			vector<deInt32> compressedFormats;
1191			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
1192			if (!compressedFormats.empty())
1193			{
1194				m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
1195				glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormats[0], 0, 0, 0, 0, 0);
1196				glGenerateMipmap(GL_TEXTURE_2D);
1197				expectError(GL_INVALID_OPERATION);
1198				m_log << TestLog::EndSection;
1199			}
1200		});
1201	ES2F_ADD_API_CASE(generatemipmap_incomplete_cube, "Invalid glGenerateMipmap() usage",
1202		{
1203			GLuint texture;
1204			glGenTextures(1, &texture);
1205			glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
1206
1207			m_log << TestLog::Section("", "INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
1208			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1209			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1210			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1211			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1212			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1213			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1214			glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1215			expectError(GL_INVALID_OPERATION);
1216			m_log << TestLog::EndSection;
1217
1218			glDeleteTextures(1, &texture);
1219		});
1220
1221	// glGenTextures
1222
1223	ES2F_ADD_API_CASE(gentextures_invalid_size, "Invalid glGenTextures() usage",
1224		{
1225			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1226			glGenTextures(-1, 0);
1227			expectError(GL_INVALID_VALUE);
1228			m_log << TestLog::EndSection;
1229		});
1230
1231	// glPixelStorei
1232
1233	ES2F_ADD_API_CASE(pixelstorei_invalid_pname, "Invalid glPixelStorei() usage",
1234		{
1235			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1236			glPixelStorei(0,1);
1237			expectError(GL_INVALID_ENUM);
1238			m_log << TestLog::EndSection;
1239		});
1240	ES2F_ADD_API_CASE(pixelstorei_invalid_param, "Invalid glPixelStorei() usage",
1241		{
1242			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if alignment is specified as other than 1, 2, 4, or 8.");
1243			glPixelStorei(GL_PACK_ALIGNMENT, 0);
1244			expectError(GL_INVALID_VALUE);
1245			glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
1246			expectError(GL_INVALID_VALUE);
1247			glPixelStorei(GL_PACK_ALIGNMENT, 16);
1248			expectError(GL_INVALID_VALUE);
1249			glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
1250			expectError(GL_INVALID_VALUE);
1251			m_log << TestLog::EndSection;
1252		});
1253
1254	// glTexImage2D
1255
1256	ES2F_ADD_API_CASE(teximage2d_invalid_target, "Invalid glTexImage2D() usage",
1257		{
1258			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1259			glTexImage2D(0, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1260			expectError(GL_INVALID_ENUM);
1261			m_log << TestLog::EndSection;
1262		});
1263	ES2F_ADD_API_CASE(teximage2d_invalid_format, "Invalid glTexImage2D() usage",
1264		{
1265			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format or type is not an accepted value.");
1266			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
1267			expectError(GL_INVALID_ENUM);
1268			m_log << TestLog::EndSection;
1269		});
1270	ES2F_ADD_API_CASE(teximage2d_invalid_type, "Invalid glTexImage2D() usage",
1271		{
1272			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format or type is not an accepted value.");
1273			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, 0, 0);
1274			expectError(GL_INVALID_ENUM);
1275			m_log << TestLog::EndSection;
1276		});
1277	ES2F_ADD_API_CASE(teximage2d_inequal_width_height_cube, "Invalid glTexImage2D() usage",
1278		{
1279			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.");
1280			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1281			expectError(GL_INVALID_VALUE);
1282			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1283			expectError(GL_INVALID_VALUE);
1284			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1285			expectError(GL_INVALID_VALUE);
1286			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1287			expectError(GL_INVALID_VALUE);
1288			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1289			expectError(GL_INVALID_VALUE);
1290			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1291			expectError(GL_INVALID_VALUE);
1292			m_log << TestLog::EndSection;
1293		});
1294	ES2F_ADD_API_CASE(teximage2d_neg_level_tex2d, "Invalid glTexImage2D() usage",
1295		{
1296			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1297			glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1298			expectError(GL_INVALID_VALUE);
1299			m_log << TestLog::EndSection;
1300		});
1301	ES2F_ADD_API_CASE(teximage2d_neg_level_cube, "Invalid glTexImage2D() usage",
1302		{
1303			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1304			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1305			expectError(GL_INVALID_VALUE);
1306			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1307			expectError(GL_INVALID_VALUE);
1308			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1309			expectError(GL_INVALID_VALUE);
1310			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1311			expectError(GL_INVALID_VALUE);
1312			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1313			expectError(GL_INVALID_VALUE);
1314			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1315			expectError(GL_INVALID_VALUE);
1316			m_log << TestLog::EndSection;
1317		});
1318	ES2F_ADD_API_CASE(teximage2d_level_max_tex2d, "Invalid glTexImage2D() usage",
1319		{
1320			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1321			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1322			glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1323			expectError(GL_INVALID_VALUE);
1324			m_log << TestLog::EndSection;
1325		});
1326	ES2F_ADD_API_CASE(teximage2d_level_max_cube, "Invalid glTexImage2D() usage",
1327		{
1328			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1329			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1330			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1331			expectError(GL_INVALID_VALUE);
1332			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1333			expectError(GL_INVALID_VALUE);
1334			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1335			expectError(GL_INVALID_VALUE);
1336			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1337			expectError(GL_INVALID_VALUE);
1338			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1339			expectError(GL_INVALID_VALUE);
1340			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1341			expectError(GL_INVALID_VALUE);
1342			m_log << TestLog::EndSection;
1343		});
1344	ES2F_ADD_API_CASE(teximage2d_invalid_internalformat, "Invalid glTexImage2D() usage",
1345		{
1346			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
1347			glTexImage2D(GL_TEXTURE_2D, 0, 0, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1348			expectError(GL_INVALID_VALUE);
1349			m_log << TestLog::EndSection;
1350		});
1351	ES2F_ADD_API_CASE(teximage2d_neg_width_height_tex2d, "Invalid glTexImage2D() usage",
1352		{
1353			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1354			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1355			expectError(GL_INVALID_VALUE);
1356			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1357			expectError(GL_INVALID_VALUE);
1358			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1359			expectError(GL_INVALID_VALUE);
1360			m_log << TestLog::EndSection;
1361		});
1362	ES2F_ADD_API_CASE(teximage2d_neg_width_height_cube_pos_x, "Invalid glTexImage2D() usage",
1363		{
1364			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1365			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1366			expectError(GL_INVALID_VALUE);
1367			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1368			expectError(GL_INVALID_VALUE);
1369			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1370			expectError(GL_INVALID_VALUE);
1371			m_log << TestLog::EndSection;
1372		});
1373	ES2F_ADD_API_CASE(teximage2d_neg_width_height_cube_pos_y, "Invalid glTexImage2D() usage",
1374		{
1375			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1376			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1377			expectError(GL_INVALID_VALUE);
1378			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1379			expectError(GL_INVALID_VALUE);
1380			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1381			expectError(GL_INVALID_VALUE);
1382			m_log << TestLog::EndSection;
1383		});
1384	ES2F_ADD_API_CASE(teximage2d_neg_width_height_cube_pos_z, "Invalid glTexImage2D() usage",
1385		{
1386			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1387			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1388			expectError(GL_INVALID_VALUE);
1389			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1390			expectError(GL_INVALID_VALUE);
1391			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1392			expectError(GL_INVALID_VALUE);
1393			m_log << TestLog::EndSection;
1394		});
1395	ES2F_ADD_API_CASE(teximage2d_neg_width_height_cube_neg_x, "Invalid glTexImage2D() usage",
1396		{
1397			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1398			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1399			expectError(GL_INVALID_VALUE);
1400			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1401			expectError(GL_INVALID_VALUE);
1402			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1403			expectError(GL_INVALID_VALUE);
1404			m_log << TestLog::EndSection;
1405		});
1406	ES2F_ADD_API_CASE(teximage2d_neg_width_height_cube_neg_y, "Invalid glTexImage2D() usage",
1407		{
1408			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1409			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1410			expectError(GL_INVALID_VALUE);
1411			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1412			expectError(GL_INVALID_VALUE);
1413			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1414			expectError(GL_INVALID_VALUE);
1415			m_log << TestLog::EndSection;
1416		});
1417	ES2F_ADD_API_CASE(teximage2d_neg_width_height_cube_neg_z, "Invalid glTexImage2D() usage",
1418		{
1419			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1420			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1421			expectError(GL_INVALID_VALUE);
1422			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1423			expectError(GL_INVALID_VALUE);
1424			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1425			expectError(GL_INVALID_VALUE);
1426			m_log << TestLog::EndSection;
1427		});
1428	ES2F_ADD_API_CASE(teximage2d_width_height_max_tex2d, "Invalid glTexImage2D() usage",
1429		{
1430			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
1431			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE) + 1;
1432			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1433			expectError(GL_INVALID_VALUE);
1434			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1435			expectError(GL_INVALID_VALUE);
1436			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1437			expectError(GL_INVALID_VALUE);
1438			m_log << TestLog::EndSection;
1439		});
1440	ES2F_ADD_API_CASE(teximage2d_width_height_max_cube_pos_x, "Invalid glTexImage2D() usage",
1441		{
1442			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1443			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1444			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1445			expectError(GL_INVALID_VALUE);
1446			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1447			expectError(GL_INVALID_VALUE);
1448			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1449			expectError(GL_INVALID_VALUE);
1450			m_log << TestLog::EndSection;
1451		});
1452	ES2F_ADD_API_CASE(teximage2d_width_height_max_cube_pos_y, "Invalid glTexImage2D() usage",
1453		{
1454			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1455			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1456			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1457			expectError(GL_INVALID_VALUE);
1458			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1459			expectError(GL_INVALID_VALUE);
1460			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1461			expectError(GL_INVALID_VALUE);
1462			m_log << TestLog::EndSection;
1463		});
1464	ES2F_ADD_API_CASE(teximage2d_width_height_max_cube_pos_z, "Invalid glTexImage2D() usage",
1465		{
1466			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1467			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1468			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1469			expectError(GL_INVALID_VALUE);
1470			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1471			expectError(GL_INVALID_VALUE);
1472			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1473			expectError(GL_INVALID_VALUE);
1474			m_log << TestLog::EndSection;
1475		});
1476	ES2F_ADD_API_CASE(teximage2d_width_height_max_cube_neg_x, "Invalid glTexImage2D() usage",
1477		{
1478			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1479			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1480			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1481			expectError(GL_INVALID_VALUE);
1482			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1483			expectError(GL_INVALID_VALUE);
1484			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1485			expectError(GL_INVALID_VALUE);
1486			m_log << TestLog::EndSection;
1487		});
1488	ES2F_ADD_API_CASE(teximage2d_width_height_max_cube_neg_y, "Invalid glTexImage2D() usage",
1489		{
1490			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1491			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1492			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1493			expectError(GL_INVALID_VALUE);
1494			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1495			expectError(GL_INVALID_VALUE);
1496			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1497			expectError(GL_INVALID_VALUE);
1498			m_log << TestLog::EndSection;
1499		});
1500	ES2F_ADD_API_CASE(teximage2d_width_height_max_cube_neg_z, "Invalid glTexImage2D() usage",
1501		{
1502			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1503			int maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1504			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1505			expectError(GL_INVALID_VALUE);
1506			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1507			expectError(GL_INVALID_VALUE);
1508			glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1509			expectError(GL_INVALID_VALUE);
1510			m_log << TestLog::EndSection;
1511		});
1512	ES2F_ADD_API_CASE(teximage2d_invalid_border, "Invalid glTexImage2D() usage",
1513		{
1514			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if border is not 0.");
1515			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1516			expectError(GL_INVALID_VALUE);
1517			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1518			expectError(GL_INVALID_VALUE);
1519			m_log << TestLog::EndSection;
1520		});
1521	ES2F_ADD_API_CASE(teximage2d_format_mismatch, "Invalid glTexImage2D() usage",
1522		{
1523			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if format does not match internalformat.");
1524			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1525			expectError(GL_INVALID_OPERATION);
1526			m_log << TestLog::EndSection;
1527		});
1528	ES2F_ADD_API_CASE(teximage2d_type_format_mismatch, "Invalid glTexImage2D() usage",
1529		{
1530			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_SHORT_4_4_4_4 or GL_UNSIGNED_SHORT_5_5_5_1 and format is not GL_RGBA.");
1531			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1532			expectError(GL_INVALID_OPERATION);
1533			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1534			expectError(GL_INVALID_OPERATION);
1535			m_log << TestLog::EndSection;
1536		});
1537
1538	// glTexSubImage2D
1539
1540	ES2F_ADD_API_CASE(texsubimage2d_invalid_target, "Invalid glTexSubImage2D() usage",
1541		{
1542			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1543			glTexSubImage2D(0, 0, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1544			expectError(GL_INVALID_ENUM);
1545			m_log << TestLog::EndSection;
1546		});
1547	ES2F_ADD_API_CASE(texsubimage2d_invalid_format, "Invalid glTexSubImage2D() usage",
1548		{
1549			GLuint texture;
1550			glGenTextures(1, &texture);
1551			glBindTexture(GL_TEXTURE_2D, texture);
1552			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1553
1554			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format or type is not an accepted value.");
1555			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, GL_UNSIGNED_BYTE, 0);
1556			expectError(GL_INVALID_ENUM);
1557			m_log << TestLog::EndSection;
1558
1559			glDeleteTextures(1, &texture);
1560		});
1561	ES2F_ADD_API_CASE(texsubimage2d_invalid_type, "Invalid glTexSubImage2D() usage",
1562		{
1563			GLuint texture;
1564			glGenTextures(1, &texture);
1565			glBindTexture(GL_TEXTURE_2D, texture);
1566			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1567
1568			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format or type is not an accepted value.");
1569			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGB, 0, 0);
1570			expectError(GL_INVALID_ENUM);
1571			m_log << TestLog::EndSection;
1572
1573			glDeleteTextures(1, &texture);
1574		});
1575	ES2F_ADD_API_CASE(texsubimage2d_neg_level_tex2d, "Invalid glTexSubImage2D() usage",
1576		{
1577			GLuint texture;
1578			glGenTextures(1, &texture);
1579			glBindTexture(GL_TEXTURE_2D, texture);
1580			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1581
1582			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1583			glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1584			expectError(GL_INVALID_VALUE);
1585			m_log << TestLog::EndSection;
1586
1587			glDeleteTextures(1, &texture);
1588		});
1589	ES2F_ADD_API_CASE(texsubimage2d_neg_level_cube, "Invalid glTexSubImage2D() usage",
1590		{
1591			GLuint texture;
1592			glGenTextures(1, &texture);
1593			glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
1594			FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL););
1595
1596			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
1597			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1598			expectError(GL_INVALID_VALUE);
1599			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1600			expectError(GL_INVALID_VALUE);
1601			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1602			expectError(GL_INVALID_VALUE);
1603			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1604			expectError(GL_INVALID_VALUE);
1605			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1606			expectError(GL_INVALID_VALUE);
1607			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1608			expectError(GL_INVALID_VALUE);
1609			m_log << TestLog::EndSection;
1610
1611			glDeleteTextures(1, &texture);
1612		});
1613	ES2F_ADD_API_CASE(texsubimage2d_level_max_tex2d, "Invalid glTexSubImage2D() usage",
1614		{
1615			GLuint texture;
1616			glGenTextures(1, &texture);
1617			glBindTexture(GL_TEXTURE_2D, texture);
1618			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1619
1620			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1621			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
1622			glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1623			expectError(GL_INVALID_VALUE);
1624			m_log << TestLog::EndSection;
1625
1626			glDeleteTextures(1, &texture);
1627		});
1628	ES2F_ADD_API_CASE(texsubimage2d_level_max_cube, "Invalid glTexSubImage2D() usage",
1629		{
1630			GLuint texture;
1631			glGenTextures(1, &texture);
1632			glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
1633			FOR_CUBE_FACES(faceGL, glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL););
1634
1635			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1636			deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1637			glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1638			expectError(GL_INVALID_VALUE);
1639			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1640			expectError(GL_INVALID_VALUE);
1641			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1642			expectError(GL_INVALID_VALUE);
1643			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1644			expectError(GL_INVALID_VALUE);
1645			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1646			expectError(GL_INVALID_VALUE);
1647			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1648			expectError(GL_INVALID_VALUE);
1649			m_log << TestLog::EndSection;
1650
1651			glDeleteTextures(1, &texture);
1652		});
1653	ES2F_ADD_API_CASE(texsubimage2d_neg_offset, "Invalid glTexSubImage2D() usage",
1654		{
1655			GLuint texture;
1656			glGenTextures(1, &texture);
1657			glBindTexture(GL_TEXTURE_2D, texture);
1658			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1659
1660			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
1661			glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1662			expectError(GL_INVALID_VALUE);
1663			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1664			expectError(GL_INVALID_VALUE);
1665			glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1666			expectError(GL_INVALID_VALUE);
1667			m_log << TestLog::EndSection;
1668
1669			glDeleteTextures(1, &texture);
1670		});
1671	ES2F_ADD_API_CASE(texsubimage2d_offset_allowed, "Invalid glTexSubImage2D() usage",
1672		{
1673			GLuint texture;
1674			glGenTextures(1, &texture);
1675			glBindTexture(GL_TEXTURE_2D, texture);
1676			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1677
1678			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1679			glTexSubImage2D(GL_TEXTURE_2D, 0, 8, 4, 10, 10, GL_RGB, GL_UNSIGNED_BYTE, 0);
1680			expectError(GL_INVALID_VALUE);
1681			glTexSubImage2D(GL_TEXTURE_2D, 0, 4, 8, 10, 10, GL_RGB, GL_UNSIGNED_BYTE, 0);
1682			expectError(GL_INVALID_VALUE);
1683			glTexSubImage2D(GL_TEXTURE_2D, 0, 8, 8, 10, 10, GL_RGB, GL_UNSIGNED_BYTE, 0);
1684			expectError(GL_INVALID_VALUE);
1685			m_log << TestLog::EndSection;
1686
1687			glDeleteTextures(1, &texture);
1688		});
1689	ES2F_ADD_API_CASE(texsubimage2d_neg_wdt_hgt, "Invalid glTexSubImage2D() usage",
1690		{
1691			GLuint texture;
1692			glGenTextures(1, &texture);
1693			glBindTexture(GL_TEXTURE_2D, texture);
1694			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1695
1696			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
1697			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1698			expectError(GL_INVALID_VALUE);
1699			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1700			expectError(GL_INVALID_VALUE);
1701			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, -GL_RGB, GL_UNSIGNED_BYTE, 0);
1702			expectError(GL_INVALID_VALUE);
1703			m_log << TestLog::EndSection;
1704
1705			glDeleteTextures(1, &texture);
1706		});
1707	ES2F_ADD_API_CASE(texsubimage2d_type_format_mismatch, "Invalid glTexSubImage2D() usage",
1708		{
1709			GLuint texture;
1710			glGenTextures(1, &texture);
1711			glBindTexture(GL_TEXTURE_2D, texture);
1712			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1713
1714			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_SHORT_5_6_5 and format is not GL_RGB");
1715			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
1716			expectError(GL_INVALID_OPERATION);
1717			m_log << tcu::TestLog::EndSection;
1718
1719			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_SHORT_4_4_4_4 or GL_UNSIGNED_SHORT_5_5_5_1 and format is not GL_RGBA.");
1720			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1721			expectError(GL_INVALID_OPERATION);
1722			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1723			expectError(GL_INVALID_OPERATION);
1724			m_log << tcu::TestLog::EndSection;
1725
1726			glDeleteTextures(1, &texture);
1727		});
1728
1729	// glTexParameteri
1730
1731	ES2F_ADD_API_CASE(texparameteri, "Invalid glTexParameteri() usage",
1732		{
1733			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1734			glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1735			expectError(GL_INVALID_ENUM);
1736			glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1737			expectError(GL_INVALID_ENUM);
1738			glTexParameteri(0, 0, GL_LINEAR);
1739			expectError(GL_INVALID_ENUM);
1740			m_log << TestLog::EndSection;
1741
1742			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.");
1743			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1744			expectError(GL_INVALID_ENUM);
1745			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1746			expectError(GL_INVALID_ENUM);
1747			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1748			expectError(GL_INVALID_ENUM);
1749			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1750			expectError(GL_INVALID_ENUM);
1751			m_log << TestLog::EndSection;
1752		});
1753	ES2F_ADD_API_CASE(texparameteri_bind, "Invalid glTexParameteri() usage",
1754		{
1755			GLuint texture;
1756			glGenTextures(1, &texture);
1757			glBindTexture(GL_TEXTURE_2D, texture);
1758
1759			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1760			glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1761			expectError(GL_INVALID_ENUM);
1762			glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1763			expectError(GL_INVALID_ENUM);
1764			glTexParameteri(0, 0, GL_LINEAR);
1765			expectError(GL_INVALID_ENUM);
1766			m_log << TestLog::EndSection;
1767
1768			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1769			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1770			expectError(GL_INVALID_ENUM);
1771			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1772			expectError(GL_INVALID_ENUM);
1773			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1774			expectError(GL_INVALID_ENUM);
1775			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1776			expectError(GL_INVALID_ENUM);
1777			m_log << TestLog::EndSection;
1778
1779			glDeleteTextures(1, &texture);
1780		});
1781
1782	// glTexParameterf
1783
1784	ES2F_ADD_API_CASE(texparameterf, "Invalid glTexParameterf() usage",
1785		{
1786			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1787			glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1788			expectError(GL_INVALID_ENUM);
1789			glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1790			expectError(GL_INVALID_ENUM);
1791			glTexParameterf(0, 0, GL_LINEAR);
1792			expectError(GL_INVALID_ENUM);
1793			m_log << TestLog::EndSection;
1794
1795			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.");
1796			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1797			expectError(GL_INVALID_ENUM);
1798			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1799			expectError(GL_INVALID_ENUM);
1800			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1801			expectError(GL_INVALID_ENUM);
1802			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1803			expectError(GL_INVALID_ENUM);
1804			m_log << TestLog::EndSection;
1805		});
1806	ES2F_ADD_API_CASE(texparameterf_bind, "Invalid glTexParameterf() usage",
1807		{
1808			GLuint texture;
1809			glGenTextures(1, &texture);
1810			glBindTexture(GL_TEXTURE_2D, texture);
1811
1812			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1813			glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1814			expectError(GL_INVALID_ENUM);
1815			glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1816			expectError(GL_INVALID_ENUM);
1817			glTexParameterf(0, 0, GL_LINEAR);
1818			expectError(GL_INVALID_ENUM);
1819			m_log << TestLog::EndSection;
1820
1821			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined symbolic constant value (based on the value of pname) and does not.");
1822			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 0);
1823			expectError(GL_INVALID_ENUM);
1824			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
1825			expectError(GL_INVALID_ENUM);
1826			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0);
1827			expectError(GL_INVALID_ENUM);
1828			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_NEAREST);
1829			expectError(GL_INVALID_ENUM);
1830			m_log << TestLog::EndSection;
1831
1832			glDeleteTextures(1, &texture);
1833		});
1834
1835	// glTexParameteriv
1836
1837	ES2F_ADD_API_CASE(texparameteriv, "Invalid glTexParameteriv() usage",
1838		{
1839			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1840			GLint params[1] = {GL_LINEAR};
1841			glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1842			expectError(GL_INVALID_ENUM);
1843			glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
1844			expectError(GL_INVALID_ENUM);
1845			glTexParameteriv(0, 0, &params[0]);
1846			expectError(GL_INVALID_ENUM);
1847			m_log << TestLog::EndSection;
1848
1849			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.");
1850			params[0] = 0;
1851			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1852			expectError(GL_INVALID_ENUM);
1853			params[0] = GL_REPEAT;
1854			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1855			expectError(GL_INVALID_ENUM);
1856			params[0] = 0;
1857			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1858			expectError(GL_INVALID_ENUM);
1859			params[0] = GL_NEAREST;
1860			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1861			expectError(GL_INVALID_ENUM);
1862			m_log << TestLog::EndSection;
1863		});
1864	ES2F_ADD_API_CASE(texparameteriv_bind, "Invalid glTexParameteriv() usage",
1865		{
1866			GLuint texture;
1867			glGenTextures(1, &texture);
1868			glBindTexture(GL_TEXTURE_2D, texture);
1869
1870			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1871			GLint params[1] = {GL_LINEAR};
1872			glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1873			expectError(GL_INVALID_ENUM);
1874			glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
1875			expectError(GL_INVALID_ENUM);
1876			glTexParameteriv(0, 0, &params[0]);
1877			expectError(GL_INVALID_ENUM);
1878			m_log << TestLog::EndSection;
1879
1880			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.");
1881			params[0] = 0;
1882			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1883			expectError(GL_INVALID_ENUM);
1884			params[0] = GL_REPEAT;
1885			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1886			expectError(GL_INVALID_ENUM);
1887			params[0] = 0;
1888			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1889			expectError(GL_INVALID_ENUM);
1890			params[0] = GL_NEAREST;
1891			glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1892			expectError(GL_INVALID_ENUM);
1893			m_log << TestLog::EndSection;
1894
1895			glDeleteTextures(1, &texture);
1896		});
1897
1898	// glTexParameterfv
1899
1900	ES2F_ADD_API_CASE(texparameterfv, "Invalid glTexParameterfv() usage",
1901		{
1902			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1903			GLfloat params[1] = {GL_LINEAR};
1904			glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1905			expectError(GL_INVALID_ENUM);
1906			glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
1907			expectError(GL_INVALID_ENUM);
1908			glTexParameterfv(0, 0, &params[0]);
1909			expectError(GL_INVALID_ENUM);
1910			m_log << TestLog::EndSection;
1911
1912			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.");
1913			params[0] = 0.0f;
1914			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1915			expectError(GL_INVALID_ENUM);
1916			params[0] = GL_REPEAT;
1917			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1918			expectError(GL_INVALID_ENUM);
1919			params[0] = 0.0f;
1920			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1921			expectError(GL_INVALID_ENUM);
1922			params[0] = GL_NEAREST;
1923			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1924			expectError(GL_INVALID_ENUM);
1925			m_log << TestLog::EndSection;
1926		});
1927	ES2F_ADD_API_CASE(texparameterfv_bind, "Invalid glTexParameterfv() usage",
1928		{
1929			GLuint texture;
1930			glGenTextures(1, &texture);
1931			glBindTexture(GL_TEXTURE_2D, texture);
1932
1933			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1934			GLfloat params[1] = {GL_LINEAR};
1935			glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
1936			expectError(GL_INVALID_ENUM);
1937			glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
1938			expectError(GL_INVALID_ENUM);
1939			glTexParameterfv(0, 0, &params[0]);
1940			expectError(GL_INVALID_ENUM);
1941			m_log << TestLog::EndSection;
1942
1943			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.");
1944			params[0] = 0.0f;
1945			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
1946			expectError(GL_INVALID_ENUM);
1947			params[0] = GL_REPEAT;
1948			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
1949			expectError(GL_INVALID_ENUM);
1950			params[0] = 0.0f;
1951			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
1952			expectError(GL_INVALID_ENUM);
1953			params[0] = GL_NEAREST;
1954			glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
1955			expectError(GL_INVALID_ENUM);
1956			m_log << TestLog::EndSection;
1957
1958			glDeleteTextures(1, &texture);
1959		});
1960
1961	// glCompressedTexSubImage2D
1962
1963	ES2F_ADD_API_CASE(compressedtexsubimage2d_invalid_target, "Invalid glCompressedTexSubImage2D() usage",
1964		{
1965			vector<deInt32> supported;
1966			vector<deInt32> accepted;
1967			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
1968			getCompressedTexSubImage2DFormat(supported, accepted);
1969
1970			if (accepted.empty())
1971			{
1972				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
1973				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
1974			}
1975			else
1976			{
1977				for (int i = 0; i < (int)accepted.size(); i++)
1978				{
1979					m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is invalid.");
1980					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
1981					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
1982					glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, accepted[i], 0, 0);
1983					expectError(GL_INVALID_ENUM);
1984					m_log << TestLog::EndSection;
1985				}
1986			}
1987		});
1988	ES2F_ADD_API_CASE(compressedtexsubimage2d_invalid_format, "Invalid glCompressedTexSubImage2D() usage",
1989		{
1990			vector<deInt32> supported;
1991			vector<deInt32> accepted;
1992			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
1993			getCompressedTexSubImage2DFormat(supported, accepted);
1994
1995			if (accepted.empty())
1996			{
1997				m_log << TestLog::Message << "// No suitable compressed formats found, expect GL_INVALID_ENUM." << TestLog::EndMessage;
1998				glCompressedTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
1999				expectError(GL_INVALID_ENUM);
2000			}
2001			else
2002			{
2003				for (int i = 0; i < (int)accepted.size(); i++)
2004				{
2005					m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if format is not a supported format returned in GL_COMPRESSED_TEXTURE_FORMATS.");
2006					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2007					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2008					//expectError(GL_NO_ERROR);
2009					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, accepted[i], 0, 0);
2010					expectError(GL_INVALID_ENUM);
2011					m_log << TestLog::EndSection;
2012				}
2013			}
2014		});
2015	ES2F_ADD_API_CASE(compressedtexsubimage2d_neg_level_tex2d, "Invalid glCompressedTexSubImage2D() usage",
2016		{
2017			vector<deInt32> supported;
2018			vector<deInt32> accepted;
2019			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2020			getCompressedTexSubImage2DFormat(supported, accepted);
2021
2022			if (accepted.empty())
2023			{
2024				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2025				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2026			}
2027			else
2028			{
2029				for (int i = 0; i < (int)accepted.size(); i++)
2030				{
2031					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2032					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2033					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2034					//expectError(GL_NO_ERROR);
2035					glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2036					expectError(GL_INVALID_VALUE);
2037					m_log << TestLog::EndSection;
2038				}
2039			}
2040		});
2041	ES2F_ADD_API_CASE(compressedtexsubimage2d_neg_level_cube, "Invalid glCompressedTexSubImage2D() usage",
2042		{
2043			vector<deInt32> supported;
2044			vector<deInt32> accepted;
2045			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2046			getCompressedTexSubImage2DFormat(supported, accepted);
2047
2048			if (accepted.empty())
2049			{
2050				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2051				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2052			}
2053			else
2054			{
2055				for (int i = 0; i < (int)accepted.size(); i++)
2056				{
2057					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
2058					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2059					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, accepted[i], 0, 0, 0, 0, 0);
2060					//expectError(GL_NO_ERROR);
2061					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2062					expectError(GL_INVALID_VALUE);
2063					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, accepted[i], 0, 0, 0, 0, 0);
2064					//expectError(GL_NO_ERROR);
2065					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2066					expectError(GL_INVALID_VALUE);
2067					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, accepted[i], 0, 0, 0, 0, 0);
2068					//expectError(GL_NO_ERROR);
2069					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2070					expectError(GL_INVALID_VALUE);
2071					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, accepted[i], 0, 0, 0, 0, 0);
2072					//expectError(GL_NO_ERROR);
2073					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2074					expectError(GL_INVALID_VALUE);
2075					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, accepted[i], 0, 0, 0, 0, 0);
2076					//expectError(GL_NO_ERROR);
2077					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2078					expectError(GL_INVALID_VALUE);
2079					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, accepted[i], 0, 0, 0, 0, 0);
2080					//expectError(GL_NO_ERROR);
2081					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, 0, 0, 0, 0, accepted[i], 0, 0);
2082					expectError(GL_INVALID_VALUE);
2083					m_log << TestLog::EndSection;
2084				}
2085			}
2086		});
2087	ES2F_ADD_API_CASE(compressedtexsubimage2d_level_max_tex2d, "Invalid glCompressedTexSubImage2D() usage",
2088		{
2089			vector<deInt32> supported;
2090			vector<deInt32> accepted;
2091			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2092			getCompressedTexSubImage2DFormat(supported, accepted);
2093
2094			if (accepted.empty())
2095			{
2096				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2097				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2098			}
2099			else
2100			{
2101				for (int i = 0; i < (int)accepted.size(); i++)
2102				{
2103					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2104					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2105					deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1;
2106					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2107					//expectError(GL_NO_ERROR);
2108					glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2109					expectError(GL_INVALID_VALUE);
2110					m_log << TestLog::EndSection;
2111				}
2112			}
2113		});
2114	ES2F_ADD_API_CASE(compressedtexsubimage2d_level_max_cube, "Invalid glCompressedTexSubImage2D() usage",
2115		{
2116			vector<deInt32> supported;
2117			vector<deInt32> accepted;
2118			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2119			getCompressedTexSubImage2DFormat(supported, accepted);
2120
2121			if (accepted.empty())
2122			{
2123				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2124				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2125			}
2126			else
2127			{
2128				for (int i = 0; i < (int)accepted.size(); i++)
2129				{
2130					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
2131					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2132					deUint32 log2MaxTextureSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
2133					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2134					//expectError(GL_NO_ERROR);
2135					glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2136					expectError(GL_INVALID_VALUE);
2137					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, accepted[i], 0, 0, 0, 0, 0);
2138					//expectError(GL_NO_ERROR);
2139					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2140					expectError(GL_INVALID_VALUE);
2141					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, accepted[i], 0, 0, 0, 0, 0);
2142					//expectError(GL_NO_ERROR);
2143					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2144					expectError(GL_INVALID_VALUE);
2145					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, accepted[i], 0, 0, 0, 0, 0);
2146					//expectError(GL_NO_ERROR);
2147					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2148					expectError(GL_INVALID_VALUE);
2149					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, accepted[i], 0, 0, 0, 0, 0);
2150					//expectError(GL_NO_ERROR);
2151					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2152					expectError(GL_INVALID_VALUE);
2153					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, accepted[i], 0, 0, 0, 0, 0);
2154					//expectError(GL_NO_ERROR);
2155					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2156					expectError(GL_INVALID_VALUE);
2157					//glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, accepted[i], 0, 0, 0, 0, 0);
2158					//expectError(GL_NO_ERROR);
2159					glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxTextureSize, 0, 0, 0, 0, accepted[i], 0, 0);
2160					expectError(GL_INVALID_VALUE);
2161					m_log << TestLog::EndSection;
2162				}
2163			}
2164		});
2165		ES2F_ADD_API_CASE(compressedtexsubimage2d_neg_offset, "Invalid glCompressedTexSubImage2D() usage",
2166		{
2167			vector<deInt32> supported;
2168			vector<deInt32> accepted;
2169			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2170			getCompressedTexSubImage2DFormat(supported, accepted);
2171
2172			if (accepted.empty())
2173			{
2174				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2175				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2176			}
2177			else
2178			{
2179				for (int i = 0; i < (int)accepted.size(); i++)
2180				{
2181					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
2182					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2183					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2184					//expectError(GL_NO_ERROR);
2185					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, accepted[i], 0, 0);
2186					expectError(GL_INVALID_VALUE);
2187					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2188					//expectError(GL_NO_ERROR);
2189					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, accepted[i], 0, 0);
2190					expectError(GL_INVALID_VALUE);
2191					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2192					//expectError(GL_NO_ERROR);
2193					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, accepted[i], 0, 0);
2194					expectError(GL_INVALID_VALUE);
2195					m_log << TestLog::EndSection;
2196				}
2197			}
2198		});
2199	ES2F_ADD_API_CASE(compressedtexsubimage2d_offset_allowed, "Invalid glCompressedTexSubImage2D() usage",
2200		{
2201			vector<deInt32> supported;
2202			vector<deInt32> accepted;
2203			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2204			getCompressedTexSubImage2DFormat(supported, accepted);
2205
2206			if (accepted.empty())
2207			{
2208				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2209				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2210			}
2211			else
2212			{
2213				for (int i = 0; i < (int)accepted.size(); i++)
2214				{
2215					deUint32 maxTextureSize = m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
2216					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
2217					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2218					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2219					//expectError(GL_NO_ERROR);
2220					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, maxTextureSize, 0, 0, 0, accepted[i], 0, 0);
2221					expectError(GL_INVALID_VALUE);
2222					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2223					//expectError(GL_NO_ERROR);
2224					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, maxTextureSize, 0, 0, accepted[i], 0, 0);
2225					expectError(GL_INVALID_VALUE);
2226					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2227					//expectError(GL_NO_ERROR);
2228					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, maxTextureSize, maxTextureSize, 0, 0, accepted[i], 0, 0);
2229					expectError(GL_INVALID_VALUE);
2230					m_log << TestLog::EndSection;
2231				}
2232			}
2233		});
2234	ES2F_ADD_API_CASE(compressedtexsubimage2d_neg_wdt_hgt, "Invalid glCompressedTexSubImage2D() usage",
2235		{
2236			vector<deInt32> supported;
2237			vector<deInt32> accepted;
2238			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2239			getCompressedTexSubImage2DFormat(supported, accepted);
2240
2241			if (accepted.empty())
2242			{
2243				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2244				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2245			}
2246			else
2247			{
2248				for (int i = 0; i < (int)accepted.size(); i++)
2249				{
2250					m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than 0.");
2251					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2252					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2253					//expectError(GL_NO_ERROR);
2254					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, accepted[i], 0, 0);
2255					expectError(GL_INVALID_VALUE);
2256					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2257					//expectError(GL_NO_ERROR);
2258					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, accepted[i], 0, 0);
2259					expectError(GL_INVALID_VALUE);
2260					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2261					//expectError(GL_NO_ERROR);
2262					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, accepted[i], 0, 0);
2263					expectError(GL_INVALID_VALUE);
2264					m_log << TestLog::EndSection;
2265				}
2266			}
2267		});
2268	ES2F_ADD_API_CASE(compressedtexsubimage2d_invalid_size, "Invalid glCompressedTexImage2D() usage",
2269		{
2270			vector<deInt32> supported;
2271			vector<deInt32> accepted;
2272			getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, supported);
2273			getCompressedTexSubImage2DFormat(supported, accepted);
2274
2275			if (accepted.empty())
2276			{
2277				m_log << TestLog::Message << "// No suitable compressed formats found, cannot evaluate test." << TestLog::EndMessage;
2278				m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No suitable compressed formats found");
2279			}
2280			else
2281			{
2282				for (int i = 0; i < (int)accepted.size(); i++)
2283				{
2284					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.");
2285					m_log << TestLog::Message << "// Using texture format " << tcu::toHex(accepted[i]) << TestLog::EndMessage;
2286					//glCompressedTexImage2D(GL_TEXTURE_2D, 0, accepted[i], 0, 0, 0, 0, 0);
2287					//expectError(GL_NO_ERROR);
2288					glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, accepted[i], -1, 0);
2289					expectError(GL_INVALID_VALUE);
2290					m_log << TestLog::EndSection;
2291				}
2292			}
2293		});
2294}
2295
2296} // Functional
2297} // gles2
2298} // deqp
2299