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