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