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 #include "gluRenderContext.hpp"
30 
31 #include "glwDefs.hpp"
32 #include "glwEnums.hpp"
33 
34 namespace deqp
35 {
36 namespace gles31
37 {
38 namespace Functional
39 {
40 namespace NegativeTestShared
41 {
42 
43 using tcu::TestLog;
44 using glu::CallLogWrapper;
45 using namespace glw;
46 
divRoundUp(int a,int b)47 static inline int divRoundUp (int a, int b)
48 {
49 	return a/b + (a%b != 0 ? 1 : 0);
50 }
51 
etc2DataSize(int width,int height)52 static inline int etc2DataSize (int width, int height)
53 {
54 	return (int)(divRoundUp(width, 4) * divRoundUp(height, 4) * sizeof(deUint64));
55 }
56 
etc2EacDataSize(int width,int height)57 static inline int etc2EacDataSize (int width, int height)
58 {
59 	return 2 * etc2DataSize(width, height);
60 }
61 
cubeFaceToGLFace(tcu::CubeFace face)62 static deUint32 cubeFaceToGLFace (tcu::CubeFace face)
63 {
64 	switch (face)
65 	{
66 		case tcu::CUBEFACE_NEGATIVE_X: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
67 		case tcu::CUBEFACE_POSITIVE_X: return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
68 		case tcu::CUBEFACE_NEGATIVE_Y: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
69 		case tcu::CUBEFACE_POSITIVE_Y: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
70 		case tcu::CUBEFACE_NEGATIVE_Z: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
71 		case tcu::CUBEFACE_POSITIVE_Z: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
72 		default:
73 			DE_ASSERT(DE_FALSE);
74 			return GL_NONE;
75 	}
76 }
77 
78 #define FOR_CUBE_FACES(FACE_GL_VAR, BODY)												\
79 	do																					\
80 	{																					\
81 		for (int faceIterTcu = 0; faceIterTcu < tcu::CUBEFACE_LAST; faceIterTcu++)		\
82 		{																				\
83 			const GLenum FACE_GL_VAR = cubeFaceToGLFace((tcu::CubeFace)faceIterTcu);	\
84 			BODY																		\
85 		}																				\
86 	} while (false)
87 
88 
89 // glActiveTexture
90 
activetexture(NegativeTestContext & ctx)91 void activetexture (NegativeTestContext& ctx)
92 {
93 	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).");
94 	ctx.glActiveTexture(-1);
95 	ctx.expectError(GL_INVALID_ENUM);
96 	int numMaxTextureUnits = ctx.getInteger(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
97 	ctx.glActiveTexture(GL_TEXTURE0 + numMaxTextureUnits);
98 	ctx.expectError(GL_INVALID_ENUM);
99 	ctx.endSection();
100 }
101 
102 // glBindTexture
103 
bindtexture(NegativeTestContext & ctx)104 void bindtexture (NegativeTestContext& ctx)
105 {
106 	GLuint texture[5];
107 	ctx.glGenTextures(5, texture);
108 
109 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
110 	ctx.glBindTexture(0, 1);
111 	ctx.expectError(GL_INVALID_ENUM);
112 	ctx.glBindTexture(GL_FRAMEBUFFER, 1);
113 	ctx.expectError(GL_INVALID_ENUM);
114 	ctx.endSection();
115 
116 	ctx.beginSection("GL_INVALID_OPERATION is generated if texture was previously created with a target that doesn't match that of target.");
117 	ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
118 	ctx.expectError(GL_NO_ERROR);
119 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
120 	ctx.expectError(GL_INVALID_OPERATION);
121 	ctx.glBindTexture(GL_TEXTURE_3D, texture[0]);
122 	ctx.expectError(GL_INVALID_OPERATION);
123 	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[0]);
124 	ctx.expectError(GL_INVALID_OPERATION);
125 
126 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[1]);
127 	ctx.expectError(GL_NO_ERROR);
128 	ctx.glBindTexture(GL_TEXTURE_2D, texture[1]);
129 	ctx.expectError(GL_INVALID_OPERATION);
130 	ctx.glBindTexture(GL_TEXTURE_3D, texture[1]);
131 	ctx.expectError(GL_INVALID_OPERATION);
132 	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[1]);
133 	ctx.expectError(GL_INVALID_OPERATION);
134 
135 	ctx.glBindTexture(GL_TEXTURE_3D, texture[2]);
136 	ctx.expectError(GL_NO_ERROR);
137 	ctx.glBindTexture(GL_TEXTURE_2D, texture[2]);
138 	ctx.expectError(GL_INVALID_OPERATION);
139 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[2]);
140 	ctx.expectError(GL_INVALID_OPERATION);
141 	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[2]);
142 	ctx.expectError(GL_INVALID_OPERATION);
143 
144 	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[3]);
145 	ctx.expectError(GL_NO_ERROR);
146 	ctx.glBindTexture(GL_TEXTURE_2D, texture[3]);
147 	ctx.expectError(GL_INVALID_OPERATION);
148 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[3]);
149 	ctx.expectError(GL_INVALID_OPERATION);
150 	ctx.glBindTexture(GL_TEXTURE_3D, texture[3]);
151 	ctx.expectError(GL_INVALID_OPERATION);
152 
153 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
154 	{
155 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[0]);
156 		ctx.expectError(GL_INVALID_OPERATION);
157 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[1]);
158 		ctx.expectError(GL_INVALID_OPERATION);
159 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[2]);
160 		ctx.expectError(GL_INVALID_OPERATION);
161 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[3]);
162 		ctx.expectError(GL_INVALID_OPERATION);
163 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[4]);
164 		ctx.expectError(GL_NO_ERROR);
165 		ctx.glBindTexture(GL_TEXTURE_2D, texture[4]);
166 		ctx.expectError(GL_INVALID_OPERATION);
167 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[4]);
168 		ctx.expectError(GL_INVALID_OPERATION);
169 		ctx.glBindTexture(GL_TEXTURE_3D, texture[4]);
170 		ctx.expectError(GL_INVALID_OPERATION);
171 		ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[4]);
172 		ctx.expectError(GL_INVALID_OPERATION);
173 	}
174 	ctx.endSection();
175 
176 	ctx.glDeleteTextures(5, texture);
177 }
178 
179 // glCompressedTexImage2D
180 
compressedteximage2d_invalid_target(NegativeTestContext & ctx)181 void compressedteximage2d_invalid_target (NegativeTestContext& ctx)
182 {
183 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
184 	ctx.glCompressedTexImage2D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
185 	ctx.expectError(GL_INVALID_ENUM);
186 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
187 	ctx.expectError(GL_INVALID_ENUM);
188 	ctx.endSection();
189 }
190 
compressedteximage2d_invalid_format(NegativeTestContext & ctx)191 void compressedteximage2d_invalid_format (NegativeTestContext& ctx)
192 {
193 	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a supported format returned in GL_COMPRESSED_TEXTURE_FORMATS.");
194 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
195 	ctx.expectError(GL_INVALID_ENUM);
196 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, 0, 0);
197 	ctx.expectError(GL_INVALID_ENUM);
198 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, 0, 0);
199 	ctx.expectError(GL_INVALID_ENUM);
200 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
201 	ctx.expectError(GL_INVALID_ENUM);
202 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
203 	ctx.expectError(GL_INVALID_ENUM);
204 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
205 	ctx.expectError(GL_INVALID_ENUM);
206 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
207 	ctx.expectError(GL_INVALID_ENUM);
208 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
209 	ctx.expectError(GL_INVALID_ENUM);
210 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
211 	ctx.expectError(GL_INVALID_ENUM);
212 	ctx.endSection();
213 }
214 
compressedteximage2d_neg_level(NegativeTestContext & ctx)215 void compressedteximage2d_neg_level (NegativeTestContext& ctx)
216 {
217 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
218 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
219 	ctx.expectError(GL_INVALID_VALUE);
220 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
221 	ctx.expectError(GL_INVALID_VALUE);
222 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
223 	ctx.expectError(GL_INVALID_VALUE);
224 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
225 	ctx.expectError(GL_INVALID_VALUE);
226 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
227 	ctx.expectError(GL_INVALID_VALUE);
228 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
229 	ctx.expectError(GL_INVALID_VALUE);
230 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
231 	ctx.expectError(GL_INVALID_VALUE);
232 	ctx.endSection();
233 }
234 
compressedteximage2d_max_level(NegativeTestContext & ctx)235 void compressedteximage2d_max_level (NegativeTestContext& ctx)
236 {
237 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for a 2d texture target.");
238 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
239 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
240 	ctx.expectError(GL_INVALID_VALUE);
241 	ctx.endSection();
242 
243 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE) for a cubemap target.");
244 	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
245 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
246 	ctx.expectError(GL_INVALID_VALUE);
247 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
248 	ctx.expectError(GL_INVALID_VALUE);
249 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
250 	ctx.expectError(GL_INVALID_VALUE);
251 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
252 	ctx.expectError(GL_INVALID_VALUE);
253 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
254 	ctx.expectError(GL_INVALID_VALUE);
255 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
256 	ctx.expectError(GL_INVALID_VALUE);
257 	ctx.endSection();
258 }
259 
compressedteximage2d_neg_width_height(NegativeTestContext & ctx)260 void compressedteximage2d_neg_width_height (NegativeTestContext& ctx)
261 {
262 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
263 
264 	ctx.beginSection("GL_TEXTURE_2D target");
265 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
266 	ctx.expectError(GL_INVALID_VALUE);
267 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
268 	ctx.expectError(GL_INVALID_VALUE);
269 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
270 	ctx.expectError(GL_INVALID_VALUE);
271 	ctx.endSection();
272 
273 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
274 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
275 	ctx.expectError(GL_INVALID_VALUE);
276 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
277 	ctx.expectError(GL_INVALID_VALUE);
278 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
279 	ctx.expectError(GL_INVALID_VALUE);
280 	ctx.endSection();
281 
282 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
283 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
284 	ctx.expectError(GL_INVALID_VALUE);
285 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
286 	ctx.expectError(GL_INVALID_VALUE);
287 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
288 	ctx.expectError(GL_INVALID_VALUE);
289 	ctx.endSection();
290 
291 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
292 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
293 	ctx.expectError(GL_INVALID_VALUE);
294 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
295 	ctx.expectError(GL_INVALID_VALUE);
296 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
297 	ctx.expectError(GL_INVALID_VALUE);
298 	ctx.endSection();
299 
300 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
301 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
302 	ctx.expectError(GL_INVALID_VALUE);
303 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
304 	ctx.expectError(GL_INVALID_VALUE);
305 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
306 	ctx.expectError(GL_INVALID_VALUE);
307 	ctx.endSection();
308 
309 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
310 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
311 	ctx.expectError(GL_INVALID_VALUE);
312 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
313 	ctx.expectError(GL_INVALID_VALUE);
314 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
315 	ctx.expectError(GL_INVALID_VALUE);
316 	ctx.endSection();
317 
318 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
319 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
320 	ctx.expectError(GL_INVALID_VALUE);
321 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
322 	ctx.expectError(GL_INVALID_VALUE);
323 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
324 	ctx.expectError(GL_INVALID_VALUE);
325 	ctx.endSection();
326 
327 	ctx.endSection();
328 }
329 
compressedteximage2d_max_width_height(NegativeTestContext & ctx)330 void compressedteximage2d_max_width_height (NegativeTestContext& ctx)
331 {
332 	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
333 	int maxCubemapSize = ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
334 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
335 
336 	ctx.beginSection("GL_TEXTURE_2D target");
337 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 1, 0, etc2EacDataSize(maxTextureSize, 1), 0);
338 	ctx.expectError(GL_INVALID_VALUE);
339 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxTextureSize, 0, etc2EacDataSize(1, maxTextureSize), 0);
340 	ctx.expectError(GL_INVALID_VALUE);
341 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, 0, etc2EacDataSize(maxTextureSize, maxTextureSize), 0);
342 	ctx.expectError(GL_INVALID_VALUE);
343 	ctx.endSection();
344 
345 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
346 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
347 	ctx.expectError(GL_INVALID_VALUE);
348 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
349 	ctx.expectError(GL_INVALID_VALUE);
350 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
351 	ctx.expectError(GL_INVALID_VALUE);
352 	ctx.endSection();
353 
354 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
355 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
356 	ctx.expectError(GL_INVALID_VALUE);
357 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
358 	ctx.expectError(GL_INVALID_VALUE);
359 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
360 	ctx.expectError(GL_INVALID_VALUE);
361 	ctx.endSection();
362 
363 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
364 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
365 	ctx.expectError(GL_INVALID_VALUE);
366 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
367 	ctx.expectError(GL_INVALID_VALUE);
368 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
369 	ctx.expectError(GL_INVALID_VALUE);
370 	ctx.endSection();
371 
372 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
373 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
374 	ctx.expectError(GL_INVALID_VALUE);
375 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
376 	ctx.expectError(GL_INVALID_VALUE);
377 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
378 	ctx.expectError(GL_INVALID_VALUE);
379 	ctx.endSection();
380 
381 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
382 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
383 	ctx.expectError(GL_INVALID_VALUE);
384 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
385 	ctx.expectError(GL_INVALID_VALUE);
386 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
387 	ctx.expectError(GL_INVALID_VALUE);
388 	ctx.endSection();
389 
390 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
391 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
392 	ctx.expectError(GL_INVALID_VALUE);
393 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
394 	ctx.expectError(GL_INVALID_VALUE);
395 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
396 	ctx.expectError(GL_INVALID_VALUE);
397 	ctx.endSection();
398 
399 	ctx.endSection();
400 }
401 
compressedteximage2d_invalid_border(NegativeTestContext & ctx)402 void compressedteximage2d_invalid_border (NegativeTestContext& ctx)
403 {
404 	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
405 
406 	ctx.beginSection("GL_TEXTURE_2D target");
407 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
408 	ctx.expectError(GL_INVALID_VALUE);
409 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
410 	ctx.expectError(GL_INVALID_VALUE);
411 	ctx.endSection();
412 
413 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
414 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
415 	ctx.expectError(GL_INVALID_VALUE);
416 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
417 	ctx.expectError(GL_INVALID_VALUE);
418 	ctx.endSection();
419 
420 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
421 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
422 	ctx.expectError(GL_INVALID_VALUE);
423 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
424 	ctx.expectError(GL_INVALID_VALUE);
425 	ctx.endSection();
426 
427 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
428 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
429 	ctx.expectError(GL_INVALID_VALUE);
430 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
431 	ctx.expectError(GL_INVALID_VALUE);
432 	ctx.endSection();
433 
434 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
435 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
436 	ctx.expectError(GL_INVALID_VALUE);
437 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
438 	ctx.expectError(GL_INVALID_VALUE);
439 	ctx.endSection();
440 
441 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
442 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
443 	ctx.expectError(GL_INVALID_VALUE);
444 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
445 	ctx.expectError(GL_INVALID_VALUE);
446 	ctx.endSection();
447 
448 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
449 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
450 	ctx.expectError(GL_INVALID_VALUE);
451 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
452 	ctx.expectError(GL_INVALID_VALUE);
453 	ctx.endSection();
454 
455 	ctx.endSection();
456 }
457 
compressedteximage2d_invalid_size(NegativeTestContext & ctx)458 void compressedteximage2d_invalid_size (NegativeTestContext& ctx)
459 {
460 	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
461 	// Subtracting 1 to the imageSize field to deviate from the expected size. Removing the -1 would cause the imageSize to be correct.
462 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_R11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
463 	ctx.expectError(GL_INVALID_VALUE);
464 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_R11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
465 	ctx.expectError(GL_INVALID_VALUE);
466 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RG11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
467 	ctx.expectError(GL_INVALID_VALUE);
468 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_RG11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
469 	ctx.expectError(GL_INVALID_VALUE);
470 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
471 	ctx.expectError(GL_INVALID_VALUE);
472 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
473 	ctx.expectError(GL_INVALID_VALUE);
474 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
475 	ctx.expectError(GL_INVALID_VALUE);
476 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
477 	ctx.expectError(GL_INVALID_VALUE);
478 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
479 	ctx.expectError(GL_INVALID_VALUE);
480 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
481 	ctx.expectError(GL_INVALID_VALUE);
482 
483 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
484 	{
485 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_4x4, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
486 	    ctx.expectError(GL_INVALID_VALUE);
487 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_5x4, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 4) * 16 - 1, 0);
488 	    ctx.expectError(GL_INVALID_VALUE);
489 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_5x5, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 5) * 16 - 1, 0);
490 	    ctx.expectError(GL_INVALID_VALUE);
491 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_6x5, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 5) * 16 - 1, 0);
492 	    ctx.expectError(GL_INVALID_VALUE);
493 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_6x6, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 6) * 16 - 1, 0);
494 	    ctx.expectError(GL_INVALID_VALUE);
495 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x5, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 5) * 16 - 1, 0);
496 	    ctx.expectError(GL_INVALID_VALUE);
497 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x6, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 6) * 16 - 1, 0);
498 	    ctx.expectError(GL_INVALID_VALUE);
499 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x8, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 8) * 16 - 1, 0);
500 	    ctx.expectError(GL_INVALID_VALUE);
501 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x5, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 5) * 16 - 1, 0);
502 	    ctx.expectError(GL_INVALID_VALUE);
503 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x6, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 6) * 16 - 1, 0);
504 	    ctx.expectError(GL_INVALID_VALUE);
505 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x8, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 8) * 16 - 1, 0);
506 	    ctx.expectError(GL_INVALID_VALUE);
507 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x10, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 10) * 16 - 1, 0);
508 	    ctx.expectError(GL_INVALID_VALUE);
509 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_12x10, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 10) * 16 - 1, 0);
510 	    ctx.expectError(GL_INVALID_VALUE);
511 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_12x12, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 12) * 16 - 1, 0);
512 	    ctx.expectError(GL_INVALID_VALUE);
513 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
514 	    ctx.expectError(GL_INVALID_VALUE);
515 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 4) * 16 - 1, 0);
516 	    ctx.expectError(GL_INVALID_VALUE);
517 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 5) * 16 - 1, 0);
518 	    ctx.expectError(GL_INVALID_VALUE);
519 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 5) * 16 - 1, 0);
520 	    ctx.expectError(GL_INVALID_VALUE);
521 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 6) * 16 - 1, 0);
522 	    ctx.expectError(GL_INVALID_VALUE);
523 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 5) * 16 - 1, 0);
524 	    ctx.expectError(GL_INVALID_VALUE);
525 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 6) * 16 - 1, 0);
526 	    ctx.expectError(GL_INVALID_VALUE);
527 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 8) * 16 - 1, 0);
528 	    ctx.expectError(GL_INVALID_VALUE);
529 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 5) * 16 - 1, 0);
530 	    ctx.expectError(GL_INVALID_VALUE);
531 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 6) * 16 - 1, 0);
532 	    ctx.expectError(GL_INVALID_VALUE);
533 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 8) * 16 - 1, 0);
534 	    ctx.expectError(GL_INVALID_VALUE);
535 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 10) * 16 - 1, 0);
536 	    ctx.expectError(GL_INVALID_VALUE);
537 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 10) * 16 - 1, 0);
538 	    ctx.expectError(GL_INVALID_VALUE);
539 	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 12) * 16 - 1, 0);
540 	    ctx.expectError(GL_INVALID_VALUE);
541 	}
542 	ctx.endSection();
543 }
544 
compressedteximage2d_neg_size(NegativeTestContext & ctx)545 void compressedteximage2d_neg_size (NegativeTestContext& ctx)
546 {
547 	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is negative.");
548 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_R11_EAC, 0, 0, 0, -1, 0);
549 	ctx.expectError(GL_INVALID_VALUE);
550 	ctx.endSection();
551 }
552 
compressedteximage2d_invalid_width_height(NegativeTestContext & ctx)553 void compressedteximage2d_invalid_width_height (NegativeTestContext& ctx)
554 {
555 	ctx.beginSection("GL_INVALID_VALUE is generated if target is a cube map face and width and height are not equal.");
556 
557 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
558 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
559 	ctx.expectError(GL_INVALID_VALUE);
560 	ctx.endSection();
561 
562 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
563 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
564 	ctx.expectError(GL_INVALID_VALUE);
565 	ctx.endSection();
566 
567 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
568 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
569 	ctx.expectError(GL_INVALID_VALUE);
570 	ctx.endSection();
571 
572 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
573 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
574 	ctx.expectError(GL_INVALID_VALUE);
575 	ctx.endSection();
576 
577 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
578 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
579 	ctx.expectError(GL_INVALID_VALUE);
580 	ctx.endSection();
581 
582 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
583 	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
584 	ctx.expectError(GL_INVALID_VALUE);
585 	ctx.endSection();
586 
587 	ctx.endSection();
588 }
589 
compressedteximage2d_invalid_buffer_target(NegativeTestContext & ctx)590 void compressedteximage2d_invalid_buffer_target (NegativeTestContext& ctx)
591 {
592 	deUint32				buf = 1234;
593 	std::vector<GLubyte>	data(64);
594 
595 	ctx.glGenBuffers			(1, &buf);
596 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
597 	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
598 	ctx.expectError				(GL_NO_ERROR);
599 
600 	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.");
601 	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
602 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 0, etc2DataSize(4, 4), 0);
603 	ctx.expectError				(GL_INVALID_OPERATION);
604 	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
605 	ctx.endSection();
606 
607 	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.");
608 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
609 	ctx.expectError				(GL_INVALID_OPERATION);
610 	ctx.endSection();
611 
612 	ctx.glDeleteBuffers			(1, &buf);
613 }
614 
615 // glCopyTexImage2D
616 
copyteximage2d_invalid_target(NegativeTestContext & ctx)617 void copyteximage2d_invalid_target (NegativeTestContext& ctx)
618 {
619 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
620 	ctx.glCopyTexImage2D(0, 0, GL_RGB, 0, 0, 64, 64, 0);
621 	ctx.expectError(GL_INVALID_ENUM);
622 	ctx.endSection();
623 }
624 
copyteximage2d_invalid_format(NegativeTestContext & ctx)625 void copyteximage2d_invalid_format (NegativeTestContext& ctx)
626 {
627 	ctx.beginSection("GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
628 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0);
629 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
630 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0);
631 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
632 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0);
633 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
634 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0);
635 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
636 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0);
637 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
638 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0);
639 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
640 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0);
641 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
642 	ctx.endSection();
643 }
644 
copyteximage2d_inequal_width_height_cube(NegativeTestContext & ctx)645 void copyteximage2d_inequal_width_height_cube (NegativeTestContext& ctx)
646 {
647 	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.");
648 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
649 	ctx.expectError(GL_INVALID_VALUE);
650 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
651 	ctx.expectError(GL_INVALID_VALUE);
652 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
653 	ctx.expectError(GL_INVALID_VALUE);
654 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
655 	ctx.expectError(GL_INVALID_VALUE);
656 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
657 	ctx.expectError(GL_INVALID_VALUE);
658 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
659 	ctx.expectError(GL_INVALID_VALUE);
660 	ctx.endSection();
661 }
662 
copyteximage2d_neg_level(NegativeTestContext & ctx)663 void copyteximage2d_neg_level (NegativeTestContext& ctx)
664 {
665 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
666 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 0, 0, 64, 64, 0);
667 	ctx.expectError(GL_INVALID_VALUE);
668 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
669 	ctx.expectError(GL_INVALID_VALUE);
670 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
671 	ctx.expectError(GL_INVALID_VALUE);
672 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
673 	ctx.expectError(GL_INVALID_VALUE);
674 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
675 	ctx.expectError(GL_INVALID_VALUE);
676 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
677 	ctx.expectError(GL_INVALID_VALUE);
678 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
679 	ctx.expectError(GL_INVALID_VALUE);
680 	ctx.endSection();
681 }
682 
copyteximage2d_max_level(NegativeTestContext & ctx)683 void copyteximage2d_max_level (NegativeTestContext& ctx)
684 {
685 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
686 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
687 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 0, 0, 64, 64, 0);
688 	ctx.expectError(GL_INVALID_VALUE);
689 	ctx.endSection();
690 
691 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
692 	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
693 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
694 	ctx.expectError(GL_INVALID_VALUE);
695 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
696 	ctx.expectError(GL_INVALID_VALUE);
697 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
698 	ctx.expectError(GL_INVALID_VALUE);
699 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
700 	ctx.expectError(GL_INVALID_VALUE);
701 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
702 	ctx.expectError(GL_INVALID_VALUE);
703 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
704 	ctx.expectError(GL_INVALID_VALUE);
705 	ctx.endSection();
706 }
707 
copyteximage2d_neg_width_height(NegativeTestContext & ctx)708 void copyteximage2d_neg_width_height (NegativeTestContext& ctx)
709 {
710 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
711 
712 	ctx.beginSection("GL_TEXTURE_2D target");
713 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, 1, 0);
714 	ctx.expectError(GL_INVALID_VALUE);
715 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, -1, 0);
716 	ctx.expectError(GL_INVALID_VALUE);
717 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, -1, 0);
718 	ctx.expectError(GL_INVALID_VALUE);
719 	ctx.endSection();
720 
721 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
722 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
723 	ctx.expectError(GL_INVALID_VALUE);
724 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
725 	ctx.expectError(GL_INVALID_VALUE);
726 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
727 	ctx.expectError(GL_INVALID_VALUE);
728 	ctx.endSection();
729 
730 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
731 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
732 	ctx.expectError(GL_INVALID_VALUE);
733 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
734 	ctx.expectError(GL_INVALID_VALUE);
735 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
736 	ctx.expectError(GL_INVALID_VALUE);
737 	ctx.endSection();
738 
739 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
740 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
741 	ctx.expectError(GL_INVALID_VALUE);
742 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
743 	ctx.expectError(GL_INVALID_VALUE);
744 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
745 	ctx.expectError(GL_INVALID_VALUE);
746 	ctx.endSection();
747 
748 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
749 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
750 	ctx.expectError(GL_INVALID_VALUE);
751 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
752 	ctx.expectError(GL_INVALID_VALUE);
753 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
754 	ctx.expectError(GL_INVALID_VALUE);
755 	ctx.endSection();
756 
757 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
758 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
759 	ctx.expectError(GL_INVALID_VALUE);
760 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
761 	ctx.expectError(GL_INVALID_VALUE);
762 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
763 	ctx.expectError(GL_INVALID_VALUE);
764 	ctx.endSection();
765 
766 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
767 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
768 	ctx.expectError(GL_INVALID_VALUE);
769 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
770 	ctx.expectError(GL_INVALID_VALUE);
771 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
772 	ctx.expectError(GL_INVALID_VALUE);
773 	ctx.endSection();
774 
775 	ctx.endSection();
776 }
777 
copyteximage2d_max_width_height(NegativeTestContext & ctx)778 void copyteximage2d_max_width_height (NegativeTestContext& ctx)
779 {
780 	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
781 	int maxCubemapSize = ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
782 
783 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
784 
785 	ctx.beginSection("GL_TEXTURE_2D target");
786 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
787 	ctx.expectError(GL_INVALID_VALUE);
788 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
789 	ctx.expectError(GL_INVALID_VALUE);
790 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
791 	ctx.expectError(GL_INVALID_VALUE);
792 	ctx.endSection();
793 
794 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
795 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
796 	ctx.expectError(GL_INVALID_VALUE);
797 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
798 	ctx.expectError(GL_INVALID_VALUE);
799 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
800 	ctx.expectError(GL_INVALID_VALUE);
801 	ctx.endSection();
802 
803 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
804 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
805 	ctx.expectError(GL_INVALID_VALUE);
806 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
807 	ctx.expectError(GL_INVALID_VALUE);
808 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
809 	ctx.expectError(GL_INVALID_VALUE);
810 	ctx.endSection();
811 
812 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
813 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
814 	ctx.expectError(GL_INVALID_VALUE);
815 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
816 	ctx.expectError(GL_INVALID_VALUE);
817 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
818 	ctx.expectError(GL_INVALID_VALUE);
819 	ctx.endSection();
820 
821 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
822 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
823 	ctx.expectError(GL_INVALID_VALUE);
824 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
825 	ctx.expectError(GL_INVALID_VALUE);
826 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
827 	ctx.expectError(GL_INVALID_VALUE);
828 	ctx.endSection();
829 
830 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
831 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
832 	ctx.expectError(GL_INVALID_VALUE);
833 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
834 	ctx.expectError(GL_INVALID_VALUE);
835 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
836 	ctx.expectError(GL_INVALID_VALUE);
837 	ctx.endSection();
838 
839 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
840 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
841 	ctx.expectError(GL_INVALID_VALUE);
842 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
843 	ctx.expectError(GL_INVALID_VALUE);
844 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
845 	ctx.expectError(GL_INVALID_VALUE);
846 	ctx.endSection();
847 
848 	ctx.endSection();
849 }
850 
copyteximage2d_invalid_border(NegativeTestContext & ctx)851 void copyteximage2d_invalid_border (NegativeTestContext& ctx)
852 {
853 	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
854 
855 	ctx.beginSection("GL_TEXTURE_2D target");
856 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, -1);
857 	ctx.expectError(GL_INVALID_VALUE);
858 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, 1);
859 	ctx.expectError(GL_INVALID_VALUE);
860 	ctx.endSection();
861 
862 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
863 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
864 	ctx.expectError(GL_INVALID_VALUE);
865 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
866 	ctx.expectError(GL_INVALID_VALUE);
867 	ctx.endSection();
868 
869 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
870 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
871 	ctx.expectError(GL_INVALID_VALUE);
872 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
873 	ctx.expectError(GL_INVALID_VALUE);
874 	ctx.endSection();
875 
876 	ctx.beginSection("GL_TEXTURE_2D target");
877 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
878 	ctx.expectError(GL_INVALID_VALUE);
879 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
880 	ctx.expectError(GL_INVALID_VALUE);
881 	ctx.endSection();
882 
883 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
884 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
885 	ctx.expectError(GL_INVALID_VALUE);
886 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
887 	ctx.expectError(GL_INVALID_VALUE);
888 	ctx.endSection();
889 
890 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
891 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
892 	ctx.expectError(GL_INVALID_VALUE);
893 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
894 	ctx.expectError(GL_INVALID_VALUE);
895 	ctx.endSection();
896 
897 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
898 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
899 	ctx.expectError(GL_INVALID_VALUE);
900 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
901 	ctx.expectError(GL_INVALID_VALUE);
902 	ctx.endSection();
903 
904 	ctx.endSection();
905 }
906 
copyteximage2d_incomplete_framebuffer(NegativeTestContext & ctx)907 void copyteximage2d_incomplete_framebuffer (NegativeTestContext& ctx)
908 {
909 	GLuint fbo = 0x1234;
910 	ctx.glGenFramebuffers		(1, &fbo);
911 	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
912 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
913 
914 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
915 	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, 0, 0);
916 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
917 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
918 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
919 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
920 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
921 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
922 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
923 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
924 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
925 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
926 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
927 	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
928 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
929 	ctx.endSection();
930 
931 	ctx.glBindFramebuffer	(GL_FRAMEBUFFER, 0);
932 	ctx.glDeleteFramebuffers(1, &fbo);
933 }
934 
copytexsubimage2d_invalid_target(NegativeTestContext & ctx)935 void copytexsubimage2d_invalid_target (NegativeTestContext& ctx)
936 {
937 	GLuint texture = 0x1234;
938 	ctx.glGenTextures	(1, &texture);
939 	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
940 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
941 
942 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
943 	ctx.glCopyTexSubImage2D(0, 0, 0, 0, 0, 0, 4, 4);
944 	ctx.expectError(GL_INVALID_ENUM);
945 	ctx.endSection();
946 
947 	ctx.glDeleteTextures(1, &texture);
948 }
copytexsubimage2d_read_buffer_is_none(NegativeTestContext & ctx)949 void copytexsubimage2d_read_buffer_is_none (NegativeTestContext& ctx)
950 {
951 	GLuint texture = 0x1234;
952 	ctx.glGenTextures	(1, &texture);
953 	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
954 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
955 
956 	ctx.beginSection("GL_INVALID_OPERATION is generated if the read buffer is NONE");
957 	ctx.glReadBuffer(GL_NONE);
958 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
959 	ctx.expectError(GL_INVALID_OPERATION);
960 	ctx.endSection();
961 
962 	ctx.glDeleteTextures(1, &texture);
963 }
964 
copytexsubimage2d_texture_internalformat(NegativeTestContext & ctx)965 void copytexsubimage2d_texture_internalformat (NegativeTestContext& ctx)
966 {
967 	GLuint texture = 0x1234;
968 	ctx.glGenTextures	(1, &texture);
969 	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
970 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGB9_E5, 16, 16, 0, GL_RGB, GL_FLOAT, 0);
971 
972 	ctx.beginSection("GL_INVALID_OPERATION is generated if internal format of the texture is GL_RGB9_E5");
973 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
974 	ctx.expectError(GL_INVALID_OPERATION);
975 	ctx.endSection();
976 
977 	ctx.glDeleteTextures(1, &texture);
978 }
979 
copytexsubimage2d_neg_level(NegativeTestContext & ctx)980 void copytexsubimage2d_neg_level (NegativeTestContext& ctx)
981 {
982 	GLuint textures[2];
983 	ctx.glGenTextures	(2, &textures[0]);
984 	ctx.glBindTexture	(GL_TEXTURE_2D, textures[0]);
985 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
986 	ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP, textures[1]);
987 	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
988 
989 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
990 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, 4, 4);
991 	ctx.expectError(GL_INVALID_VALUE);
992 	FOR_CUBE_FACES(faceGL,
993 	{
994 		ctx.glCopyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4);
995 		ctx.expectError(GL_INVALID_VALUE);
996 	});
997 	ctx.endSection();
998 
999 	ctx.glDeleteTextures(2, &textures[0]);
1000 }
1001 
copytexsubimage2d_max_level(NegativeTestContext & ctx)1002 void copytexsubimage2d_max_level (NegativeTestContext& ctx)
1003 {
1004 	GLuint textures[2];
1005 	ctx.glGenTextures	(2, &textures[0]);
1006 	ctx.glBindTexture	(GL_TEXTURE_2D, textures[0]);
1007 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1008 	ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP, textures[1]);
1009 	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
1010 
1011 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for 2D texture targets.");
1012 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
1013 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 4, 4);
1014 	ctx.expectError(GL_INVALID_VALUE);
1015 	ctx.endSection();
1016 
1017 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_SIZE) for cubemap targets.");
1018 	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1019 	FOR_CUBE_FACES(faceGL,
1020 	{
1021 		ctx.glCopyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4);
1022 		ctx.expectError(GL_INVALID_VALUE);
1023 	});
1024 	ctx.endSection();
1025 
1026 	ctx.glDeleteTextures(2, &textures[0]);
1027 }
1028 
copytexsubimage2d_neg_offset(NegativeTestContext & ctx)1029 void copytexsubimage2d_neg_offset (NegativeTestContext& ctx)
1030 {
1031 	GLuint texture = 0x1234;
1032 	ctx.glGenTextures	(1, &texture);
1033 	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
1034 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1035 
1036 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.");
1037 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, 4, 4);
1038 	ctx.expectError(GL_INVALID_VALUE);
1039 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, 4, 4);
1040 	ctx.expectError(GL_INVALID_VALUE);
1041 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, 4, 4);
1042 	ctx.expectError(GL_INVALID_VALUE);
1043 	ctx.endSection();
1044 
1045 	ctx.glDeleteTextures(1, &texture);
1046 }
1047 
copytexsubimage2d_invalid_offset(NegativeTestContext & ctx)1048 void copytexsubimage2d_invalid_offset (NegativeTestContext& ctx)
1049 {
1050 	GLuint texture = 0x1234;
1051 	ctx.glGenTextures	(1, &texture);
1052 	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
1053 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1054 
1055 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1056 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 0, 0, 0, 4, 4);
1057 	ctx.expectError(GL_INVALID_VALUE);
1058 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 14, 0, 0, 4, 4);
1059 	ctx.expectError(GL_INVALID_VALUE);
1060 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 14, 0, 0, 4, 4);
1061 	ctx.expectError(GL_INVALID_VALUE);
1062 	ctx.endSection();
1063 
1064 	ctx.glDeleteTextures(1, &texture);
1065 }
1066 
copytexsubimage2d_neg_width_height(NegativeTestContext & ctx)1067 void copytexsubimage2d_neg_width_height (NegativeTestContext& ctx)
1068 {
1069 	GLuint texture = 0x1234;
1070 	ctx.glGenTextures	(1, &texture);
1071 	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
1072 	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1073 
1074 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
1075 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0);
1076 	ctx.expectError(GL_INVALID_VALUE);
1077 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1);
1078 	ctx.expectError(GL_INVALID_VALUE);
1079 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1);
1080 	ctx.expectError(GL_INVALID_VALUE);
1081 	ctx.endSection();
1082 
1083 	ctx.glDeleteTextures(1, &texture);
1084 }
1085 
copytexsubimage2d_incomplete_framebuffer(NegativeTestContext & ctx)1086 void copytexsubimage2d_incomplete_framebuffer (NegativeTestContext& ctx)
1087 {
1088 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1089 
1090 	GLuint texture[2];
1091 	GLuint fbo = 0x1234;
1092 
1093 	ctx.glGenTextures			(2, texture);
1094 	ctx.glBindTexture			(GL_TEXTURE_2D, texture[0]);
1095 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1096 	ctx.glBindTexture			(GL_TEXTURE_CUBE_MAP, texture[1]);
1097 	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1098 	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1099 	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1100 	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1101 	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1102 	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1103 	ctx.expectError(GL_NO_ERROR);
1104 
1105 	ctx.glGenFramebuffers(1, &fbo);
1106 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1107 	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1108 	ctx.expectError(GL_NO_ERROR);
1109 
1110 	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
1111 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1112 	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
1113 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1114 	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
1115 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1116 	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1117 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1118 	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
1119 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1120 	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
1121 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1122 	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
1123 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1124 
1125 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1126 	ctx.glDeleteFramebuffers(1, &fbo);
1127 	ctx.glDeleteTextures(2, texture);
1128 
1129 	ctx.endSection();
1130 }
1131 
1132 // glDeleteTextures
1133 
deletetextures(NegativeTestContext & ctx)1134 void deletetextures (NegativeTestContext& ctx)
1135 {
1136 	GLuint texture = 0x1234;
1137 	ctx.glGenTextures(1, &texture);
1138 
1139 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1140 	ctx.glDeleteTextures(-1, 0);
1141 	ctx.expectError(GL_INVALID_VALUE);
1142 
1143 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
1144 	ctx.glDeleteTextures(-1, 0);
1145 	ctx.expectError(GL_INVALID_VALUE);
1146 	ctx.endSection();
1147 
1148 	ctx.glDeleteTextures(1, &texture);
1149 }
1150 
1151 // glGenerateMipmap
1152 
generatemipmap(NegativeTestContext & ctx)1153 void generatemipmap (NegativeTestContext& ctx)
1154 {
1155 	GLuint texture[2];
1156 	ctx.glGenTextures(2, texture);
1157 
1158 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.");
1159 	ctx.glGenerateMipmap(0);
1160 	ctx.expectError(GL_INVALID_ENUM);
1161 	ctx.endSection();
1162 
1163 	ctx.beginSection("INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
1164 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1165 	ctx.glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
1166 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1167 	ctx.glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1168 	ctx.expectError(GL_INVALID_OPERATION);
1169 
1170 	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1171 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1172 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1173 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1174 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1175 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1176 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1177 	ctx.glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
1178 	ctx.expectError(GL_INVALID_OPERATION);
1179 	ctx.endSection();
1180 
1181 	ctx.beginSection("GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
1182 	ctx.glBindTexture(GL_TEXTURE_2D, texture[1]);
1183 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1184 	ctx.glGenerateMipmap(GL_TEXTURE_2D);
1185 	ctx.expectError(GL_INVALID_OPERATION);
1186 	ctx.endSection();
1187 
1188 	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.");
1189 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 0, 0, 0, GL_RGB, GL_BYTE, 0);
1190 	ctx.glGenerateMipmap(GL_TEXTURE_2D);
1191 	ctx.expectError(GL_INVALID_OPERATION);
1192 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, 0);
1193 	ctx.glGenerateMipmap(GL_TEXTURE_2D);
1194 	ctx.expectError(GL_INVALID_OPERATION);
1195 
1196 	if (!(ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") && ctx.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
1197 	{
1198 		ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
1199 		ctx.glGenerateMipmap(GL_TEXTURE_2D);
1200 		ctx.expectError(GL_INVALID_OPERATION);
1201 	}
1202 
1203 	ctx.endSection();
1204 
1205 	ctx.glDeleteTextures(2, texture);
1206 }
1207 
1208 // glGenTextures
1209 
gentextures(NegativeTestContext & ctx)1210 void gentextures (NegativeTestContext& ctx)
1211 {
1212 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1213 	ctx.glGenTextures(-1, 0);
1214 	ctx.expectError(GL_INVALID_VALUE);
1215 	ctx.endSection();
1216 }
1217 
1218 // glPixelStorei
1219 
pixelstorei(NegativeTestContext & ctx)1220 void pixelstorei (NegativeTestContext& ctx)
1221 {
1222 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1223 	ctx.glPixelStorei(0,1);
1224 	ctx.expectError(GL_INVALID_ENUM);
1225 	ctx.endSection();
1226 
1227 	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.");
1228 	ctx.glPixelStorei(GL_PACK_ROW_LENGTH, -1);
1229 	ctx.expectError(GL_INVALID_VALUE);
1230 	ctx.glPixelStorei(GL_PACK_SKIP_ROWS, -1);
1231 	ctx.expectError(GL_INVALID_VALUE);
1232 	ctx.glPixelStorei(GL_PACK_SKIP_PIXELS, -1);
1233 	ctx.expectError(GL_INVALID_VALUE);
1234 	ctx.glPixelStorei(GL_UNPACK_ROW_LENGTH, -1);
1235 	ctx.expectError(GL_INVALID_VALUE);
1236 	ctx.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, -1);
1237 	ctx.expectError(GL_INVALID_VALUE);
1238 	ctx.glPixelStorei(GL_UNPACK_SKIP_ROWS, -1);
1239 	ctx.expectError(GL_INVALID_VALUE);
1240 	ctx.glPixelStorei(GL_UNPACK_SKIP_PIXELS, -1);
1241 	ctx.expectError(GL_INVALID_VALUE);
1242 	ctx.glPixelStorei(GL_UNPACK_SKIP_IMAGES, -1);
1243 	ctx.expectError(GL_INVALID_VALUE);
1244 	ctx.glPixelStorei(GL_PACK_ALIGNMENT, 0);
1245 	ctx.expectError(GL_INVALID_VALUE);
1246 	ctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
1247 	ctx.expectError(GL_INVALID_VALUE);
1248 	ctx.glPixelStorei(GL_PACK_ALIGNMENT, 16);
1249 	ctx.expectError(GL_INVALID_VALUE);
1250 	ctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
1251 	ctx.expectError(GL_INVALID_VALUE);
1252 	ctx.endSection();
1253 }
1254 
1255 // glTexImage2D
1256 
teximage2d(NegativeTestContext & ctx)1257 void teximage2d (NegativeTestContext& ctx)
1258 {
1259 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
1260 	ctx.glTexImage2D(0, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1261 	ctx.expectError(GL_INVALID_ENUM);
1262 	ctx.endSection();
1263 
1264 	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
1265 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 0, 0);
1266 	ctx.expectError(GL_INVALID_ENUM);
1267 	ctx.endSection();
1268 
1269 	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
1270 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1271 	ctx.expectError(GL_INVALID_OPERATION);
1272 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1273 	ctx.expectError(GL_INVALID_OPERATION);
1274 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1275 	ctx.expectError(GL_INVALID_OPERATION);
1276 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
1277 	ctx.expectError(GL_INVALID_OPERATION);
1278 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
1279 	ctx.expectError(GL_INVALID_OPERATION);
1280 	ctx.endSection();
1281 }
1282 
teximage2d_inequal_width_height_cube(NegativeTestContext & ctx)1283 void teximage2d_inequal_width_height_cube (NegativeTestContext& ctx)
1284 {
1285 	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.");
1286 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1287 	ctx.expectError(GL_INVALID_VALUE);
1288 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1289 	ctx.expectError(GL_INVALID_VALUE);
1290 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1291 	ctx.expectError(GL_INVALID_VALUE);
1292 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1293 	ctx.expectError(GL_INVALID_VALUE);
1294 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 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, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1297 	ctx.expectError(GL_INVALID_VALUE);
1298 	ctx.endSection();
1299 }
1300 
teximage2d_neg_level(NegativeTestContext & ctx)1301 void teximage2d_neg_level (NegativeTestContext& ctx)
1302 {
1303 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
1304 	ctx.glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1305 	ctx.expectError(GL_INVALID_VALUE);
1306 	ctx.endSection();
1307 
1308 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
1309 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1310 	ctx.expectError(GL_INVALID_VALUE);
1311 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1312 	ctx.expectError(GL_INVALID_VALUE);
1313 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1314 	ctx.expectError(GL_INVALID_VALUE);
1315 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1316 	ctx.expectError(GL_INVALID_VALUE);
1317 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1318 	ctx.expectError(GL_INVALID_VALUE);
1319 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1320 	ctx.expectError(GL_INVALID_VALUE);
1321 	ctx.endSection();
1322 }
1323 
teximage2d_max_level(NegativeTestContext & ctx)1324 void teximage2d_max_level (NegativeTestContext& ctx)
1325 {
1326 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1327 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
1328 	ctx.glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1329 	ctx.expectError(GL_INVALID_VALUE);
1330 	ctx.endSection();
1331 
1332 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1333 	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1334 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1335 	ctx.expectError(GL_INVALID_VALUE);
1336 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1337 	ctx.expectError(GL_INVALID_VALUE);
1338 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1339 	ctx.expectError(GL_INVALID_VALUE);
1340 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1341 	ctx.expectError(GL_INVALID_VALUE);
1342 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1343 	ctx.expectError(GL_INVALID_VALUE);
1344 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1345 	ctx.expectError(GL_INVALID_VALUE);
1346 	ctx.endSection();
1347 }
1348 
teximage2d_neg_width_height(NegativeTestContext & ctx)1349 void teximage2d_neg_width_height (NegativeTestContext& ctx)
1350 {
1351 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
1352 
1353 	ctx.beginSection("GL_TEXTURE_2D target");
1354 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1355 	ctx.expectError(GL_INVALID_VALUE);
1356 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1357 	ctx.expectError(GL_INVALID_VALUE);
1358 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1359 	ctx.expectError(GL_INVALID_VALUE);
1360 	ctx.endSection();
1361 
1362 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1363 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1364 	ctx.expectError(GL_INVALID_VALUE);
1365 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1366 	ctx.expectError(GL_INVALID_VALUE);
1367 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1368 	ctx.expectError(GL_INVALID_VALUE);
1369 	ctx.endSection();
1370 
1371 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1372 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1373 	ctx.expectError(GL_INVALID_VALUE);
1374 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1375 	ctx.expectError(GL_INVALID_VALUE);
1376 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1377 	ctx.expectError(GL_INVALID_VALUE);
1378 	ctx.endSection();
1379 
1380 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1381 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1382 	ctx.expectError(GL_INVALID_VALUE);
1383 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1384 	ctx.expectError(GL_INVALID_VALUE);
1385 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1386 	ctx.expectError(GL_INVALID_VALUE);
1387 	ctx.endSection();
1388 
1389 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1390 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1391 	ctx.expectError(GL_INVALID_VALUE);
1392 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1393 	ctx.expectError(GL_INVALID_VALUE);
1394 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1395 	ctx.expectError(GL_INVALID_VALUE);
1396 	ctx.endSection();
1397 
1398 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1399 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1400 	ctx.expectError(GL_INVALID_VALUE);
1401 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1402 	ctx.expectError(GL_INVALID_VALUE);
1403 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1404 	ctx.expectError(GL_INVALID_VALUE);
1405 	ctx.endSection();
1406 
1407 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1408 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1409 	ctx.expectError(GL_INVALID_VALUE);
1410 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1411 	ctx.expectError(GL_INVALID_VALUE);
1412 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1413 	ctx.expectError(GL_INVALID_VALUE);
1414 	ctx.endSection();
1415 
1416 	ctx.endSection();
1417 }
1418 
teximage2d_max_width_height(NegativeTestContext & ctx)1419 void teximage2d_max_width_height (NegativeTestContext& ctx)
1420 {
1421 	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
1422 	int maxCubemapSize = ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
1423 
1424 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
1425 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1426 	ctx.expectError(GL_INVALID_VALUE);
1427 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1428 	ctx.expectError(GL_INVALID_VALUE);
1429 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1430 	ctx.expectError(GL_INVALID_VALUE);
1431 	ctx.endSection();
1432 
1433 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
1434 
1435 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
1436 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1437 	ctx.expectError(GL_INVALID_VALUE);
1438 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1439 	ctx.expectError(GL_INVALID_VALUE);
1440 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1441 	ctx.expectError(GL_INVALID_VALUE);
1442 	ctx.endSection();
1443 
1444 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
1445 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1446 	ctx.expectError(GL_INVALID_VALUE);
1447 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1448 	ctx.expectError(GL_INVALID_VALUE);
1449 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1450 	ctx.expectError(GL_INVALID_VALUE);
1451 	ctx.endSection();
1452 
1453 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
1454 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1455 	ctx.expectError(GL_INVALID_VALUE);
1456 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1457 	ctx.expectError(GL_INVALID_VALUE);
1458 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1459 	ctx.expectError(GL_INVALID_VALUE);
1460 	ctx.endSection();
1461 
1462 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
1463 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1464 	ctx.expectError(GL_INVALID_VALUE);
1465 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1466 	ctx.expectError(GL_INVALID_VALUE);
1467 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1468 	ctx.expectError(GL_INVALID_VALUE);
1469 	ctx.endSection();
1470 
1471 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
1472 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1473 	ctx.expectError(GL_INVALID_VALUE);
1474 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1475 	ctx.expectError(GL_INVALID_VALUE);
1476 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1477 	ctx.expectError(GL_INVALID_VALUE);
1478 	ctx.endSection();
1479 
1480 	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
1481 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1482 	ctx.expectError(GL_INVALID_VALUE);
1483 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1484 	ctx.expectError(GL_INVALID_VALUE);
1485 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1486 	ctx.expectError(GL_INVALID_VALUE);
1487 	ctx.endSection();
1488 
1489 	ctx.endSection();
1490 }
1491 
teximage2d_invalid_border(NegativeTestContext & ctx)1492 void teximage2d_invalid_border (NegativeTestContext& ctx)
1493 {
1494 	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
1495 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1496 	ctx.expectError(GL_INVALID_VALUE);
1497 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1498 	ctx.expectError(GL_INVALID_VALUE);
1499 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1500 	ctx.expectError(GL_INVALID_VALUE);
1501 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1502 	ctx.expectError(GL_INVALID_VALUE);
1503 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1504 	ctx.expectError(GL_INVALID_VALUE);
1505 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1506 	ctx.expectError(GL_INVALID_VALUE);
1507 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1508 	ctx.expectError(GL_INVALID_VALUE);
1509 	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
1510 	ctx.expectError(GL_INVALID_VALUE);
1511 	ctx.endSection();
1512 }
1513 
teximage2d_invalid_buffer_target(NegativeTestContext & ctx)1514 void teximage2d_invalid_buffer_target (NegativeTestContext& ctx)
1515 {
1516 	deUint32				buf = 0x1234;
1517 	deUint32				texture = 0x1234;
1518 	std::vector<GLubyte>	data(64);
1519 
1520 	ctx.glGenBuffers			(1, &buf);
1521 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
1522 	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1523 	ctx.glGenTextures			(1, &texture);
1524 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
1525 	ctx.expectError				(GL_NO_ERROR);
1526 
1527 	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
1528 	ctx.beginSection("...the buffer object's data store is currently mapped.");
1529 	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1530 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1531 	ctx.expectError				(GL_INVALID_OPERATION);
1532 	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
1533 	ctx.endSection();
1534 
1535 	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
1536 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1537 	ctx.expectError				(GL_INVALID_OPERATION);
1538 	ctx.endSection();
1539 
1540 	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1541 	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1542 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGB5_A1, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
1543 	ctx.expectError				(GL_INVALID_OPERATION);
1544 	ctx.endSection();
1545 	ctx.endSection();
1546 
1547 	ctx.glDeleteBuffers			(1, &buf);
1548 	ctx.glDeleteTextures		(1, &texture);
1549 }
1550 
1551 // glTexSubImage2D
1552 
texsubimage2d(NegativeTestContext & ctx)1553 void texsubimage2d (NegativeTestContext& ctx)
1554 {
1555 	deUint32			texture = 0x1234;
1556 	ctx.glGenTextures		(1, &texture);
1557 	ctx.glBindTexture		(GL_TEXTURE_2D, texture);
1558 	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1559 	ctx.expectError			(GL_NO_ERROR);
1560 
1561 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
1562 	ctx.glTexSubImage2D(0, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1563 	ctx.expectError(GL_INVALID_ENUM);
1564 	ctx.endSection();
1565 
1566 	ctx.beginSection("GL_INVALID_ENUM is generated if format is not an accepted format constant.");
1567 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, GL_UNSIGNED_BYTE, 0);
1568 	ctx.expectError(GL_INVALID_ENUM);
1569 	ctx.endSection();
1570 
1571 	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
1572 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, 0, 0);
1573 	ctx.expectError(GL_INVALID_ENUM);
1574 	ctx.endSection();
1575 
1576 	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.");
1577 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
1578 	ctx.expectError(GL_INVALID_OPERATION);
1579 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1580 	ctx.expectError(GL_INVALID_OPERATION);
1581 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1582 	ctx.expectError(GL_INVALID_OPERATION);
1583 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
1584 	ctx.expectError(GL_INVALID_OPERATION);
1585 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
1586 	ctx.expectError(GL_INVALID_OPERATION);
1587 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_FLOAT, 0);
1588 	ctx.expectError(GL_INVALID_OPERATION);
1589 	ctx.endSection();
1590 
1591 	ctx.glDeleteTextures	(1, &texture);
1592 }
1593 
texsubimage2d_neg_level(NegativeTestContext & ctx)1594 void texsubimage2d_neg_level (NegativeTestContext& ctx)
1595 {
1596 	deUint32			textures[2];
1597 	ctx.glGenTextures		(2, &textures[0]);
1598 	ctx.glBindTexture		(GL_TEXTURE_2D, textures[0]);
1599 	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1600 	ctx.glBindTexture		(GL_TEXTURE_2D, textures[1]);
1601 	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1602 	ctx.expectError			(GL_NO_ERROR);
1603 
1604 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
1605 	ctx.glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1606 	ctx.expectError(GL_INVALID_VALUE);
1607 	ctx.endSection();
1608 
1609 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
1610 	FOR_CUBE_FACES(faceGL,
1611 	{
1612 		ctx.glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1613 		ctx.expectError(GL_INVALID_VALUE);
1614 	});
1615 	ctx.endSection();
1616 
1617 	ctx.glDeleteTextures(2, &textures[0]);
1618 }
1619 
texsubimage2d_max_level(NegativeTestContext & ctx)1620 void texsubimage2d_max_level (NegativeTestContext& ctx)
1621 {
1622 	deUint32			textures[2];
1623 	ctx.glGenTextures		(2, &textures[0]);
1624 	ctx.glBindTexture		(GL_TEXTURE_2D, textures[0]);
1625 	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1626 	ctx.glBindTexture		(GL_TEXTURE_CUBE_MAP, textures[1]);
1627 	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
1628 	ctx.expectError			(GL_NO_ERROR);
1629 
1630 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
1631 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
1632 	ctx.glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1633 	ctx.expectError(GL_INVALID_VALUE);
1634 	ctx.endSection();
1635 
1636 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
1637 	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
1638 	FOR_CUBE_FACES(faceGL,
1639 	{
1640 		ctx.glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1641 		ctx.expectError(GL_INVALID_VALUE);
1642 	});
1643 	ctx.endSection();
1644 
1645 	ctx.glDeleteTextures(2, &textures[0]);
1646 }
1647 
texsubimage2d_neg_offset(NegativeTestContext & ctx)1648 void texsubimage2d_neg_offset (NegativeTestContext& ctx)
1649 {
1650 	deUint32 texture = 0x1234;
1651 	ctx.glGenTextures(1, &texture);
1652 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
1653 	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1654 	ctx.expectError(GL_NO_ERROR);
1655 
1656 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
1657 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1658 	ctx.expectError(GL_INVALID_VALUE);
1659 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1660 	ctx.expectError(GL_INVALID_VALUE);
1661 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
1662 	ctx.expectError(GL_INVALID_VALUE);
1663 	ctx.endSection();
1664 
1665 	ctx.glDeleteTextures(1, &texture);
1666 }
1667 
texsubimage2d_invalid_offset(NegativeTestContext & ctx)1668 void texsubimage2d_invalid_offset (NegativeTestContext& ctx)
1669 {
1670 	deUint32			texture = 0x1234;
1671 	ctx.glGenTextures		(1, &texture);
1672 	ctx.glBindTexture		(GL_TEXTURE_2D, texture);
1673 	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1674 	ctx.expectError			(GL_NO_ERROR);
1675 
1676 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
1677 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1678 	ctx.expectError(GL_INVALID_VALUE);
1679 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1680 	ctx.expectError(GL_INVALID_VALUE);
1681 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1682 	ctx.expectError(GL_INVALID_VALUE);
1683 	ctx.endSection();
1684 
1685 	ctx.glDeleteTextures	(1, &texture);
1686 }
1687 
texsubimage2d_neg_width_height(NegativeTestContext & ctx)1688 void texsubimage2d_neg_width_height (NegativeTestContext& ctx)
1689 {
1690 	deUint32			texture = 0x1234;
1691 	ctx.glGenTextures		(1, &texture);
1692 	ctx.glBindTexture		(GL_TEXTURE_2D, texture);
1693 	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1694 	ctx.expectError			(GL_NO_ERROR);
1695 
1696 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
1697 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1698 	ctx.expectError(GL_INVALID_VALUE);
1699 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1700 	ctx.expectError(GL_INVALID_VALUE);
1701 	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1702 	ctx.expectError(GL_INVALID_VALUE);
1703 	ctx.endSection();
1704 
1705 	ctx.glDeleteTextures	(1, &texture);
1706 }
1707 
texsubimage2d_invalid_buffer_target(NegativeTestContext & ctx)1708 void texsubimage2d_invalid_buffer_target (NegativeTestContext& ctx)
1709 {
1710 	deUint32				buf = 0x1234;
1711 	deUint32				texture = 0x1234;
1712 	std::vector<GLubyte>	data(64);
1713 
1714 	ctx.glGenTextures			(1, &texture);
1715 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
1716 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1717 	ctx.glGenBuffers			(1, &buf);
1718 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
1719 	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
1720 	ctx.expectError				(GL_NO_ERROR);
1721 
1722 	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
1723 	ctx.beginSection("...the buffer object's data store is currently mapped.");
1724 	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
1725 	ctx.glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1726 	ctx.expectError				(GL_INVALID_OPERATION);
1727 	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
1728 	ctx.endSection();
1729 
1730 	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
1731 	ctx.glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1732 	ctx.expectError				(GL_INVALID_OPERATION);
1733 	ctx.endSection();
1734 
1735 	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
1736 	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
1737 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, 0);
1738 	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
1739 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
1740 	ctx.expectError				(GL_NO_ERROR);
1741 	ctx.glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
1742 	ctx.expectError				(GL_INVALID_OPERATION);
1743 	ctx.endSection();
1744 	ctx.endSection();
1745 
1746 	ctx.glDeleteBuffers			(1, &buf);
1747 	ctx.glDeleteTextures		(1, &texture);
1748 }
1749 
1750 // glTexParameteri
1751 
texparameteri(NegativeTestContext & ctx)1752 void texparameteri (NegativeTestContext& ctx)
1753 {
1754 	GLuint texture = 0x1234;
1755 	GLint textureMode = -1;
1756 
1757 	ctx.glGenTextures(1, &texture);
1758 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
1759 
1760 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1761 	ctx.glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1762 	ctx.expectError(GL_INVALID_ENUM);
1763 	ctx.glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
1764 	ctx.expectError(GL_INVALID_ENUM);
1765 	ctx.glTexParameteri(0, 0, GL_LINEAR);
1766 	ctx.expectError(GL_INVALID_ENUM);
1767 	ctx.endSection();
1768 
1769 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
1770 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
1771 	ctx.expectError(GL_INVALID_ENUM);
1772 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
1773 	ctx.expectError(GL_INVALID_ENUM);
1774 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
1775 	ctx.expectError(GL_INVALID_ENUM);
1776 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
1777 	ctx.expectError(GL_INVALID_ENUM);
1778 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
1779 	ctx.expectError(GL_INVALID_ENUM);
1780 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
1781 	ctx.expectError(GL_INVALID_ENUM);
1782 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
1783 	ctx.expectError(GL_INVALID_ENUM);
1784 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
1785 	ctx.expectError(GL_INVALID_ENUM);
1786 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
1787 	ctx.expectError(GL_INVALID_ENUM);
1788 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
1789 	ctx.expectError(GL_INVALID_ENUM);
1790 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
1791 	ctx.expectError(GL_INVALID_ENUM);
1792 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
1793 	ctx.expectError(GL_INVALID_ENUM);
1794 	ctx.endSection();
1795 
1796 	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
1797 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, -1);
1798 	ctx.expectError(GL_INVALID_VALUE);
1799 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, -1);
1800 	ctx.expectError(GL_INVALID_VALUE);
1801 	ctx.endSection();
1802 
1803 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1804 	{
1805 		ctx.beginSection("GL_INVALID_ENUM is generated if pname is a non-scalar parameter.");
1806 		ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, 0);
1807 		ctx.expectError(GL_INVALID_ENUM);
1808 		ctx.endSection();
1809 	}
1810 
1811 	ctx.beginSection("GL_INVALID_ENUM error is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname is not valid.");
1812 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
1813 	ctx.expectError(GL_INVALID_ENUM);
1814 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
1815 	ctx.expectError(GL_INVALID_ENUM);
1816 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
1817 	ctx.expectError(GL_INVALID_ENUM);
1818 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
1819 	ctx.expectError(GL_INVALID_ENUM);
1820 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
1821 	ctx.expectError(GL_INVALID_ENUM);
1822 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
1823 	ctx.expectError(GL_INVALID_ENUM);
1824 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
1825 	ctx.expectError(GL_INVALID_ENUM);
1826 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
1827 	ctx.expectError(GL_INVALID_ENUM);
1828 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
1829 	ctx.expectError(GL_INVALID_ENUM);
1830 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
1831 	ctx.expectError(GL_INVALID_ENUM);
1832 
1833 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1834 	{
1835 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
1836 		ctx.expectError(GL_INVALID_ENUM);
1837 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
1838 		ctx.expectError(GL_INVALID_ENUM);
1839 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
1840 		ctx.expectError(GL_INVALID_ENUM);
1841 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
1842 		ctx.expectError(GL_INVALID_ENUM);
1843 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
1844 		ctx.expectError(GL_INVALID_ENUM);
1845 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
1846 		ctx.expectError(GL_INVALID_ENUM);
1847 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
1848 		ctx.expectError(GL_INVALID_ENUM);
1849 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
1850 		ctx.expectError(GL_INVALID_ENUM);
1851 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
1852 		ctx.expectError(GL_INVALID_ENUM);
1853 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
1854 		ctx.expectError(GL_INVALID_ENUM);
1855 	}
1856 	ctx.endSection();
1857 
1858 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname GL_TEXTURE_BASE_LEVEL is not 0.");
1859 	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, 1);
1860 	ctx.expectError(GL_INVALID_OPERATION);
1861 
1862 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1863 	{
1864 		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, 1);
1865 		ctx.expectError(GL_INVALID_OPERATION);
1866 	}
1867 	ctx.endSection();
1868 
1869 	ctx.glDeleteTextures(1, &texture);
1870 }
1871 
1872 // glTexParameterf
1873 
texparameterf(NegativeTestContext & ctx)1874 void texparameterf (NegativeTestContext& ctx)
1875 {
1876 	GLuint texture = 0x1234;
1877 	GLfloat textureMode = -1.0f;
1878 	ctx.glGenTextures(1, &texture);
1879 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
1880 
1881 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
1882 	ctx.glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1883 	ctx.expectError(GL_INVALID_ENUM);
1884 	ctx.glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
1885 	ctx.expectError(GL_INVALID_ENUM);
1886 	ctx.glTexParameterf(0, 0, GL_LINEAR);
1887 	ctx.expectError(GL_INVALID_ENUM);
1888 	ctx.endSection();
1889 
1890 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
1891 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
1892 	ctx.expectError(GL_INVALID_ENUM);
1893 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
1894 	ctx.expectError(GL_INVALID_ENUM);
1895 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
1896 	ctx.expectError(GL_INVALID_ENUM);
1897 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
1898 	ctx.expectError(GL_INVALID_ENUM);
1899 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
1900 	ctx.expectError(GL_INVALID_ENUM);
1901 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
1902 	ctx.expectError(GL_INVALID_ENUM);
1903 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
1904 	ctx.expectError(GL_INVALID_ENUM);
1905 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
1906 	ctx.expectError(GL_INVALID_ENUM);
1907 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
1908 	ctx.expectError(GL_INVALID_ENUM);
1909 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
1910 	ctx.expectError(GL_INVALID_ENUM);
1911 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
1912 	ctx.expectError(GL_INVALID_ENUM);
1913 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
1914 	ctx.expectError(GL_INVALID_ENUM);
1915 	ctx.endSection();
1916 
1917 	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
1918 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, -1.0f);
1919 	ctx.expectError(GL_INVALID_VALUE);
1920 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, -1.0f);
1921 	ctx.expectError(GL_INVALID_VALUE);
1922 	ctx.endSection();
1923 
1924 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1925 	{
1926 		ctx.beginSection("GL_INVALID_ENUM is generated if pname is a non-scalar parameter.");
1927 		ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, 0.0f);
1928 		ctx.expectError(GL_INVALID_ENUM);
1929 		ctx.endSection();
1930 	}
1931 
1932 	ctx.beginSection("GL_INVALID_ENUM error is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname is not valid.");
1933 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
1934 	ctx.expectError(GL_INVALID_ENUM);
1935 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
1936 	ctx.expectError(GL_INVALID_ENUM);
1937 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
1938 	ctx.expectError(GL_INVALID_ENUM);
1939 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
1940 	ctx.expectError(GL_INVALID_ENUM);
1941 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
1942 	ctx.expectError(GL_INVALID_ENUM);
1943 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
1944 	ctx.expectError(GL_INVALID_ENUM);
1945 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
1946 	ctx.expectError(GL_INVALID_ENUM);
1947 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
1948 	ctx.expectError(GL_INVALID_ENUM);
1949 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
1950 	ctx.expectError(GL_INVALID_ENUM);
1951 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
1952 	ctx.expectError(GL_INVALID_ENUM);
1953 
1954 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1955 	{
1956 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
1957 		ctx.expectError(GL_INVALID_ENUM);
1958 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
1959 		ctx.expectError(GL_INVALID_ENUM);
1960 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
1961 		ctx.expectError(GL_INVALID_ENUM);
1962 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
1963 		ctx.expectError(GL_INVALID_ENUM);
1964 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
1965 		ctx.expectError(GL_INVALID_ENUM);
1966 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
1967 		ctx.expectError(GL_INVALID_ENUM);
1968 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
1969 		ctx.expectError(GL_INVALID_ENUM);
1970 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
1971 		ctx.expectError(GL_INVALID_ENUM);
1972 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
1973 		ctx.expectError(GL_INVALID_ENUM);
1974 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
1975 		ctx.expectError(GL_INVALID_ENUM);
1976 	}
1977 	ctx.endSection();
1978 
1979 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname GL_TEXTURE_BASE_LEVEL is not 0.");
1980 	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, 1.0f);
1981 	ctx.expectError(GL_INVALID_OPERATION);
1982 
1983 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1984 	{
1985 		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, 1.0f);
1986 		ctx.expectError(GL_INVALID_OPERATION);
1987 	}
1988 	ctx.endSection();
1989 
1990 	ctx.glDeleteTextures(1, &texture);
1991 }
1992 
1993 // glTexParameteriv
1994 
texparameteriv(NegativeTestContext & ctx)1995 void texparameteriv (NegativeTestContext& ctx)
1996 {
1997 	GLint params[1] = {GL_LINEAR};
1998 
1999 	GLuint texture = 0x1234;
2000 	ctx.glGenTextures(1, &texture);
2001 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
2002 
2003 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
2004 	ctx.glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
2005 	ctx.expectError(GL_INVALID_ENUM);
2006 	ctx.glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
2007 	ctx.expectError(GL_INVALID_ENUM);
2008 	ctx.glTexParameteriv(0, 0, &params[0]);
2009 	ctx.expectError(GL_INVALID_ENUM);
2010 	ctx.endSection();
2011 
2012 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2013 	params[0] = -1;
2014 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &params[0]);
2015 	ctx.expectError(GL_INVALID_ENUM);
2016 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, &params[0]);
2017 	ctx.expectError(GL_INVALID_ENUM);
2018 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2019 	ctx.expectError(GL_INVALID_ENUM);
2020 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
2021 	ctx.expectError(GL_INVALID_ENUM);
2022 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
2023 	ctx.expectError(GL_INVALID_ENUM);
2024 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, &params[0]);
2025 	ctx.expectError(GL_INVALID_ENUM);
2026 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, &params[0]);
2027 	ctx.expectError(GL_INVALID_ENUM);
2028 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, &params[0]);
2029 	ctx.expectError(GL_INVALID_ENUM);
2030 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, &params[0]);
2031 	ctx.expectError(GL_INVALID_ENUM);
2032 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
2033 	ctx.expectError(GL_INVALID_ENUM);
2034 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
2035 	ctx.expectError(GL_INVALID_ENUM);
2036 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, &params[0]);
2037 	ctx.expectError(GL_INVALID_ENUM);
2038 	ctx.endSection();
2039 
2040 	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
2041 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &params[0]);
2042 	ctx.expectError(GL_INVALID_VALUE);
2043 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &params[0]);
2044 	ctx.expectError(GL_INVALID_VALUE);
2045 	ctx.endSection();
2046 
2047 	ctx.beginSection("GL_INVALID_ENUM error is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname is not valid.");
2048 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, &params[0]);
2049 	ctx.expectError(GL_INVALID_ENUM);
2050 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, &params[0]);
2051 	ctx.expectError(GL_INVALID_ENUM);
2052 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, &params[0]);
2053 	ctx.expectError(GL_INVALID_ENUM);
2054 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, &params[0]);
2055 	ctx.expectError(GL_INVALID_ENUM);
2056 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, &params[0]);
2057 	ctx.expectError(GL_INVALID_ENUM);
2058 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, &params[0]);
2059 	ctx.expectError(GL_INVALID_ENUM);
2060 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, &params[0]);
2061 	ctx.expectError(GL_INVALID_ENUM);
2062 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, &params[0]);
2063 	ctx.expectError(GL_INVALID_ENUM);
2064 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, &params[0]);
2065 	ctx.expectError(GL_INVALID_ENUM);
2066 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2067 	ctx.expectError(GL_INVALID_ENUM);
2068 
2069 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2070 	{
2071 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, &params[0]);
2072 		ctx.expectError(GL_INVALID_ENUM);
2073 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, &params[0]);
2074 		ctx.expectError(GL_INVALID_ENUM);
2075 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, &params[0]);
2076 		ctx.expectError(GL_INVALID_ENUM);
2077 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, &params[0]);
2078 		ctx.expectError(GL_INVALID_ENUM);
2079 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, &params[0]);
2080 		ctx.expectError(GL_INVALID_ENUM);
2081 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, &params[0]);
2082 		ctx.expectError(GL_INVALID_ENUM);
2083 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, &params[0]);
2084 		ctx.expectError(GL_INVALID_ENUM);
2085 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, &params[0]);
2086 		ctx.expectError(GL_INVALID_ENUM);
2087 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, &params[0]);
2088 		ctx.expectError(GL_INVALID_ENUM);
2089 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2090 		ctx.expectError(GL_INVALID_ENUM);
2091 	}
2092 	ctx.endSection();
2093 
2094 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname GL_TEXTURE_BASE_LEVEL is not 0.");
2095 	params[0] = 1;
2096 	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, &params[0]);
2097 	ctx.expectError(GL_INVALID_OPERATION);
2098 
2099 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2100 	{
2101 		params[0] = 1;
2102 		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, &params[0]);
2103 		ctx.expectError(GL_INVALID_OPERATION);
2104 	}
2105 	ctx.endSection();
2106 
2107 	ctx.glDeleteTextures(1, &texture);
2108 }
2109 
2110 // glTexParameterfv
2111 
texparameterfv(NegativeTestContext & ctx)2112 void texparameterfv (NegativeTestContext& ctx)
2113 {
2114 	GLfloat params[1] = {GL_LINEAR};
2115 	GLuint texture = 0x1234;
2116 	ctx.glGenTextures(1, &texture);
2117 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
2118 
2119 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
2120 	params[0] = GL_LINEAR;
2121 	ctx.glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
2122 	ctx.expectError(GL_INVALID_ENUM);
2123 	ctx.glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
2124 	ctx.expectError(GL_INVALID_ENUM);
2125 	ctx.glTexParameterfv(0, 0, &params[0]);
2126 	ctx.expectError(GL_INVALID_ENUM);
2127 	ctx.endSection();
2128 
2129 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2130 	params[0] = -1.0f;
2131 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &params[0]);
2132 	ctx.expectError(GL_INVALID_ENUM);
2133 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, &params[0]);
2134 	ctx.expectError(GL_INVALID_ENUM);
2135 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2136 	ctx.expectError(GL_INVALID_ENUM);
2137 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
2138 	ctx.expectError(GL_INVALID_ENUM);
2139 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
2140 	ctx.expectError(GL_INVALID_ENUM);
2141 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, &params[0]);
2142 	ctx.expectError(GL_INVALID_ENUM);
2143 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, &params[0]);
2144 	ctx.expectError(GL_INVALID_ENUM);
2145 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, &params[0]);
2146 	ctx.expectError(GL_INVALID_ENUM);
2147 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, &params[0]);
2148 	ctx.expectError(GL_INVALID_ENUM);
2149 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
2150 	ctx.expectError(GL_INVALID_ENUM);
2151 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
2152 	ctx.expectError(GL_INVALID_ENUM);
2153 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, &params[0]);
2154 	ctx.expectError(GL_INVALID_ENUM);
2155 	ctx.endSection();
2156 
2157 	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
2158 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &params[0]);
2159 	ctx.expectError(GL_INVALID_VALUE);
2160 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &params[0]);
2161 	ctx.expectError(GL_INVALID_VALUE);
2162 	ctx.endSection();
2163 
2164 	ctx.beginSection("GL_INVALID_ENUM error is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname is not valid.");
2165 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, &params[0]);
2166 	ctx.expectError(GL_INVALID_ENUM);
2167 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, &params[0]);
2168 	ctx.expectError(GL_INVALID_ENUM);
2169 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, &params[0]);
2170 	ctx.expectError(GL_INVALID_ENUM);
2171 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, &params[0]);
2172 	ctx.expectError(GL_INVALID_ENUM);
2173 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, &params[0]);
2174 	ctx.expectError(GL_INVALID_ENUM);
2175 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, &params[0]);
2176 	ctx.expectError(GL_INVALID_ENUM);
2177 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, &params[0]);
2178 	ctx.expectError(GL_INVALID_ENUM);
2179 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, &params[0]);
2180 	ctx.expectError(GL_INVALID_ENUM);
2181 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, &params[0]);
2182 	ctx.expectError(GL_INVALID_ENUM);
2183 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2184 	ctx.expectError(GL_INVALID_ENUM);
2185 
2186 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2187 	{
2188 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, &params[0]);
2189 		ctx.expectError(GL_INVALID_ENUM);
2190 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, &params[0]);
2191 		ctx.expectError(GL_INVALID_ENUM);
2192 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, &params[0]);
2193 		ctx.expectError(GL_INVALID_ENUM);
2194 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, &params[0]);
2195 		ctx.expectError(GL_INVALID_ENUM);
2196 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, &params[0]);
2197 		ctx.expectError(GL_INVALID_ENUM);
2198 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, &params[0]);
2199 		ctx.expectError(GL_INVALID_ENUM);
2200 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, &params[0]);
2201 		ctx.expectError(GL_INVALID_ENUM);
2202 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, &params[0]);
2203 		ctx.expectError(GL_INVALID_ENUM);
2204 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, &params[0]);
2205 		ctx.expectError(GL_INVALID_ENUM);
2206 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2207 		ctx.expectError(GL_INVALID_ENUM);
2208 	}
2209 	ctx.endSection();
2210 
2211 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname GL_TEXTURE_BASE_LEVEL is not 0.");
2212 	params[0] = 1.0f;
2213 	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, &params[0]);
2214 	ctx.expectError(GL_INVALID_OPERATION);
2215 
2216 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2217 	{
2218 		params[0] = 1.0f;
2219 		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, &params[0]);
2220 		ctx.expectError(GL_INVALID_OPERATION);
2221 	}
2222 	ctx.endSection();
2223 
2224 	ctx.glDeleteTextures(1, &texture);
2225 }
2226 
2227 // glTexParameterIiv
2228 
texparameterIiv(NegativeTestContext & ctx)2229 void texparameterIiv (NegativeTestContext& ctx)
2230 {
2231 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
2232 		throw tcu::NotSupportedError("glTexParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
2233 
2234 	GLint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
2235 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not a valid target.");
2236 	ctx.glTexParameterIiv(0, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2237 	ctx.expectError(GL_INVALID_ENUM);
2238 	ctx.endSection();
2239 
2240 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not a valid parameter.");
2241 	ctx.glTexParameterIiv(GL_TEXTURE_2D, 0, textureMode);
2242 	ctx.expectError(GL_INVALID_ENUM);
2243 	ctx.endSection();
2244 
2245 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2246 	textureMode[0] = -1;
2247 	textureMode[1] = -1;
2248 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2249 	ctx.expectError(GL_INVALID_ENUM);
2250 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
2251 	ctx.expectError(GL_INVALID_ENUM);
2252 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
2253 	ctx.expectError(GL_INVALID_ENUM);
2254 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
2255 	ctx.expectError(GL_INVALID_ENUM);
2256 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
2257 	ctx.expectError(GL_INVALID_ENUM);
2258 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
2259 	ctx.expectError(GL_INVALID_ENUM);
2260 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
2261 	ctx.expectError(GL_INVALID_ENUM);
2262 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
2263 	ctx.expectError(GL_INVALID_ENUM);
2264 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
2265 	ctx.expectError(GL_INVALID_ENUM);
2266 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
2267 	ctx.expectError(GL_INVALID_ENUM);
2268 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
2269 	ctx.expectError(GL_INVALID_ENUM);
2270 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
2271 	ctx.expectError(GL_INVALID_ENUM);
2272 	ctx.endSection();
2273 
2274 	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
2275 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, textureMode);
2276 	ctx.expectError(GL_INVALID_VALUE);
2277 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, textureMode);
2278 	ctx.expectError(GL_INVALID_VALUE);
2279 	ctx.endSection();
2280 
2281 	ctx.beginSection("GL_INVALID_ENUM error is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname is not valid.");
2282 	textureMode[0] = 0;
2283 	textureMode[1] = 0;
2284 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
2285 	ctx.expectError(GL_INVALID_ENUM);
2286 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
2287 	ctx.expectError(GL_INVALID_ENUM);
2288 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
2289 	ctx.expectError(GL_INVALID_ENUM);
2290 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
2291 	ctx.expectError(GL_INVALID_ENUM);
2292 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
2293 	ctx.expectError(GL_INVALID_ENUM);
2294 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
2295 	ctx.expectError(GL_INVALID_ENUM);
2296 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
2297 	ctx.expectError(GL_INVALID_ENUM);
2298 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
2299 	ctx.expectError(GL_INVALID_ENUM);
2300 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
2301 	ctx.expectError(GL_INVALID_ENUM);
2302 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
2303 	ctx.expectError(GL_INVALID_ENUM);
2304 
2305 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
2306 	ctx.expectError(GL_INVALID_ENUM);
2307 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
2308 	ctx.expectError(GL_INVALID_ENUM);
2309 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
2310 	ctx.expectError(GL_INVALID_ENUM);
2311 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
2312 	ctx.expectError(GL_INVALID_ENUM);
2313 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
2314 	ctx.expectError(GL_INVALID_ENUM);
2315 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
2316 	ctx.expectError(GL_INVALID_ENUM);
2317 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
2318 	ctx.expectError(GL_INVALID_ENUM);
2319 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
2320 	ctx.expectError(GL_INVALID_ENUM);
2321 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
2322 	ctx.expectError(GL_INVALID_ENUM);
2323 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
2324 	ctx.expectError(GL_INVALID_ENUM);
2325 	ctx.endSection();
2326 
2327 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname GL_TEXTURE_BASE_LEVEL is not 0.");
2328 	textureMode[0] = 1;
2329 	textureMode[1] = 1;
2330 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, textureMode);
2331 	ctx.expectError(GL_INVALID_OPERATION);
2332 	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, textureMode);
2333 	ctx.expectError(GL_INVALID_OPERATION);
2334 	ctx.endSection();
2335 }
2336 
2337 // glTexParameterIuiv
2338 
texparameterIuiv(NegativeTestContext & ctx)2339 void texparameterIuiv (NegativeTestContext& ctx)
2340 {
2341 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
2342 		throw tcu::NotSupportedError("glTexParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
2343 
2344 	GLuint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
2345 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not a valid target.");
2346 	ctx.glTexParameterIuiv(0, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2347 	ctx.expectError(GL_INVALID_ENUM);
2348 	ctx.endSection();
2349 
2350 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not a valid parameter.");
2351 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, 0, textureMode);
2352 	ctx.expectError(GL_INVALID_ENUM);
2353 	ctx.endSection();
2354 
2355 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2356 	textureMode[0] = GL_DONT_CARE;
2357 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2358 	ctx.expectError(GL_INVALID_ENUM);
2359 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
2360 	ctx.expectError(GL_INVALID_ENUM);
2361 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
2362 	ctx.expectError(GL_INVALID_ENUM);
2363 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
2364 	ctx.expectError(GL_INVALID_ENUM);
2365 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
2366 	ctx.expectError(GL_INVALID_ENUM);
2367 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
2368 	ctx.expectError(GL_INVALID_ENUM);
2369 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
2370 	ctx.expectError(GL_INVALID_ENUM);
2371 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
2372 	ctx.expectError(GL_INVALID_ENUM);
2373 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
2374 	ctx.expectError(GL_INVALID_ENUM);
2375 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
2376 	ctx.expectError(GL_INVALID_ENUM);
2377 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
2378 	ctx.expectError(GL_INVALID_ENUM);
2379 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
2380 	ctx.expectError(GL_INVALID_ENUM);
2381 	ctx.endSection();
2382 
2383 	ctx.beginSection("GL_INVALID_ENUM error is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname is not valid.");
2384 	textureMode[0] = 0;
2385 	textureMode[1] = 0;
2386 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
2387 	ctx.expectError(GL_INVALID_ENUM);
2388 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
2389 	ctx.expectError(GL_INVALID_ENUM);
2390 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
2391 	ctx.expectError(GL_INVALID_ENUM);
2392 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
2393 	ctx.expectError(GL_INVALID_ENUM);
2394 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
2395 	ctx.expectError(GL_INVALID_ENUM);
2396 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
2397 	ctx.expectError(GL_INVALID_ENUM);
2398 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
2399 	ctx.expectError(GL_INVALID_ENUM);
2400 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
2401 	ctx.expectError(GL_INVALID_ENUM);
2402 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
2403 	ctx.expectError(GL_INVALID_ENUM);
2404 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
2405 	ctx.expectError(GL_INVALID_ENUM);
2406 
2407 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
2408 	ctx.expectError(GL_INVALID_ENUM);
2409 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
2410 	ctx.expectError(GL_INVALID_ENUM);
2411 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
2412 	ctx.expectError(GL_INVALID_ENUM);
2413 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
2414 	ctx.expectError(GL_INVALID_ENUM);
2415 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
2416 	ctx.expectError(GL_INVALID_ENUM);
2417 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
2418 	ctx.expectError(GL_INVALID_ENUM);
2419 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
2420 	ctx.expectError(GL_INVALID_ENUM);
2421 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
2422 	ctx.expectError(GL_INVALID_ENUM);
2423 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
2424 	ctx.expectError(GL_INVALID_ENUM);
2425 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
2426 	ctx.expectError(GL_INVALID_ENUM);
2427 	ctx.endSection();
2428 
2429 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_MULTISAMPLE or GL_TEXTURE_2D_MULTISAMPLE_ARRAY and pname GL_TEXTURE_BASE_LEVEL is not 0.");
2430 	textureMode[0] = 1;
2431 	textureMode[1] = 1;
2432 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, textureMode);
2433 	ctx.expectError(GL_INVALID_OPERATION);
2434 	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, textureMode);
2435 	ctx.expectError(GL_INVALID_OPERATION);
2436 	ctx.endSection();
2437 }
2438 
2439 // glCompressedTexSubImage2D
2440 
compressedtexsubimage2d(NegativeTestContext & ctx)2441 void compressedtexsubimage2d (NegativeTestContext& ctx)
2442 {
2443 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
2444 	ctx.glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
2445 	ctx.expectError(GL_INVALID_ENUM);
2446 	ctx.endSection();
2447 
2448 	deUint32				texture = 0x1234;
2449 	ctx.glGenTextures			(1, &texture);
2450 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
2451 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
2452 	ctx.expectError				(GL_NO_ERROR);
2453 
2454 	ctx.beginSection("GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
2455 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
2456 	ctx.expectError(GL_INVALID_OPERATION);
2457 	ctx.endSection();
2458 
2459 	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.");
2460 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 4, 0, 10, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
2461 	ctx.expectError(GL_INVALID_OPERATION);
2462 	ctx.endSection();
2463 
2464 	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.");
2465 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 4, 4, 10, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
2466 	ctx.expectError(GL_INVALID_OPERATION);
2467 	ctx.endSection();
2468 
2469 	ctx.beginSection("For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
2470 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2471 	ctx.expectError(GL_INVALID_OPERATION);
2472 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2473 	ctx.expectError(GL_INVALID_OPERATION);
2474 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2475 	ctx.expectError(GL_INVALID_OPERATION);
2476 	ctx.endSection();
2477 
2478 	ctx.glDeleteTextures		(1, &texture);
2479 }
2480 
compressedtexsubimage2d_neg_level(NegativeTestContext & ctx)2481 void compressedtexsubimage2d_neg_level (NegativeTestContext& ctx)
2482 {
2483 	deUint32				textures[2];
2484 	ctx.glGenTextures			(2, &textures[0]);
2485 	ctx.glBindTexture			(GL_TEXTURE_2D, textures[0]);
2486 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
2487 	ctx.glBindTexture			(GL_TEXTURE_CUBE_MAP, textures[1]);
2488 	FOR_CUBE_FACES(faceGL, ctx.glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
2489 	ctx.expectError				(GL_NO_ERROR);
2490 
2491 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
2492 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2493 	ctx.expectError(GL_INVALID_VALUE);
2494 	ctx.endSection();
2495 
2496 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
2497 	FOR_CUBE_FACES(faceGL,
2498 	{
2499 		ctx.glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2500 		ctx.expectError(GL_INVALID_VALUE);
2501 	});
2502 	ctx.endSection();
2503 
2504 	ctx.glDeleteTextures(2, &textures[0]);
2505 }
2506 
compressedtexsubimage2d_max_level(NegativeTestContext & ctx)2507 void compressedtexsubimage2d_max_level (NegativeTestContext& ctx)
2508 {
2509 	deUint32				textures[2];
2510 	ctx.glGenTextures			(2, &textures[0]);
2511 	ctx.glBindTexture			(GL_TEXTURE_2D, textures[0]);
2512 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
2513 	ctx.glBindTexture			(GL_TEXTURE_CUBE_MAP, textures[1]);
2514 	FOR_CUBE_FACES(faceGL, ctx.glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
2515 	ctx.expectError				(GL_NO_ERROR);
2516 
2517 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2518 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
2519 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2520 	ctx.expectError(GL_INVALID_VALUE);
2521 	ctx.endSection();
2522 
2523 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
2524 	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
2525 	FOR_CUBE_FACES(faceGL,
2526 	{
2527 		ctx.glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2528 		ctx.expectError(GL_INVALID_VALUE);
2529 	});
2530 	ctx.endSection();
2531 
2532 	ctx.glDeleteTextures(2, &textures[0]);
2533 }
2534 
compressedtexsubimage2d_neg_offset(NegativeTestContext & ctx)2535 void compressedtexsubimage2d_neg_offset (NegativeTestContext& ctx)
2536 {
2537 	GLuint texture = 0x1234;
2538 	ctx.glGenTextures(1, &texture);
2539 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
2540 	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, etc2EacDataSize(8, 8), 0);
2541 
2542 	// \note Both GL_INVALID_VALUE and GL_INVALID_OPERATION are valid here since implementation may
2543 	//		 first check if offsets are valid for certain format and only after that check that they
2544 	//		 are not negative.
2545 	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset or yoffset are negative.");
2546 
2547 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2548 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2549 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2550 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2551 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2552 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2553 
2554 	ctx.endSection();
2555 
2556 	ctx.glDeleteTextures(1, &texture);
2557 }
2558 
compressedtexsubimage2d_invalid_offset(NegativeTestContext & ctx)2559 void compressedtexsubimage2d_invalid_offset (NegativeTestContext& ctx)
2560 {
2561 	deUint32				texture = 0x1234;
2562 	ctx.glGenTextures			(1, &texture);
2563 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
2564 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2565 	ctx.expectError				(GL_NO_ERROR);
2566 
2567 	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
2568 
2569 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 0, 8, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
2570 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2571 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 12, 4, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
2572 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2573 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 12, 8, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
2574 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2575 	ctx.endSection();
2576 
2577 	ctx.glDeleteTextures		(1, &texture);
2578 }
2579 
compressedtexsubimage2d_neg_width_height(NegativeTestContext & ctx)2580 void compressedtexsubimage2d_neg_width_height (NegativeTestContext& ctx)
2581 {
2582 	deUint32				texture = 0x1234;
2583 	ctx.glGenTextures			(1, &texture);
2584 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
2585 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2586 	ctx.expectError				(GL_NO_ERROR);
2587 
2588 	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width or height is less than 0.");
2589 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2590 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2591 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2592 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2593 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
2594 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
2595 	ctx.endSection();
2596 
2597 	ctx.glDeleteTextures(1,		&texture);
2598 }
2599 
compressedtexsubimage2d_invalid_size(NegativeTestContext & ctx)2600 void compressedtexsubimage2d_invalid_size (NegativeTestContext& ctx)
2601 {
2602 	deUint32				texture = 0x1234;
2603 	ctx.glGenTextures			(1, &texture);
2604 	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
2605 	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2606 	ctx.expectError				(GL_NO_ERROR);
2607 
2608 	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
2609 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
2610 	ctx.expectError(GL_INVALID_VALUE);
2611 
2612 	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
2613 	ctx.expectError(GL_INVALID_VALUE);
2614 	ctx.endSection();
2615 
2616 	ctx.glDeleteTextures		(1, &texture);
2617 }
2618 
compressedtexsubimage2d_invalid_buffer_target(NegativeTestContext & ctx)2619 void compressedtexsubimage2d_invalid_buffer_target (NegativeTestContext& ctx)
2620 {
2621 	deUint32					buf = 0x1234;
2622 	deUint32					texture = 0x1234;
2623 	std::vector<GLubyte>		data(128);
2624 
2625 	ctx.glGenTextures				(1, &texture);
2626 	ctx.glBindTexture				(GL_TEXTURE_2D, texture);
2627 	ctx.glCompressedTexImage2D		(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2628 	ctx.glGenBuffers				(1, &buf);
2629 	ctx.glBindBuffer				(GL_PIXEL_UNPACK_BUFFER, buf);
2630 	ctx.glBufferData				(GL_PIXEL_UNPACK_BUFFER, 128, &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...");
2634 	ctx.beginSection("...the buffer object's data store is currently mapped.");
2635 	ctx.glMapBufferRange			(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2636 	ctx.glCompressedTexSubImage2D	(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
2637 	ctx.expectError					(GL_INVALID_OPERATION);
2638 	ctx.glUnmapBuffer				(GL_PIXEL_UNPACK_BUFFER);
2639 	ctx.endSection();
2640 
2641 	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2642 	ctx.glCompressedTexSubImage2D	(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
2643 	ctx.expectError					(GL_INVALID_OPERATION);
2644 	ctx.endSection();
2645 	ctx.endSection();
2646 
2647 	ctx.glDeleteBuffers			(1, &buf);
2648 	ctx.glDeleteTextures		(1, &texture);
2649 }
2650 
2651 // glTexImage3D
2652 
teximage3d(NegativeTestContext & ctx)2653 void teximage3d (NegativeTestContext& ctx)
2654 {
2655 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
2656 	ctx.glTexImage3D(0, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2657 	ctx.expectError(GL_INVALID_ENUM);
2658 	ctx.glTexImage3D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2659 	ctx.expectError(GL_INVALID_ENUM);
2660 	ctx.endSection();
2661 
2662 	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
2663 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 0, 0);
2664 	ctx.expectError(GL_INVALID_ENUM);
2665 	ctx.endSection();
2666 
2667 	ctx.beginSection("GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2668 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
2669 	ctx.expectError(GL_INVALID_ENUM);
2670 	ctx.endSection();
2671 
2672 	ctx.beginSection("GL_INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants.");
2673 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, 0, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2674 	ctx.expectError(GL_INVALID_VALUE);
2675 	ctx.endSection();
2676 
2677 	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_3D and format is GL_DEPTH_COMPONENT, or GL_DEPTH_STENCIL.");
2678 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_STENCIL, 1, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
2679 	ctx.expectError(GL_INVALID_OPERATION);
2680 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_COMPONENT, 1, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
2681 	ctx.expectError(GL_INVALID_OPERATION);
2682 	ctx.endSection();
2683 
2684 	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
2685 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2686 	ctx.expectError(GL_INVALID_OPERATION);
2687 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2688 	ctx.expectError(GL_INVALID_OPERATION);
2689 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2690 	ctx.expectError(GL_INVALID_OPERATION);
2691 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB10_A2, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
2692 	ctx.expectError(GL_INVALID_OPERATION);
2693 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, 1, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
2694 	ctx.expectError(GL_INVALID_OPERATION);
2695 	ctx.endSection();
2696 
2697 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2698 	{
2699 		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TEXTURE_CUBE_MAP_ARRAY and width and height are not equal.");
2700 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 2, 1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2701 		ctx.expectError(GL_INVALID_VALUE);
2702 		ctx.endSection();
2703 
2704 		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TEXTURE_CUBE_MAP_ARRAY and depth is not a multiple of six.");
2705 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2706 		ctx.expectError(GL_INVALID_VALUE);
2707 		ctx.endSection();
2708 	}
2709 }
2710 
teximage3d_neg_level(NegativeTestContext & ctx)2711 void teximage3d_neg_level (NegativeTestContext& ctx)
2712 {
2713 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
2714 	ctx.glTexImage3D(GL_TEXTURE_3D, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2715 	ctx.expectError(GL_INVALID_VALUE);
2716 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2717 	ctx.expectError(GL_INVALID_VALUE);
2718 
2719 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2720 	{
2721 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, -1, GL_RGBA, 1, 1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2722 		ctx.expectError(GL_INVALID_VALUE);
2723 	}
2724 
2725 	ctx.endSection();
2726 
2727 }
2728 
teximage3d_max_level(NegativeTestContext & ctx)2729 void teximage3d_max_level (NegativeTestContext& ctx)
2730 {
2731 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2732 	deUint32 log2Max3DTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2733 	ctx.glTexImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2734 	ctx.expectError(GL_INVALID_VALUE);
2735 	ctx.endSection();
2736 
2737 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2738 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
2739 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
2740 	ctx.expectError(GL_INVALID_VALUE);
2741 	ctx.endSection();
2742 }
2743 
teximage3d_neg_width_height_depth(NegativeTestContext & ctx)2744 void teximage3d_neg_width_height_depth (NegativeTestContext& ctx)
2745 {
2746 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
2747 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2748 	ctx.expectError(GL_INVALID_VALUE);
2749 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2750 	ctx.expectError(GL_INVALID_VALUE);
2751 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2752 	ctx.expectError(GL_INVALID_VALUE);
2753 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2754 	ctx.expectError(GL_INVALID_VALUE);
2755 
2756 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2757 	ctx.expectError(GL_INVALID_VALUE);
2758 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2759 	ctx.expectError(GL_INVALID_VALUE);
2760 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2761 	ctx.expectError(GL_INVALID_VALUE);
2762 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2763 	ctx.expectError(GL_INVALID_VALUE);
2764 
2765 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2766 	{
2767 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, -1, 1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2768 		ctx.expectError(GL_INVALID_VALUE);
2769 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 1, -1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2770 		ctx.expectError(GL_INVALID_VALUE);
2771 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 1, 1, -6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2772 		ctx.expectError(GL_INVALID_VALUE);
2773 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, -1, -1, -6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2774 		ctx.expectError(GL_INVALID_VALUE);
2775 	}
2776 	ctx.endSection();
2777 }
2778 
teximage3d_max_width_height_depth(NegativeTestContext & ctx)2779 void teximage3d_max_width_height_depth (NegativeTestContext& ctx)
2780 {
2781 	int max3DTextureSize	= ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE) + 1;
2782 	int maxTextureSize		= ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
2783 
2784 	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_3D_TEXTURE_SIZE.");
2785 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2786 	ctx.expectError(GL_INVALID_VALUE);
2787 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, max3DTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2788 	ctx.expectError(GL_INVALID_VALUE);
2789 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2790 	ctx.expectError(GL_INVALID_VALUE);
2791 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2792 	ctx.expectError(GL_INVALID_VALUE);
2793 	ctx.endSection();
2794 
2795 	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
2796 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2797 	ctx.expectError(GL_INVALID_VALUE);
2798 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, maxTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2799 	ctx.expectError(GL_INVALID_VALUE);
2800 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2801 	ctx.expectError(GL_INVALID_VALUE);
2802 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, maxTextureSize, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2803 	ctx.expectError(GL_INVALID_VALUE);
2804 	ctx.endSection();
2805 }
2806 
teximage3d_invalid_border(NegativeTestContext & ctx)2807 void teximage3d_invalid_border (NegativeTestContext& ctx)
2808 {
2809 	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0 or 1.");
2810 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2811 	ctx.expectError(GL_INVALID_VALUE);
2812 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2813 	ctx.expectError(GL_INVALID_VALUE);
2814 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
2815 	ctx.expectError(GL_INVALID_VALUE);
2816 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
2817 	ctx.expectError(GL_INVALID_VALUE);
2818 
2819 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2820 	{
2821 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA, 1, 1, 6, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2822 		ctx.expectError(GL_INVALID_VALUE);
2823 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA, 1, 1, 6, 1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2824 		ctx.expectError(GL_INVALID_VALUE);
2825 	}
2826 
2827 	ctx.endSection();
2828 }
2829 
teximage3d_invalid_buffer_target(NegativeTestContext & ctx)2830 void teximage3d_invalid_buffer_target (NegativeTestContext& ctx)
2831 {
2832 	deUint32				buf = 0x1234;
2833 	deUint32				texture = 0x1234;
2834 	std::vector<GLubyte>	data(512);
2835 
2836 	ctx.glGenBuffers			(1, &buf);
2837 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
2838 	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
2839 	ctx.glGenTextures			(1, &texture);
2840 	ctx.glBindTexture			(GL_TEXTURE_3D, texture);
2841 	ctx.expectError				(GL_NO_ERROR);
2842 
2843 	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
2844 
2845 	ctx.beginSection("...the buffer object's data store is currently mapped.");
2846 	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
2847 	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2848 	ctx.expectError				(GL_INVALID_OPERATION);
2849 	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
2850 	ctx.endSection();
2851 
2852 	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
2853 	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 64, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2854 	ctx.expectError				(GL_INVALID_OPERATION);
2855 	ctx.endSection();
2856 
2857 	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
2858 	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
2859 	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);
2860 	ctx.expectError				(GL_INVALID_OPERATION);
2861 	ctx.endSection();
2862 
2863 	ctx.endSection();
2864 
2865 	ctx.glDeleteBuffers			(1, &buf);
2866 	ctx.glDeleteTextures		(1, &texture);
2867 }
2868 
2869 // glTexSubImage3D
2870 
texsubimage3d(NegativeTestContext & ctx)2871 void texsubimage3d (NegativeTestContext& ctx)
2872 {
2873 	deUint32			texture = 0x1234;
2874 	ctx.glGenTextures		(1, &texture);
2875 	ctx.glBindTexture		(GL_TEXTURE_3D, texture);
2876 	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2877 	ctx.expectError			(GL_NO_ERROR);
2878 
2879 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
2880 	ctx.glTexSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2881 	ctx.expectError(GL_INVALID_ENUM);
2882 	ctx.glTexSubImage3D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2883 	ctx.expectError(GL_INVALID_ENUM);
2884 	ctx.endSection();
2885 
2886 	ctx.beginSection("GL_INVALID_ENUM is generated if format is not an accepted format constant.");
2887 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, GL_UNSIGNED_BYTE, 0);
2888 	ctx.expectError(GL_INVALID_ENUM);
2889 	ctx.endSection();
2890 
2891 	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
2892 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, 0, 0);
2893 	ctx.expectError(GL_INVALID_ENUM);
2894 	ctx.endSection();
2895 
2896 	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.");
2897 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
2898 	ctx.expectError(GL_INVALID_OPERATION);
2899 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2900 	ctx.expectError(GL_INVALID_OPERATION);
2901 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
2902 	ctx.expectError(GL_INVALID_OPERATION);
2903 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
2904 	ctx.expectError(GL_INVALID_OPERATION);
2905 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_FLOAT, 0);
2906 	ctx.expectError(GL_INVALID_OPERATION);
2907 	ctx.endSection();
2908 
2909 	ctx.glDeleteTextures	(1, &texture);
2910 }
2911 
texsubimage3d_neg_level(NegativeTestContext & ctx)2912 void texsubimage3d_neg_level (NegativeTestContext& ctx)
2913 {
2914 	deUint32			textures[3];
2915 	ctx.glGenTextures		(3, &textures[0]);
2916 	ctx.glBindTexture		(GL_TEXTURE_3D, textures[0]);
2917 	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2918 	ctx.glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2919 	ctx.glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2920 	ctx.expectError			(GL_NO_ERROR);
2921 
2922 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
2923 	ctx.glTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2924 	ctx.expectError(GL_INVALID_VALUE);
2925 	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2926 	ctx.expectError(GL_INVALID_VALUE);
2927 
2928 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2929 	{
2930 		ctx.glBindTexture		(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
2931 		ctx.glTexImage3D		(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2932 		ctx.expectError			(GL_NO_ERROR);
2933 
2934 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2935 		ctx.expectError(GL_INVALID_VALUE);
2936 	}
2937 
2938 	ctx.endSection();
2939 
2940 	ctx.glDeleteTextures	(3, &textures[0]);
2941 }
2942 
texsubimage3d_max_level(NegativeTestContext & ctx)2943 void texsubimage3d_max_level (NegativeTestContext& ctx)
2944 {
2945 	deUint32			textures[2];
2946 	ctx.glGenTextures		(2, &textures[0]);
2947 	ctx.glBindTexture		(GL_TEXTURE_3D, textures[0]);
2948 	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2949 	ctx.glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2950 	ctx.glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2951 	ctx.expectError			(GL_NO_ERROR);
2952 
2953 	deUint32 log2Max3DTextureSize	= deLog2Floor32(ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE)) + 1;
2954 	deUint32 log2MaxTextureSize		= deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
2955 
2956 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
2957 	ctx.glTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2958 	ctx.expectError(GL_INVALID_VALUE);
2959 	ctx.endSection();
2960 
2961 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
2962 	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2963 	ctx.expectError(GL_INVALID_VALUE);
2964 	ctx.endSection();
2965 
2966 	ctx.glDeleteTextures	(2, &textures[0]);
2967 }
2968 
texsubimage3d_neg_offset(NegativeTestContext & ctx)2969 void texsubimage3d_neg_offset (NegativeTestContext& ctx)
2970 {
2971 	deUint32			textures[3];
2972 	ctx.glGenTextures		(3, &textures[0]);
2973 	ctx.glBindTexture		(GL_TEXTURE_3D, textures[0]);
2974 	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2975 	ctx.glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
2976 	ctx.glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2977 	ctx.expectError			(GL_NO_ERROR);
2978 
2979 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.");
2980 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2981 	ctx.expectError(GL_INVALID_VALUE);
2982 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2983 	ctx.expectError(GL_INVALID_VALUE);
2984 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2985 	ctx.expectError(GL_INVALID_VALUE);
2986 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2987 	ctx.expectError(GL_INVALID_VALUE);
2988 	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2989 	ctx.expectError(GL_INVALID_VALUE);
2990 	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2991 	ctx.expectError(GL_INVALID_VALUE);
2992 	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2993 	ctx.expectError(GL_INVALID_VALUE);
2994 	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2995 	ctx.expectError(GL_INVALID_VALUE);
2996 
2997 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2998 	{
2999 		ctx.glBindTexture		(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
3000 		ctx.glTexImage3D		(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3001 		ctx.expectError			(GL_NO_ERROR);
3002 
3003 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3004 		ctx.expectError(GL_INVALID_VALUE);
3005 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3006 		ctx.expectError(GL_INVALID_VALUE);
3007 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3008 		ctx.expectError(GL_INVALID_VALUE);
3009 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3010 		ctx.expectError(GL_INVALID_VALUE);
3011 	}
3012 
3013 	ctx.endSection();
3014 
3015 	ctx.glDeleteTextures	(3, &textures[0]);
3016 }
3017 
texsubimage3d_invalid_offset(NegativeTestContext & ctx)3018 void texsubimage3d_invalid_offset (NegativeTestContext& ctx)
3019 {
3020 	deUint32			texture = 0x1234;
3021 	ctx.glGenTextures		(1, &texture);
3022 	ctx.glBindTexture		(GL_TEXTURE_3D, texture);
3023 	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3024 	ctx.expectError			(GL_NO_ERROR);
3025 
3026 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
3027 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3028 	ctx.expectError(GL_INVALID_VALUE);
3029 	ctx.endSection();
3030 
3031 	ctx.beginSection("GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
3032 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3033 	ctx.expectError(GL_INVALID_VALUE);
3034 	ctx.endSection();
3035 
3036 	ctx.beginSection("GL_INVALID_VALUE is generated if zoffset + depth > texture_depth.");
3037 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3038 	ctx.expectError(GL_INVALID_VALUE);
3039 	ctx.endSection();
3040 
3041 	ctx.glDeleteTextures	(1, &texture);
3042 }
3043 
texsubimage3d_neg_width_height(NegativeTestContext & ctx)3044 void texsubimage3d_neg_width_height (NegativeTestContext& ctx)
3045 {
3046 	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
3047 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3048 	ctx.expectError(GL_INVALID_VALUE);
3049 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3050 	ctx.expectError(GL_INVALID_VALUE);
3051 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3052 	ctx.expectError(GL_INVALID_VALUE);
3053 	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3054 	ctx.expectError(GL_INVALID_VALUE);
3055 
3056 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3057 	{
3058 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3059 		ctx.expectError(GL_INVALID_VALUE);
3060 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3061 		ctx.expectError(GL_INVALID_VALUE);
3062 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3063 		ctx.expectError(GL_INVALID_VALUE);
3064 		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3065 		ctx.expectError(GL_INVALID_VALUE);
3066 	}
3067 
3068 	ctx.endSection();
3069 }
3070 
texsubimage3d_invalid_buffer_target(NegativeTestContext & ctx)3071 void texsubimage3d_invalid_buffer_target (NegativeTestContext& ctx)
3072 {
3073 	deUint32				buf = 0x1234;
3074 	deUint32				texture = 0x1234;
3075 	std::vector<GLubyte>	data(512);
3076 
3077 	ctx.glGenTextures			(1, &texture);
3078 	ctx.glBindTexture			(GL_TEXTURE_3D, texture);
3079 	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3080 	ctx.glGenBuffers			(1, &buf);
3081 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
3082 	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
3083 	ctx.expectError				(GL_NO_ERROR);
3084 
3085 	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
3086 
3087 	ctx.beginSection("...the buffer object's data store is currently mapped.");
3088 	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 512, GL_MAP_WRITE_BIT);
3089 	ctx.glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3090 	ctx.expectError				(GL_INVALID_OPERATION);
3091 	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
3092 	ctx.endSection();
3093 
3094 	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
3095 	ctx.glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 16, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3096 	ctx.expectError				(GL_INVALID_OPERATION);
3097 	ctx.endSection();
3098 
3099 	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
3100 	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
3101 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, 0);
3102 	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
3103 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
3104 	ctx.expectError				(GL_NO_ERROR);
3105 	ctx.glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
3106 	ctx.expectError				(GL_INVALID_OPERATION);
3107 	ctx.endSection();
3108 
3109 	ctx.endSection();
3110 
3111 	ctx.glDeleteBuffers			(1, &buf);
3112 	ctx.glDeleteTextures		(1, &texture);
3113 }
3114 
3115 // glCopyTexSubImage3D
3116 
copytexsubimage3d(NegativeTestContext & ctx)3117 void copytexsubimage3d (NegativeTestContext& ctx)
3118 {
3119 	GLuint texture = 0x1234;
3120 	ctx.glGenTextures	(1, &texture);
3121 	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
3122 	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3123 
3124 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
3125 	ctx.glCopyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 4);
3126 	ctx.expectError(GL_INVALID_ENUM);
3127 	ctx.endSection();
3128 
3129 	ctx.glDeleteTextures(1, &texture);
3130 }
3131 
copytexsubimage3d_neg_level(NegativeTestContext & ctx)3132 void copytexsubimage3d_neg_level (NegativeTestContext& ctx)
3133 {
3134 	deUint32	textures[3];
3135 	ctx.glGenTextures(3, &textures[0]);
3136 	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3137 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3138 	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
3139 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3140 	ctx.expectError(GL_NO_ERROR);
3141 
3142 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
3143 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 4);
3144 	ctx.expectError(GL_INVALID_VALUE);
3145 	ctx.glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
3146 	ctx.expectError(GL_INVALID_VALUE);
3147 
3148 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3149 	{
3150 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
3151 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3152 		ctx.expectError(GL_NO_ERROR);
3153 		ctx.glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
3154 		ctx.expectError(GL_INVALID_VALUE);
3155 	}
3156 
3157 	ctx.endSection();
3158 
3159 	ctx.glDeleteTextures(3, &textures[0]);
3160 }
3161 
copytexsubimage3d_max_level(NegativeTestContext & ctx)3162 void copytexsubimage3d_max_level (NegativeTestContext& ctx)
3163 {
3164 	deUint32	log2Max3DTextureSize		= deLog2Floor32(ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE)) + 1;
3165 	deUint32	log2MaxTextureSize			= deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
3166 	deUint32	log2MaxCubeMapTextureSize	= deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
3167 
3168 	deUint32	textures[3];
3169 	ctx.glGenTextures(3, &textures[0]);
3170 	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3171 	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3172 	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
3173 	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3174 	ctx.expectError(GL_NO_ERROR);
3175 
3176 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
3177 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 4);
3178 	ctx.expectError(GL_INVALID_VALUE);
3179 	ctx.endSection();
3180 
3181 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
3182 	ctx.glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 4);
3183 	ctx.expectError(GL_INVALID_VALUE);
3184 	ctx.endSection();
3185 
3186 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3187 	{
3188 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
3189 		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3190 		ctx.expectError(GL_NO_ERROR);
3191 		ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
3192 		ctx.glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, log2MaxCubeMapTextureSize, 0, 0, 0, 0, 0, 4, 4);
3193 		ctx.expectError(GL_INVALID_VALUE);
3194 		ctx.endSection();
3195 	}
3196 
3197 	ctx.glDeleteTextures(3, &textures[0]);
3198 }
3199 
copytexsubimage3d_neg_offset(NegativeTestContext & ctx)3200 void copytexsubimage3d_neg_offset (NegativeTestContext& ctx)
3201 {
3202 	GLuint texture = 0x1234;
3203 	ctx.glGenTextures	(1, &texture);
3204 	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
3205 	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3206 
3207 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.");
3208 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0,  0, 0, 0, 4, 4);
3209 	ctx.expectError(GL_INVALID_VALUE);
3210 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4);
3211 	ctx.expectError(GL_INVALID_VALUE);
3212 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4);
3213 	ctx.expectError(GL_INVALID_VALUE);
3214 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4);
3215 	ctx.expectError(GL_INVALID_VALUE);
3216 	ctx.endSection();
3217 
3218 	ctx.glDeleteTextures(1, &texture);
3219 }
3220 
copytexsubimage3d_invalid_offset(NegativeTestContext & ctx)3221 void copytexsubimage3d_invalid_offset (NegativeTestContext& ctx)
3222 {
3223 	GLuint texture = 0x1234;
3224 	ctx.glGenTextures	(1, &texture);
3225 	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
3226 	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3227 
3228 	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
3229 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4);
3230 	ctx.expectError(GL_INVALID_VALUE);
3231 	ctx.endSection();
3232 
3233 	ctx.beginSection("GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
3234 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4);
3235 	ctx.expectError(GL_INVALID_VALUE);
3236 	ctx.endSection();
3237 
3238 	ctx.beginSection("GL_INVALID_VALUE is generated if zoffset + 1 > texture_depth.");
3239 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4);
3240 	ctx.expectError(GL_INVALID_VALUE);
3241 	ctx.endSection();
3242 
3243 	ctx.glDeleteTextures(1, &texture);
3244 }
3245 
copytexsubimage3d_neg_width_height(NegativeTestContext & ctx)3246 void copytexsubimage3d_neg_width_height (NegativeTestContext& ctx)
3247 {
3248 	GLuint texture = 0x1234;
3249 	ctx.glGenTextures	(1, &texture);
3250 	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
3251 	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3252 
3253 	ctx.beginSection("GL_INVALID_VALUE is generated if width < 0.");
3254 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4);
3255 	ctx.expectError(GL_INVALID_VALUE);
3256 	ctx.endSection();
3257 
3258 	ctx.beginSection("GL_INVALID_VALUE is generated if height < 0.");
3259 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4);
3260 	ctx.expectError(GL_INVALID_VALUE);
3261 	ctx.endSection();
3262 
3263 	ctx.glDeleteTextures(1, &texture);
3264 }
3265 
copytexsubimage3d_incomplete_framebuffer(NegativeTestContext & ctx)3266 void copytexsubimage3d_incomplete_framebuffer (NegativeTestContext& ctx)
3267 {
3268 	GLuint fbo = 0x1234;
3269 	GLuint texture[2];
3270 
3271 	ctx.glGenTextures			(2, texture);
3272 	ctx.glBindTexture			(GL_TEXTURE_3D, texture[0]);
3273 	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3274 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture[1]);
3275 	ctx.glTexImage3D			(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3276 	ctx.glGenFramebuffers		(1, &fbo);
3277 	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, fbo);
3278 	ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
3279 
3280 	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
3281 	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4);
3282 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
3283 	ctx.glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
3284 	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
3285 	ctx.endSection();
3286 
3287 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
3288 	ctx.glDeleteFramebuffers(1, &fbo);
3289 	ctx.glDeleteTextures(2, texture);
3290 }
3291 
3292 // glCompressedTexImage3D
3293 
compressedteximage3d(NegativeTestContext & ctx)3294 void compressedteximage3d (NegativeTestContext& ctx)
3295 {
3296 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
3297 	ctx.glCompressedTexImage3D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
3298 	ctx.expectError(GL_INVALID_ENUM);
3299 	ctx.glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
3300 	ctx.expectError(GL_INVALID_ENUM);
3301 	ctx.endSection();
3302 
3303 	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.");
3304 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, 0);
3305 	ctx.expectError(GL_INVALID_ENUM);
3306 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 0, 0, 0, 0, 0, 0);
3307 	ctx.expectError(GL_INVALID_ENUM);
3308 	ctx.endSection();
3309 }
3310 
compressedteximage3d_neg_level(NegativeTestContext & ctx)3311 void compressedteximage3d_neg_level (NegativeTestContext& ctx)
3312 {
3313 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
3314 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
3315 	ctx.expectError(GL_INVALID_VALUE);
3316 	ctx.endSection();
3317 }
3318 
compressedteximage3d_max_level(NegativeTestContext & ctx)3319 void compressedteximage3d_max_level (NegativeTestContext& ctx)
3320 {
3321 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
3322 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
3323 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
3324 	ctx.expectError(GL_INVALID_VALUE);
3325 	ctx.endSection();
3326 }
3327 
compressedteximage3d_neg_width_height_depth(NegativeTestContext & ctx)3328 void compressedteximage3d_neg_width_height_depth (NegativeTestContext& ctx)
3329 {
3330 	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
3331 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0, 0);
3332 	ctx.expectError(GL_INVALID_VALUE);
3333 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0, 0);
3334 	ctx.expectError(GL_INVALID_VALUE);
3335 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0, 0);
3336 	ctx.expectError(GL_INVALID_VALUE);
3337 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, 0, 0);
3338 	ctx.expectError(GL_INVALID_VALUE);
3339 	ctx.endSection();
3340 }
3341 
compressedteximage3d_max_width_height_depth(NegativeTestContext & ctx)3342 void compressedteximage3d_max_width_height_depth (NegativeTestContext& ctx)
3343 {
3344 	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
3345 
3346 	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
3347 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, 0, 0);
3348 	ctx.expectError(GL_INVALID_VALUE);
3349 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, 0, 0);
3350 	ctx.expectError(GL_INVALID_VALUE);
3351 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureSize, 0, 0, 0);
3352 	ctx.expectError(GL_INVALID_VALUE);
3353 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, maxTextureSize, 0, 0, 0);
3354 	ctx.expectError(GL_INVALID_VALUE);
3355 	ctx.endSection();
3356 }
3357 
compressedteximage3d_invalid_border(NegativeTestContext & ctx)3358 void compressedteximage3d_invalid_border (NegativeTestContext& ctx)
3359 {
3360 	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
3361 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0, 0);
3362 	ctx.expectError(GL_INVALID_VALUE);
3363 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, 0, 0);
3364 	ctx.expectError(GL_INVALID_VALUE);
3365 	ctx.endSection();
3366 }
3367 
compressedteximage3d_invalid_size(NegativeTestContext & ctx)3368 void compressedteximage3d_invalid_size (NegativeTestContext& ctx)
3369 {
3370 	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
3371 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, -1, 0);
3372 	ctx.expectError(GL_INVALID_VALUE);
3373 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*8, 0);
3374 	ctx.expectError(GL_INVALID_VALUE);
3375 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, 4*4*16, 0);
3376 	ctx.expectError(GL_INVALID_VALUE);
3377 	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, 4*4*16, 0);
3378 	ctx.expectError(GL_INVALID_VALUE);
3379 	ctx.endSection();
3380 }
3381 
compressedteximage3d_invalid_width_height(NegativeTestContext & ctx)3382 void compressedteximage3d_invalid_width_height (NegativeTestContext& ctx)
3383 {
3384 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3385 	{
3386 		const int				width		= 4;
3387 		const int				height		= 6;
3388 		const int				depth		= 6;
3389 		const int				blockSize	= 16;
3390 		const int				imageSize	= divRoundUp(width, 4) * divRoundUp(height, 4) * depth * blockSize;
3391 		std::vector<GLubyte>	data		(imageSize);
3392 		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TEXTURE_CUBE_MAP_ARRAY and width and height are not equal.");
3393 		ctx.glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, width, height, depth, 0, imageSize, &data[0]);
3394 		ctx.expectError(GL_INVALID_VALUE);
3395 		ctx.endSection();
3396 	}
3397 }
3398 
compressedteximage3d_invalid_buffer_target(NegativeTestContext & ctx)3399 void compressedteximage3d_invalid_buffer_target (NegativeTestContext& ctx)
3400 {
3401 	deUint32				buf = 0x1234;
3402 	std::vector<GLubyte>	data(512);
3403 
3404 	ctx.glGenBuffers			(1, &buf);
3405 	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
3406 	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
3407 	ctx.expectError				(GL_NO_ERROR);
3408 
3409 	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.");
3410 	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 64, GL_MAP_WRITE_BIT);
3411 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 1, 0, etc2DataSize(4, 4), 0);
3412 	ctx.expectError				(GL_INVALID_OPERATION);
3413 	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
3414 	ctx.endSection();
3415 
3416 	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.");
3417 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, etc2DataSize(16, 16), 0);
3418 	ctx.expectError				(GL_INVALID_OPERATION);
3419 	ctx.endSection();
3420 
3421 	ctx.glDeleteBuffers			(1, &buf);
3422 }
3423 
3424 // glCompressedTexSubImage3D
3425 
compressedtexsubimage3d(NegativeTestContext & ctx)3426 void compressedtexsubimage3d (NegativeTestContext& ctx)
3427 {
3428 	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
3429 	ctx.glCompressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3430 	ctx.expectError(GL_INVALID_ENUM);
3431 	ctx.endSection();
3432 
3433 	deUint32				texture = 0x1234;
3434 	ctx.glGenTextures			(1, &texture);
3435 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3436 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0, etc2EacDataSize(18, 18), 0);
3437 	ctx.expectError				(GL_NO_ERROR);
3438 
3439 	ctx.beginSection("GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
3440 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
3441 	ctx.expectError(GL_INVALID_OPERATION);
3442 	ctx.endSection();
3443 
3444 	ctx.beginSection("GL_INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.");
3445 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(18, 18), 0);
3446 	ctx.expectError(GL_INVALID_OPERATION);
3447 	ctx.endSection();
3448 
3449 	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.");
3450 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
3451 	ctx.expectError(GL_INVALID_OPERATION);
3452 	ctx.endSection();
3453 
3454 	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.");
3455 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
3456 	ctx.expectError(GL_INVALID_OPERATION);
3457 	ctx.endSection();
3458 
3459 	ctx.beginSection("For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
3460 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
3461 	ctx.expectError(GL_INVALID_OPERATION);
3462 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
3463 	ctx.expectError(GL_INVALID_OPERATION);
3464 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
3465 	ctx.expectError(GL_INVALID_OPERATION);
3466 	ctx.endSection();
3467 
3468 	ctx.glDeleteTextures		(1, &texture);
3469 }
3470 
compressedtexsubimage3d_neg_level(NegativeTestContext & ctx)3471 void compressedtexsubimage3d_neg_level (NegativeTestContext& ctx)
3472 {
3473 	deUint32				texture = 0x1234;
3474 	ctx.glGenTextures			(1, &texture);
3475 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3476 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
3477 	ctx.expectError				(GL_NO_ERROR);
3478 
3479 	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
3480 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3481 	ctx.expectError(GL_INVALID_VALUE);
3482 	ctx.endSection();
3483 
3484 	ctx.glDeleteTextures		(1, &texture);
3485 }
3486 
compressedtexsubimage3d_max_level(NegativeTestContext & ctx)3487 void compressedtexsubimage3d_max_level (NegativeTestContext& ctx)
3488 {
3489 	deUint32				texture = 0x1234;
3490 	ctx.glGenTextures			(1, &texture);
3491 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3492 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
3493 	ctx.expectError				(GL_NO_ERROR);
3494 
3495 	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
3496 	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
3497 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3498 	ctx.expectError(GL_INVALID_VALUE);
3499 	ctx.endSection();
3500 
3501 	ctx.glDeleteTextures		(1, &texture);
3502 }
3503 
compressedtexsubimage3d_neg_offset(NegativeTestContext & ctx)3504 void compressedtexsubimage3d_neg_offset (NegativeTestContext& ctx)
3505 {
3506 	deUint32				texture = 0x1234;
3507 	ctx.glGenTextures			(1, &texture);
3508 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3509 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
3510 	ctx.expectError				(GL_NO_ERROR);
3511 
3512 	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.");
3513 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3514 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3515 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3516 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3517 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3518 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3519 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3520 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3521 	ctx.endSection();
3522 
3523 	ctx.glDeleteTextures		(1, &texture);
3524 }
3525 
compressedtexsubimage3d_invalid_offset(NegativeTestContext & ctx)3526 void compressedtexsubimage3d_invalid_offset (NegativeTestContext& ctx)
3527 {
3528 	deUint32				texture = 0x1234;
3529 	ctx.glGenTextures			(1, &texture);
3530 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3531 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, etc2EacDataSize(4, 4), 0);
3532 	ctx.expectError				(GL_NO_ERROR);
3533 
3534 	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
3535 
3536 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
3537 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3538 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
3539 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3540 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
3541 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3542 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
3543 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3544 	ctx.endSection();
3545 
3546 	ctx.glDeleteTextures		(1, &texture);
3547 }
3548 
compressedtexsubimage3d_neg_width_height_depth(NegativeTestContext & ctx)3549 void compressedtexsubimage3d_neg_width_height_depth (NegativeTestContext& ctx)
3550 {
3551 	deUint32				texture = 0x1234;
3552 	ctx.glGenTextures			(1, &texture);
3553 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3554 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
3555 	ctx.expectError				(GL_NO_ERROR);
3556 
3557 	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width, height or depth are negative.");
3558 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3559 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3560 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3561 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3562 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3563 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3564 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
3565 	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
3566 	ctx.endSection();
3567 
3568 	ctx.glDeleteTextures		(1, &texture);
3569 }
3570 
compressedtexsubimage3d_invalid_size(NegativeTestContext & ctx)3571 void compressedtexsubimage3d_invalid_size (NegativeTestContext& ctx)
3572 {
3573 	deUint32				texture = 0x1234;
3574 	ctx.glGenTextures			(1, &texture);
3575 	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
3576 	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*16, 0);
3577 	ctx.expectError				(GL_NO_ERROR);
3578 
3579 	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
3580 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
3581 	ctx.expectError(GL_INVALID_VALUE);
3582 
3583 	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
3584 	ctx.expectError(GL_INVALID_VALUE);
3585 	ctx.endSection();
3586 
3587 	ctx.glDeleteTextures		(1, &texture);
3588 }
3589 
compressedtexsubimage3d_invalid_buffer_target(NegativeTestContext & ctx)3590 void compressedtexsubimage3d_invalid_buffer_target (NegativeTestContext& ctx)
3591 {
3592 	deUint32						buf = 0x1234;
3593 	deUint32						texture = 0x1234;
3594 	GLsizei							bufferSize =  etc2EacDataSize(4, 4);
3595 	std::vector<GLubyte>			data(bufferSize);
3596 
3597 	ctx.glGenTextures				(1, &texture);
3598 	ctx.glBindTexture				(GL_TEXTURE_2D_ARRAY, texture);
3599 	ctx.glCompressedTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
3600 	ctx.glGenBuffers				(1, &buf);
3601 	ctx.glBindBuffer				(GL_PIXEL_UNPACK_BUFFER, buf);
3602 	ctx.glBufferData				(GL_PIXEL_UNPACK_BUFFER, bufferSize, &data[0], GL_DYNAMIC_COPY);
3603 	ctx.expectError					(GL_NO_ERROR);
3604 
3605 	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
3606 	ctx.beginSection("...the buffer object's data store is currently mapped.");
3607 	ctx.glMapBufferRange			(GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, GL_MAP_WRITE_BIT);
3608 	ctx.glCompressedTexSubImage3D	(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
3609 	ctx.expectError					(GL_INVALID_OPERATION);
3610 	ctx.glUnmapBuffer				(GL_PIXEL_UNPACK_BUFFER);
3611 	ctx.endSection();
3612 
3613 	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
3614 	ctx.glCompressedTexSubImage3D	(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
3615 	ctx.expectError					(GL_INVALID_OPERATION);
3616 	ctx.endSection();
3617 	ctx.endSection();
3618 
3619 	ctx.glDeleteBuffers			(1, &buf);
3620 	ctx.glDeleteTextures		(1, &texture);
3621 }
3622 
3623 // glTexStorage2D
3624 
texstorage2d(NegativeTestContext & ctx)3625 void texstorage2d (NegativeTestContext& ctx)
3626 {
3627 	deUint32  textures[] = {0x1234, 0x1234};
3628 
3629 	ctx.glGenTextures(2, textures);
3630 	ctx.glBindTexture(GL_TEXTURE_2D, textures[0]);
3631 	ctx.expectError(GL_NO_ERROR);
3632 
3633 	ctx.beginSection("GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3634 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, 0, 16, 16);
3635 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3636 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, 16, 16);
3637 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3638 	ctx.endSection();
3639 
3640 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3641 	ctx.glTexStorage2D(0, 1, GL_RGBA8, 16, 16);
3642 	ctx.expectError(GL_INVALID_ENUM);
3643 	ctx.glTexStorage2D(GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16);
3644 	ctx.expectError(GL_INVALID_ENUM);
3645 	ctx.glTexStorage2D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16);
3646 	ctx.expectError(GL_INVALID_ENUM);
3647 	ctx.endSection();
3648 
3649 	ctx.beginSection("GL_INVALID_VALUE is generated if width or height are less than 1.");
3650 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 16);
3651 	ctx.expectError(GL_INVALID_VALUE);
3652 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 0);
3653 	ctx.expectError(GL_INVALID_VALUE);
3654 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 0);
3655 	ctx.expectError(GL_INVALID_VALUE);
3656 
3657 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
3658 	{
3659 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
3660 		ctx.expectError(GL_NO_ERROR);
3661 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 0, 16);
3662 		ctx.expectError(GL_INVALID_VALUE);
3663 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 0);
3664 		ctx.expectError(GL_INVALID_VALUE);
3665 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 0, 0);
3666 		ctx.expectError(GL_INVALID_VALUE);
3667 	}
3668 	ctx.endSection();
3669 
3670 	ctx.glDeleteTextures(2, textures);
3671 }
3672 
texstorage2d_invalid_binding(NegativeTestContext & ctx)3673 void texstorage2d_invalid_binding (NegativeTestContext& ctx)
3674 {
3675 	deUint32	textures[]		= {0x1234, 0x1234};
3676 	deInt32		immutable		= 0x1234;
3677 	const bool	supportsES32	= contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
3678 
3679 	ctx.beginSection("GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3680 	ctx.glBindTexture(GL_TEXTURE_2D, 0);
3681 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3682 	ctx.expectError(GL_INVALID_OPERATION);
3683 
3684 	if (supportsES32)
3685 	{
3686 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
3687 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 16);
3688 		ctx.expectError(GL_INVALID_OPERATION);
3689 	}
3690 	ctx.endSection();
3691 
3692 	ctx.glGenTextures(2, textures);
3693 
3694 	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.");
3695 	ctx.glBindTexture(GL_TEXTURE_2D, textures[0]);
3696 	ctx.glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3697 	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3698 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3699 	ctx.expectError(GL_NO_ERROR);
3700 	ctx.glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3701 	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3702 	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3703 	ctx.expectError(GL_INVALID_OPERATION);
3704 
3705 	if (supportsES32)
3706 	{
3707 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
3708 		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3709 		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3710 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 16);
3711 		ctx.expectError(GL_NO_ERROR);
3712 		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3713 		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3714 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 16);
3715 		ctx.expectError(GL_INVALID_OPERATION);
3716 	}
3717 	ctx.endSection();
3718 
3719 	ctx.glDeleteTextures(2, textures);
3720 }
3721 
texstorage2d_invalid_levels(NegativeTestContext & ctx)3722 void texstorage2d_invalid_levels (NegativeTestContext& ctx)
3723 {
3724 	deUint32	textures[]		= {0x1234, 0x1234};
3725 	deUint32	log2MaxSize		= deLog2Floor32(deMax32(16, 16)) + 1 + 1;
3726 	const bool	supportsES32	= contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
3727 
3728 	ctx.glGenTextures(2, textures);
3729 	ctx.glBindTexture(GL_TEXTURE_2D, textures[0]);
3730 
3731 	if (supportsES32)
3732 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
3733 
3734 	ctx.expectError(GL_NO_ERROR);
3735 
3736 	ctx.beginSection("GL_INVALID_VALUE is generated if levels is less than 1.");
3737 	ctx.glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16);
3738 	ctx.expectError(GL_INVALID_VALUE);
3739 	ctx.glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0);
3740 	ctx.expectError(GL_INVALID_VALUE);
3741 
3742 	if (supportsES32)
3743 	{
3744 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA8, 16, 16);
3745 		ctx.expectError(GL_INVALID_VALUE);
3746 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA8, 0, 0);
3747 		ctx.expectError(GL_INVALID_VALUE);
3748 	}
3749 	ctx.endSection();
3750 
3751 	ctx.beginSection("GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1");
3752 	ctx.glTexStorage2D(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 16);
3753 	ctx.expectError(GL_INVALID_OPERATION);
3754 
3755 	if (supportsES32)
3756 	{
3757 		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, log2MaxSize, GL_RGBA8, 16, 16);
3758 		ctx.expectError(GL_INVALID_OPERATION);
3759 	}
3760 	ctx.endSection();
3761 
3762 	ctx.glDeleteTextures(2, textures);
3763 }
3764 
3765 // glTexStorage3D
3766 
texstorage3d(NegativeTestContext & ctx)3767 void texstorage3d (NegativeTestContext& ctx)
3768 {
3769 	deUint32 textures[] = {0x1234, 0x1234};
3770 
3771 	ctx.glGenTextures(2, textures);
3772 	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3773 	ctx.expectError(GL_NO_ERROR);
3774 
3775 	ctx.beginSection("GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3776 	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, 0, 4, 4, 4);
3777 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3778 	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA_INTEGER, 4, 4, 4);
3779 	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3780 	ctx.endSection();
3781 
3782 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3783 	ctx.glTexStorage3D(0, 1, GL_RGBA8, 4, 4, 4);
3784 	ctx.expectError(GL_INVALID_ENUM);
3785 	ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 4, 4, 4);
3786 	ctx.expectError(GL_INVALID_ENUM);
3787 	ctx.glTexStorage3D(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 4);
3788 	ctx.expectError(GL_INVALID_ENUM);
3789 	ctx.endSection();
3790 
3791 	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth are less than 1.");
3792 	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 4, 4);
3793 	ctx.expectError(GL_INVALID_VALUE);
3794 	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 0, 4);
3795 	ctx.expectError(GL_INVALID_VALUE);
3796 	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 0);
3797 	ctx.expectError(GL_INVALID_VALUE);
3798 	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 0, 0);
3799 	ctx.expectError(GL_INVALID_VALUE);
3800 
3801 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3802 	{
3803 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[1]);
3804 		ctx.expectError(GL_NO_ERROR);
3805 		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 0, 4, 4);
3806 		ctx.expectError(GL_INVALID_VALUE);
3807 		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 0, 4);
3808 		ctx.expectError(GL_INVALID_VALUE);
3809 		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 0);
3810 		ctx.expectError(GL_INVALID_VALUE);
3811 		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 0, 0, 0);
3812 		ctx.expectError(GL_INVALID_VALUE);
3813 	}
3814 	ctx.endSection();
3815 
3816 	ctx.glDeleteTextures(2, textures);
3817 }
3818 
texstorage3d_invalid_binding(NegativeTestContext & ctx)3819 void texstorage3d_invalid_binding (NegativeTestContext& ctx)
3820 {
3821 	deUint32	textures[]	= {0x1234, 0x1234};
3822 	deInt32		immutable	= 0x1234;
3823 
3824 	ctx.beginSection("GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3825 	ctx.glBindTexture	(GL_TEXTURE_3D, 0);
3826 	ctx.glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3827 	ctx.expectError		(GL_INVALID_OPERATION);
3828 
3829 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3830 	{
3831 		ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
3832 		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 6);
3833 		ctx.expectError		(GL_INVALID_OPERATION);
3834 	}
3835 	ctx.endSection();
3836 
3837 	ctx.glGenTextures	(2, textures);
3838 
3839 	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.");
3840 	ctx.glBindTexture	(GL_TEXTURE_3D, textures[0]);
3841 	ctx.glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3842 	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3843 	ctx.glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3844 	ctx.expectError		(GL_NO_ERROR);
3845 	ctx.glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3846 	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3847 	ctx.glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
3848 	ctx.expectError		(GL_INVALID_OPERATION);
3849 
3850 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3851 	{
3852 		ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP_ARRAY, textures[1]);
3853 		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3854 		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3855 		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 6);
3856 		ctx.expectError		(GL_NO_ERROR);
3857 		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3858 		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3859 		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 6);
3860 		ctx.expectError		(GL_INVALID_OPERATION);
3861 	}
3862 	ctx.endSection();
3863 
3864 	ctx.glDeleteTextures(2, textures);
3865 }
3866 
texstorage3d_invalid_levels(NegativeTestContext & ctx)3867 void texstorage3d_invalid_levels (NegativeTestContext& ctx)
3868 {
3869 	deUint32	textures[]		= {0x1234, 0x1234};
3870 	deUint32	log2MaxSize		= deLog2Floor32(8) + 1 + 1;
3871 	const bool	supportsES32	= contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
3872 	ctx.glGenTextures(2, textures);
3873 	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3874 
3875 	ctx.beginSection("GL_INVALID_VALUE is generated if levels is less than 1.");
3876 	ctx.glTexStorage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4);
3877 	ctx.expectError(GL_INVALID_VALUE);
3878 	ctx.glTexStorage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 0, 0, 0);
3879 	ctx.expectError(GL_INVALID_VALUE);
3880 
3881 	if (supportsES32 || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3882 	{
3883 		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[1]);
3884 		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA8, 4, 4, 6);
3885 		ctx.expectError(GL_INVALID_VALUE);
3886 		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA8, 0, 0, 6);
3887 		ctx.expectError(GL_INVALID_VALUE);
3888 	}
3889 	ctx.endSection();
3890 
3891 	ctx.beginSection("GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1");
3892 	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 2, 2);
3893 	ctx.expectError		(GL_INVALID_OPERATION);
3894 	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 8, 2);
3895 	ctx.expectError		(GL_INVALID_OPERATION);
3896 	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 2, 8);
3897 	ctx.expectError		(GL_INVALID_OPERATION);
3898 	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 8, 8);
3899 	ctx.expectError		(GL_INVALID_OPERATION);
3900 
3901 	if (supportsES32 || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3902 	{
3903 		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, log2MaxSize, GL_RGBA8, 2, 2, 6);
3904 		ctx.expectError		(GL_INVALID_OPERATION);
3905 		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, log2MaxSize, GL_RGBA8, 8, 8, 6);
3906 		ctx.expectError		(GL_INVALID_OPERATION);
3907 	}
3908 	ctx.endSection();
3909 
3910 	ctx.glDeleteTextures(2, textures);
3911 }
3912 
srgb_decode_texparameteri(NegativeTestContext & ctx)3913 void srgb_decode_texparameteri (NegativeTestContext& ctx)
3914 {
3915 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
3916 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
3917 
3918 	GLuint	texture		= 0x1234;
3919 	GLint	textureMode	= -1;
3920 
3921 	ctx.glGenTextures(1, &texture);
3922 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
3923 
3924 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
3925 	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
3926 	ctx.expectError(GL_INVALID_ENUM);
3927 	ctx.endSection();
3928 
3929 	ctx.glDeleteTextures(1, &texture);
3930 }
3931 
srgb_decode_texparameterf(NegativeTestContext & ctx)3932 void srgb_decode_texparameterf (NegativeTestContext& ctx)
3933 {
3934 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
3935 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
3936 
3937 	GLuint	texture		= 0x1234;
3938 	GLfloat	textureMode	= -1.0f;
3939 
3940 	ctx.glGenTextures(1, &texture);
3941 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
3942 
3943 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
3944 	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
3945 	ctx.expectError(GL_INVALID_ENUM);
3946 	ctx.endSection();
3947 
3948 	ctx.glDeleteTextures(1, &texture);
3949 }
3950 
srgb_decode_texparameteriv(NegativeTestContext & ctx)3951 void srgb_decode_texparameteriv (NegativeTestContext& ctx)
3952 {
3953 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
3954 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
3955 
3956 	GLint	params[1]	= {GL_LINEAR};
3957 	GLuint	texture		= 0x1234;
3958 
3959 	ctx.glGenTextures(1, &texture);
3960 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
3961 
3962 	params[0] = -1;
3963 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
3964 	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
3965 	ctx.expectError(GL_INVALID_ENUM);
3966 	ctx.endSection();
3967 
3968 	ctx.glDeleteTextures(1, &texture);
3969 }
3970 
srgb_decode_texparameterfv(NegativeTestContext & ctx)3971 void srgb_decode_texparameterfv (NegativeTestContext& ctx)
3972 {
3973 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
3974 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
3975 
3976 	GLfloat	params[1]	= {GL_LINEAR};
3977 	GLuint	texture		= 0x1234;
3978 
3979 	ctx.glGenTextures(1, &texture);
3980 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
3981 
3982 	params[0] = -1.0f;
3983 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
3984 	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
3985 	ctx.expectError(GL_INVALID_ENUM);
3986 	ctx.endSection();
3987 
3988 	ctx.glDeleteTextures(1, &texture);
3989 }
3990 
srgb_decode_texparameterIiv(NegativeTestContext & ctx)3991 void srgb_decode_texparameterIiv (NegativeTestContext& ctx)
3992 {
3993 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
3994 		TCU_THROW(NotSupportedError,"glTexParameterIiv is not supported.");
3995 
3996 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
3997 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
3998 
3999 	GLint	textureMode[]	= {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
4000 	GLuint	texture			= 0x1234;
4001 
4002 	ctx.glGenTextures(1, &texture);
4003 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
4004 
4005 	textureMode[0] = -1;
4006 	textureMode[1] = -1;
4007 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
4008 	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
4009 	ctx.expectError(GL_INVALID_ENUM);
4010 	ctx.endSection();
4011 
4012 	ctx.glDeleteTextures(1, &texture);
4013 }
4014 
srgb_decode_texparameterIuiv(NegativeTestContext & ctx)4015 void srgb_decode_texparameterIuiv (NegativeTestContext& ctx)
4016 {
4017 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
4018 		TCU_THROW(NotSupportedError,"glTexParameterIuiv is not supported.");
4019 
4020 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
4021 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
4022 
4023 	GLuint	textureMode[]	= {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
4024 	GLuint	texture			= 0x1234;
4025 
4026 	ctx.glGenTextures(1, &texture);
4027 	ctx.glBindTexture(GL_TEXTURE_2D, texture);
4028 
4029 	textureMode[0] = GL_DONT_CARE;
4030 	textureMode[1] = GL_DONT_CARE;
4031 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
4032 	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
4033 	ctx.expectError(GL_INVALID_ENUM);
4034 	ctx.endSection();
4035 
4036 	ctx.glDeleteTextures(1, &texture);
4037 }
4038 
getNegativeTextureApiTestFunctions()4039 std::vector<FunctionContainer> getNegativeTextureApiTestFunctions()
4040 {
4041 	FunctionContainer funcs[] =
4042 	{
4043 		{activetexture,									"activetexture",									"Invalid glActiveTexture() usage"		   },
4044 		{bindtexture,									"bindtexture",										"Invalid glBindTexture() usage"			   },
4045 		{compressedteximage2d_invalid_target,			"compressedteximage2d_invalid_target",				"Invalid glCompressedTexImage2D() usage"   },
4046 		{compressedteximage2d_invalid_format,			"compressedteximage2d_invalid_format",				"Invalid glCompressedTexImage2D() usage"   },
4047 		{compressedteximage2d_neg_level,				"compressedteximage2d_neg_level",					"Invalid glCompressedTexImage2D() usage"   },
4048 		{compressedteximage2d_max_level,				"compressedteximage2d_max_level",					"Invalid glCompressedTexImage2D() usage"   },
4049 		{compressedteximage2d_neg_width_height,			"compressedteximage2d_neg_width_height",			"Invalid glCompressedTexImage2D() usage"   },
4050 		{compressedteximage2d_max_width_height,			"compressedteximage2d_max_width_height",			"Invalid glCompressedTexImage2D() usage"   },
4051 		{compressedteximage2d_invalid_border,			"compressedteximage2d_invalid_border",				"Invalid glCompressedTexImage2D() usage"   },
4052 		{compressedteximage2d_invalid_size,				"compressedteximage2d_invalid_size",				"Invalid glCompressedTexImage2D() usage"   },
4053 		{compressedteximage2d_neg_size,					"compressedteximage2d_neg_size",					"Invalid glCompressedTexImage2D() usage"   },
4054 		{compressedteximage2d_invalid_width_height,		"compressedteximage2d_invalid_width_height",		"Invalid glCompressedTexImage2D() usage"   },
4055 		{compressedteximage2d_invalid_buffer_target,	"compressedteximage2d_invalid_buffer_target",		"Invalid glCompressedTexImage2D() usage"   },
4056 		{copyteximage2d_invalid_target,					"copyteximage2d_invalid_target",					"Invalid glCopyTexImage2D() usage"		   },
4057 		{copyteximage2d_invalid_format,					"copyteximage2d_invalid_format",					"Invalid glCopyTexImage2D() usage"		   },
4058 		{copyteximage2d_inequal_width_height_cube,		"copyteximage2d_inequal_width_height_cube",			"Invalid glCopyTexImage2D() usage"		   },
4059 		{copyteximage2d_neg_level,						"copyteximage2d_neg_level",							"Invalid glCopyTexImage2D() usage"		   },
4060 		{copyteximage2d_max_level,						"copyteximage2d_max_level",							"Invalid glCopyTexImage2D() usage"		   },
4061 		{copyteximage2d_neg_width_height,				"copyteximage2d_neg_width_height",					"Invalid glCopyTexImage2D() usage"		   },
4062 		{copyteximage2d_max_width_height,				"copyteximage2d_max_width_height",					"Invalid glCopyTexImage2D() usage"		   },
4063 		{copyteximage2d_invalid_border,					"copyteximage2d_invalid_border",					"Invalid glCopyTexImage2D() usage"		   },
4064 		{copyteximage2d_incomplete_framebuffer,			"copyteximage2d_incomplete_framebuffer",			"Invalid glCopyTexImage2D() usage"		   },
4065 		{copytexsubimage2d_invalid_target,				"copytexsubimage2d_invalid_target",					"Invalid glCopyTexSubImage2D() usage"	   },
4066 		{copytexsubimage2d_read_buffer_is_none,			"copytexsubimage2d_read_buffer_is_none",			"Invalid glCopyTexSubImage2D() usage"	   },
4067 		{copytexsubimage2d_texture_internalformat,		"copytexsubimage2d_texture_internalformat",			"Invalid glCopyTexSubImage2D() usage"	   },
4068 		{copytexsubimage2d_neg_level,					"copytexsubimage2d_neg_level",						"Invalid glCopyTexSubImage2D() usage"	   },
4069 		{copytexsubimage2d_max_level,					"copytexsubimage2d_max_level",						"Invalid glCopyTexSubImage2D() usage"	   },
4070 		{copytexsubimage2d_neg_offset,					"copytexsubimage2d_neg_offset",						"Invalid glCopyTexSubImage2D() usage"	   },
4071 		{copytexsubimage2d_invalid_offset,				"copytexsubimage2d_invalid_offset",					"Invalid glCopyTexSubImage2D() usage"	   },
4072 		{copytexsubimage2d_neg_width_height,			"copytexsubimage2d_neg_width_height",				"Invalid glCopyTexSubImage2D() usage"	   },
4073 		{copytexsubimage2d_incomplete_framebuffer,		"copytexsubimage2d_incomplete_framebuffer",			"Invalid glCopyTexSubImage2D() usage"	   },
4074 		{deletetextures,								"deletetextures",									"Invalid glDeleteTextures() usage"		   },
4075 		{generatemipmap,								"generatemipmap",									"Invalid glGenerateMipmap() usage"		   },
4076 		{gentextures,									"gentextures",										"Invalid glGenTextures() usage"			   },
4077 		{pixelstorei,									"pixelstorei",										"Invalid glPixelStorei() usage"			   },
4078 		{teximage2d,									"teximage2d",										"Invalid glTexImage2D() usage"			   },
4079 		{teximage2d_inequal_width_height_cube,			"teximage2d_inequal_width_height_cube",				"Invalid glTexImage2D() usage"			   },
4080 		{teximage2d_neg_level,							"teximage2d_neg_level",								"Invalid glTexImage2D() usage"			   },
4081 		{teximage2d_max_level,							"teximage2d_max_level",								"Invalid glTexImage2D() usage"			   },
4082 		{teximage2d_neg_width_height,					"teximage2d_neg_width_height",						"Invalid glTexImage2D() usage"			   },
4083 		{teximage2d_max_width_height,					"teximage2d_max_width_height",						"Invalid glTexImage2D() usage"			   },
4084 		{teximage2d_invalid_border,						"teximage2d_invalid_border",						"Invalid glTexImage2D() usage"			   },
4085 		{teximage2d_invalid_buffer_target,				"teximage2d_invalid_buffer_target",					"Invalid glTexImage2D() usage"			   },
4086 		{texsubimage2d,									"texsubimage2d",									"Invalid glTexSubImage2D() usage"		   },
4087 		{texsubimage2d_neg_level,						"texsubimage2d_neg_level",							"Invalid glTexSubImage2D() usage"		   },
4088 		{texsubimage2d_max_level,						"texsubimage2d_max_level",							"Invalid glTexSubImage2D() usage"		   },
4089 		{texsubimage2d_neg_offset,						"texsubimage2d_neg_offset",							"Invalid glTexSubImage2D() usage"		   },
4090 		{texsubimage2d_invalid_offset,					"texsubimage2d_invalid_offset",						"Invalid glTexSubImage2D() usage"		   },
4091 		{texsubimage2d_neg_width_height,				"texsubimage2d_neg_width_height",					"Invalid glTexSubImage2D() usage"		   },
4092 		{texsubimage2d_invalid_buffer_target,			"texsubimage2d_invalid_buffer_target",				"Invalid glTexSubImage2D() usage"		   },
4093 		{texparameteri,									"texparameteri",									"Invalid glTexParameteri() usage"		   },
4094 		{texparameterf,									"texparameterf",									"Invalid glTexParameterf() usage"		   },
4095 		{texparameteriv,								"texparameteriv",									"Invalid glTexParameteriv() usage"		   },
4096 		{texparameterfv,								"texparameterfv",									"Invalid glTexParameterfv() usage"		   },
4097 		{texparameterIiv,								"texparameterIiv",									"Invalid glTexParameterIiv() usage"		   },
4098 		{texparameterIuiv,								"texparameterIuiv",									"Invalid glTexParameterIuiv() usage"	   },
4099 		{compressedtexsubimage2d,						"compressedtexsubimage2d",							"Invalid glCompressedTexSubImage2D() usage"},
4100 		{compressedtexsubimage2d_neg_level,				"compressedtexsubimage2d_neg_level",				"Invalid glCompressedTexSubImage2D() usage"},
4101 		{compressedtexsubimage2d_max_level,				"compressedtexsubimage2d_max_level",				"Invalid glCompressedTexSubImage2D() usage"},
4102 		{compressedtexsubimage2d_neg_offset,			"compressedtexsubimage2d_neg_offset",				"Invalid glCompressedTexSubImage2D() usage"},
4103 		{compressedtexsubimage2d_invalid_offset,		"compressedtexsubimage2d_invalid_offset",			"Invalid glCompressedTexSubImage2D() usage"},
4104 		{compressedtexsubimage2d_neg_width_height,		"compressedtexsubimage2d_neg_width_height",			"Invalid glCompressedTexSubImage2D() usage"},
4105 		{compressedtexsubimage2d_invalid_size,			"compressedtexsubimage2d_invalid_size",				"Invalid glCompressedTexImage2D() usage"   },
4106 		{compressedtexsubimage2d_invalid_buffer_target,	"compressedtexsubimage2d_invalid_buffer_target",	"Invalid glCompressedTexSubImage2D() usage"},
4107 		{teximage3d,									"teximage3d",										"Invalid glTexImage3D() usage"			   },
4108 		{teximage3d_neg_level,							"teximage3d_neg_level",								"Invalid glTexImage3D() usage"			   },
4109 		{teximage3d_max_level,							"teximage3d_max_level",								"Invalid glTexImage3D() usage"			   },
4110 		{teximage3d_neg_width_height_depth,				"teximage3d_neg_width_height_depth",				"Invalid glTexImage3D() usage"			   },
4111 		{teximage3d_max_width_height_depth,				"teximage3d_max_width_height_depth",				"Invalid glTexImage3D() usage"			   },
4112 		{teximage3d_invalid_border,						"teximage3d_invalid_border",						"Invalid glTexImage3D() usage"			   },
4113 		{teximage3d_invalid_buffer_target,				"teximage3d_invalid_buffer_target",					"Invalid glTexImage3D() usage"			   },
4114 		{texsubimage3d,									"texsubimage3d",									"Invalid glTexSubImage3D() usage"		   },
4115 		{texsubimage3d_neg_level,						"texsubimage3d_neg_level",							"Invalid glTexSubImage3D() usage"		   },
4116 		{texsubimage3d_max_level,						"texsubimage3d_max_level",							"Invalid glTexSubImage3D() usage"		   },
4117 		{texsubimage3d_neg_offset,						"texsubimage3d_neg_offset",							"Invalid glTexSubImage3D() usage"		   },
4118 		{texsubimage3d_invalid_offset,					"texsubimage3d_invalid_offset",						"Invalid glTexSubImage3D() usage"		   },
4119 		{texsubimage3d_neg_width_height,				"texsubimage3d_neg_width_height",					"Invalid glTexSubImage3D() usage"		   },
4120 		{texsubimage3d_invalid_buffer_target,			"texsubimage3d_invalid_buffer_target",				"Invalid glTexSubImage3D() usage"		   },
4121 		{copytexsubimage3d,								"copytexsubimage3d",								"Invalid glCopyTexSubImage3D() usage"	   },
4122 		{copytexsubimage3d_neg_level,					"copytexsubimage3d_neg_level",						"Invalid glCopyTexSubImage3D() usage"	   },
4123 		{copytexsubimage3d_max_level,					"copytexsubimage3d_max_level",						"Invalid glCopyTexSubImage3D() usage"	   },
4124 		{copytexsubimage3d_neg_offset,					"copytexsubimage3d_neg_offset",						"Invalid glCopyTexSubImage3D() usage"	   },
4125 		{copytexsubimage3d_invalid_offset,				"copytexsubimage3d_invalid_offset",					"Invalid glCopyTexSubImage3D() usage"	   },
4126 		{copytexsubimage3d_neg_width_height,			"copytexsubimage3d_neg_width_height",				"Invalid glCopyTexSubImage3D() usage"	   },
4127 		{copytexsubimage3d_incomplete_framebuffer,		"copytexsubimage3d_incomplete_framebuffer",			"Invalid glCopyTexSubImage3D() usage"	   },
4128 		{compressedteximage3d,							"compressedteximage3d",								"Invalid glCompressedTexImage3D() usage"   },
4129 		{compressedteximage3d_neg_level,				"compressedteximage3d_neg_level",					"Invalid glCompressedTexImage3D() usage"   },
4130 		{compressedteximage3d_max_level,				"compressedteximage3d_max_level",					"Invalid glCompressedTexImage3D() usage"   },
4131 		{compressedteximage3d_neg_width_height_depth,	"compressedteximage3d_neg_width_height_depth",		"Invalid glCompressedTexImage3D() usage"   },
4132 		{compressedteximage3d_max_width_height_depth,	"compressedteximage3d_max_width_height_depth",		"Invalid glCompressedTexImage3D() usage"   },
4133 		{compressedteximage3d_invalid_border,			"compressedteximage3d_invalid_border",				"Invalid glCompressedTexImage3D() usage"   },
4134 		{compressedteximage3d_invalid_size,				"compressedteximage3d_invalid_size",				"Invalid glCompressedTexImage3D() usage"   },
4135 		{compressedteximage3d_invalid_width_height,		"compressedteximage3d_invalid_width_height",		"Invalid glCompressedTexImage3D() usage"   },
4136 		{compressedteximage3d_invalid_buffer_target,	"compressedteximage3d_invalid_buffer_target",		"Invalid glCompressedTexImage3D() usage"   },
4137 		{compressedtexsubimage3d,						"compressedtexsubimage3d",							"Invalid glCompressedTexSubImage3D() usage"},
4138 		{compressedtexsubimage3d_neg_level,				"compressedtexsubimage3d_neg_level",				"Invalid glCompressedTexSubImage3D() usage"},
4139 		{compressedtexsubimage3d_max_level,				"compressedtexsubimage3d_max_level",				"Invalid glCompressedTexSubImage3D() usage"},
4140 		{compressedtexsubimage3d_neg_offset,			"compressedtexsubimage3d_neg_offset",				"Invalid glCompressedTexSubImage3D() usage"},
4141 		{compressedtexsubimage3d_invalid_offset,		"compressedtexsubimage3d_invalid_offset",			"Invalid glCompressedTexSubImage3D() usage"},
4142 		{compressedtexsubimage3d_neg_width_height_depth,"compressedtexsubimage3d_neg_width_height_depth",	"Invalid glCompressedTexSubImage3D() usage"},
4143 		{compressedtexsubimage3d_invalid_size,			"compressedtexsubimage3d_invalid_size",				"Invalid glCompressedTexSubImage3D() usage"},
4144 		{compressedtexsubimage3d_invalid_buffer_target,	"compressedtexsubimage3d_invalid_buffer_target",	"Invalid glCompressedTexSubImage3D() usage"},
4145 		{texstorage2d,									"texstorage2d",										"Invalid glTexStorage2D() usage"		   },
4146 		{texstorage2d_invalid_binding,					"texstorage2d_invalid_binding",						"Invalid glTexStorage2D() usage"		   },
4147 		{texstorage2d_invalid_levels,					"texstorage2d_invalid_levels",						"Invalid glTexStorage2D() usage"		   },
4148 		{texstorage3d,									"texstorage3d",										"Invalid glTexStorage3D() usage"		   },
4149 		{texstorage3d_invalid_binding,					"texstorage3d_invalid_binding",						"Invalid glTexStorage3D() usage"		   },
4150 		{texstorage3d_invalid_levels,					"texstorage3d_invalid_levels",						"Invalid glTexStorage3D() usage"		   },
4151 		{srgb_decode_texparameteri,						"srgb_decode_texparameteri",						"Invalid texparameteri() usage srgb"	   },
4152 		{srgb_decode_texparameterf,						"srgb_decode_texparameterf",						"Invalid texparameterf() usage srgb"	   },
4153 		{srgb_decode_texparameteriv,					"srgb_decode_texparameteriv",						"Invalid texparameteriv() usage srgb"	   },
4154 		{srgb_decode_texparameterfv,					"srgb_decode_texparameterfv",						"Invalid texparameterfv() usage srgb"	   },
4155 		{srgb_decode_texparameterIiv,					"srgb_decode_texparameterIiv",						"Invalid texparameterIiv() usage srgb"	   },
4156 		{srgb_decode_texparameterIuiv,					"srgb_decode_texparameterIuiv",						"Invalid texparameterIuiv() usage srgb"	   },
4157 	};
4158 
4159 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
4160 }
4161 
4162 } // NegativeTestShared
4163 } // Functional
4164 } // gles31
4165 } // deqp
4166