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