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