13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Negative Texture API tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fNegativeTextureApiTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fNegativeTestShared.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
289ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi#include "gluContextInfo.hpp"
29bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe#include "gluRenderContext.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace NegativeTestShared
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::CallLogWrapper;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int divRoundUp (int a, int b)
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return a/b + (a%b != 0 ? 1 : 0);
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int etc2DataSize (int width, int height)
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (int)(divRoundUp(width, 4) * divRoundUp(height, 4) * sizeof(deUint64));
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int etc2EacDataSize (int width, int height)
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return 2 * etc2DataSize(width, height);
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic deUint32 cubeFaceToGLFace (tcu::CubeFace face)
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (face)
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::CUBEFACE_NEGATIVE_X: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::CUBEFACE_POSITIVE_X: return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::CUBEFACE_NEGATIVE_Y: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::CUBEFACE_POSITIVE_Y: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::CUBEFACE_NEGATIVE_Z: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::CUBEFACE_POSITIVE_Z: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(DE_FALSE);
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return GL_NONE;
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define FOR_CUBE_FACES(FACE_GL_VAR, BODY)												\
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	do																					\
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{																					\
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceIterTcu = 0; faceIterTcu < tcu::CUBEFACE_LAST; faceIterTcu++)		\
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{																				\
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLenum FACE_GL_VAR = cubeFaceToGLFace((tcu::CubeFace)faceIterTcu);	\
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			BODY																		\
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}																				\
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} while (false)
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glActiveTexture
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid activetexture (NegativeTestContext& ctx)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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).");
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glActiveTexture(-1);
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numMaxTextureUnits = ctx.getInteger(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glActiveTexture(GL_TEXTURE0 + numMaxTextureUnits);
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glBindTexture
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid bindtexture (NegativeTestContext& ctx)
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
106bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture[5];
107bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(5, texture);
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(0, 1);
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_FRAMEBUFFER, 1);
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if texture was previously created with a target that doesn't match that of target.");
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_3D, texture[0]);
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[0]);
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[1]);
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D, texture[1]);
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_3D, texture[1]);
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[1]);
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
134bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
135bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_3D, texture[2]);
136bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
137bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, texture[2]);
138bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
139bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[2]);
140bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
141bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[2]);
142bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
143bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
144bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[3]);
145bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
146bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, texture[3]);
147bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
148bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[3]);
149bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
150bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_3D, texture[3]);
151bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
152bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
153bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
154bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
155bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[0]);
156bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
157bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[1]);
158bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
159bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[2]);
160bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
161bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[3]);
162bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
163bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, texture[4]);
164bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_NO_ERROR);
165bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_2D, texture[4]);
166bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
167bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[4]);
168bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
169bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_3D, texture[4]);
170bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
171bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, texture[4]);
172bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
173bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
176bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(5, texture);
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glCompressedTexImage2D
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_invalid_target (NegativeTestContext& ctx)
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_invalid_format (NegativeTestContext& ctx)
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a supported format returned in GL_COMPRESSED_TEXTURE_FORMATS.");
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, 0, 0);
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, 0, 0);
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_neg_level (NegativeTestContext& ctx)
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_max_level (NegativeTestContext& ctx)
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for a 2d texture target.");
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE) for a cubemap target.");
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_neg_width_height (NegativeTestContext& ctx)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0);
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0);
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, 0, 0, 0);
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_max_width_height (NegativeTestContext& ctx)
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxCubemapSize = ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 1, 0, etc2EacDataSize(maxTextureSize, 1), 0);
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxTextureSize, 0, etc2EacDataSize(1, maxTextureSize), 0);
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, 0, etc2EacDataSize(maxTextureSize, maxTextureSize), 0);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, 1, 0, etc2EacDataSize(maxCubemapSize, 1), 0);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, maxCubemapSize, 0, etc2EacDataSize(1, maxCubemapSize), 0);
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxCubemapSize, maxCubemapSize, 0, etc2EacDataSize(maxCubemapSize, maxCubemapSize), 0);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_invalid_border (NegativeTestContext& ctx)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 1, 0, 0);
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_invalid_size (NegativeTestContext& ctx)
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
461bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	// Subtracting 1 to the imageSize field to deviate from the expected size. Removing the -1 would cause the imageSize to be correct.
462bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_R11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
463bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
464bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_R11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
465bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
466bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RG11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
467bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
468bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SIGNED_RG11_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
469bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
470bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
471bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
472bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
473bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
474bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
475bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
476bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 8 - 1, 0);
477bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
478bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
480bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
482bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
483bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
484bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
485bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_4x4, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
486bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
487bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_5x4, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 4) * 16 - 1, 0);
488bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
489bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_5x5, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 5) * 16 - 1, 0);
490bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
491bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_6x5, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 5) * 16 - 1, 0);
492bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
493bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_6x6, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 6) * 16 - 1, 0);
494bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
495bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x5, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 5) * 16 - 1, 0);
496bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
497bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x6, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 6) * 16 - 1, 0);
498bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
499bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x8, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 8) * 16 - 1, 0);
500bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
501bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x5, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 5) * 16 - 1, 0);
502bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
503bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x6, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 6) * 16 - 1, 0);
504bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
505bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x8, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 8) * 16 - 1, 0);
506bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
507bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_10x10, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 10) * 16 - 1, 0);
508bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
509bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_12x10, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 10) * 16 - 1, 0);
510bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
511bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_12x12, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 12) * 16 - 1, 0);
512bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
513bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4, 1, 1, 0, divRoundUp(1, 4) * divRoundUp(1, 4) * 16 - 1, 0);
514bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
515bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 4) * 16 - 1, 0);
516bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
517bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5, 1, 1, 0, divRoundUp(1, 5) * divRoundUp(1, 5) * 16 - 1, 0);
518bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
519bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 5) * 16 - 1, 0);
520bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
521bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6, 1, 1, 0, divRoundUp(1, 6) * divRoundUp(1, 6) * 16 - 1, 0);
522bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
523bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 5) * 16 - 1, 0);
524bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
525bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 6) * 16 - 1, 0);
526bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
527bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8, 1, 1, 0, divRoundUp(1, 8) * divRoundUp(1, 8) * 16 - 1, 0);
528bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
529bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 5) * 16 - 1, 0);
530bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
531bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 6) * 16 - 1, 0);
532bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
533bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 8) * 16 - 1, 0);
534bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
535bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10, 1, 1, 0, divRoundUp(1, 10) * divRoundUp(1, 10) * 16 - 1, 0);
536bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
537bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 10) * 16 - 1, 0);
538bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
539bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12, 1, 1, 0, divRoundUp(1, 12) * divRoundUp(1, 12) * 16 - 1, 0);
540bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	    ctx.expectError(GL_INVALID_VALUE);
541bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
542bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
543bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
544bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
545bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid compressedteximage2d_neg_size (NegativeTestContext& ctx)
546bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
547bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is negative.");
548bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_R11_EAC, 0, 0, 0, -1, 0);
549bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
550bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
551bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
552bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
553bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid compressedteximage2d_invalid_width_height (NegativeTestContext& ctx)
554bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
555bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if target is a cube map face and width and height are not equal.");
556bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
557bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
558bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
559bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
560bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
561bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
562bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
563bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
564bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
565bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
566bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
567bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
568bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
569bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
570bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
571bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
572bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
573bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
574bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
575bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
576bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
577bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
578bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
580bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
581bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
582bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
583bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_COMPRESSED_R11_EAC, 1, 2, 0, divRoundUp(1, 4) * divRoundUp(2, 4) * 8, 0);
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
586bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
587bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage2d_invalid_buffer_target (NegativeTestContext& ctx)
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				buf = 1234;
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>	data(64);
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers			(1, &buf);
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 0, etc2DataSize(4, 4), 0);
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 0, etc2DataSize(16, 16), 0);
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glCopyTexImage2D
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_invalid_target (NegativeTestContext& ctx)
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(0, 0, GL_RGB, 0, 0, 64, 64, 0);
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_invalid_format (NegativeTestContext& ctx)
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not an accepted format.");
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 64, 64, 0);
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 16, 16, 0);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 16, 16, 0);
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 16, 16, 0);
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 16, 16, 0);
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 16, 16, 0);
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 16, 16, 0);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_inequal_width_height_cube (NegativeTestContext& ctx)
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 16, 17, 0);
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 16, 17, 0);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 16, 17, 0);
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_neg_level (NegativeTestContext& ctx)
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 0, 0, 64, 64, 0);
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 0, 0, 16, 16, 0);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 0, 0, 16, 16, 0);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 0, 0, 16, 16, 0);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_max_level (NegativeTestContext& ctx)
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 0, 0, 64, 64, 0);
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 0, 0, 16, 16, 0);
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_neg_width_height (NegativeTestContext& ctx)
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, 1, 0);
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, -1, 0);
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, -1, -1, 0);
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, 1, 0);
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, -1, 0);
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, -1, -1, 0);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, 1, 0);
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, -1, 0);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, -1, -1, 0);
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, 1, 0);
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, -1, 0);
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, -1, -1, 0);
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_max_width_height (NegativeTestContext& ctx)
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxCubemapSize = ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, 1, 0);
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1, maxTextureSize, 0);
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, maxTextureSize, maxTextureSize, 0);
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 1, maxCubemapSize, 0);
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, 1, 0);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, maxCubemapSize, maxCubemapSize, 0);
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_invalid_border (NegativeTestContext& ctx)
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, -1);
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 0, 0, 1);
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, -1);
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 0, 0, 0, 0, 1);
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, -1);
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 0, 0, 0, 0, 1);
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, -1);
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 0, 0, 0, 0, 1);
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copyteximage2d_incomplete_framebuffer (NegativeTestContext& ctx)
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0x1234;
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers		(1, &fbo);
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer		(GL_FRAMEBUFFER, fbo);
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, 0, 0, 0, 0, 0);
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer	(GL_FRAMEBUFFER, 0);
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_invalid_target (NegativeTestContext& ctx)
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(0, 0, 0, 0, 0, 0, 4, 4);
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
949bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid copytexsubimage2d_read_buffer_is_none (NegativeTestContext& ctx)
950bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
951bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture = 0x1234;
952bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures	(1, &texture);
953bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
954bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
955bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
956bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_OPERATION is generated if the read buffer is NONE");
957bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glReadBuffer(GL_NONE);
958bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
959bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
960bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
961bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
962bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(1, &texture);
963bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
964bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
965bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid copytexsubimage2d_texture_internalformat (NegativeTestContext& ctx)
966bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
967bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture = 0x1234;
968bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures	(1, &texture);
969bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
970bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGB9_E5, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
971bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
972bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_OPERATION is generated if internal format of the texture is GL_RGB9_E5");
973bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
974bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
975bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
976bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
977bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(1, &texture);
978bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_neg_level (NegativeTestContext& ctx)
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint textures[2];
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(2, &textures[0]);
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_2D, textures[0]);
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP, textures[1]);
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, 4, 4);
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL,
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glCopyTexSubImage2D(faceGL, -1, 0, 0, 0, 0, 4, 4);
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	});
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, &textures[0]);
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_max_level (NegativeTestContext& ctx)
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint textures[2];
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(2, &textures[0]);
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_2D, textures[0]);
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP, textures[1]);
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0););
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE) for 2D texture targets.");
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, 4, 4);
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_SIZE) for cubemap targets.");
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL,
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glCopyTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, 4, 4);
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	});
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, &textures[0]);
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_neg_offset (NegativeTestContext& ctx)
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset < 0 or yoffset < 0.");
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, 4, 4);
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, 4, 4);
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, 4, 4);
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_invalid_offset (NegativeTestContext& ctx)
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 0, 0, 0, 4, 4);
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 14, 0, 0, 4, 4);
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 14, 14, 0, 0, 4, 4);
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_neg_width_height (NegativeTestContext& ctx)
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_2D, texture);
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D	(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, 0);
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, -1);
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1);
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage2d_incomplete_framebuffer (NegativeTestContext& ctx)
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture[2];
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0x1234;
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(2, texture);
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture[0]);
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_CUBE_MAP, texture[1]);
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0);
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 0, 0);
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 0, 0, 0, 0);
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 0, 0);
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 0, 0);
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 0, 0);
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 0, 0);
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, texture);
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glDeleteTextures
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid deletetextures (NegativeTestContext& ctx)
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures(1, &texture);
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(-1, 0);
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D, texture);
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(-1, 0);
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glGenerateMipmap
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid generatemipmap (NegativeTestContext& ctx)
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture[2];
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures(2, texture);
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.");
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenerateMipmap(0);
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("INVALID_OPERATION is generated if the texture bound to target is not cube complete.");
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the zero level array is stored in a compressed internal format.");
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D, texture[1]);
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0);
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenerateMipmap(GL_TEXTURE_2D);
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 0, 0, 0, GL_RGB, GL_BYTE, 0);
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenerateMipmap(GL_TEXTURE_2D);
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, 0);
11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenerateMipmap(GL_TEXTURE_2D);
11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11959ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi
11969ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi	if (!(ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_float") && ctx.getContextInfo().isExtensionSupported("GL_OES_texture_float_linear")))
11979ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi	{
11989ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi		ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
11999ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi		ctx.glGenerateMipmap(GL_TEXTURE_2D);
12009ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi		ctx.expectError(GL_INVALID_OPERATION);
12019ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi	}
12029ffcdca48772cb951540a7ce02b11a42a2b35c3bMika Isojärvi
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, texture);
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glGenTextures
12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid gentextures (NegativeTestContext& ctx)
12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures(-1, 0);
12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glPixelStorei
12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid pixelstorei (NegativeTestContext& ctx)
12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(0,1);
12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_PACK_ROW_LENGTH, -1);
12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_PACK_SKIP_ROWS, -1);
12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_PACK_SKIP_PIXELS, -1);
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_ROW_LENGTH, -1);
12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, -1);
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_SKIP_ROWS, -1);
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_SKIP_PIXELS, -1);
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_SKIP_IMAGES, -1);
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_PACK_ALIGNMENT, 0);
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_PACK_ALIGNMENT, 16);
12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 16);
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexImage2D
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d (NegativeTestContext& ctx)
12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(0, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 0, 0);
12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_inequal_width_height_cube (NegativeTestContext& ctx)
12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_neg_level (NegativeTestContext& ctx)
13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_max_level (NegativeTestContext& ctx)
13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, log2MaxTextureSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, log2MaxCubemapSize, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_neg_width_height (NegativeTestContext& ctx)
13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_2D target");
13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -1, -1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_max_width_height (NegativeTestContext& ctx)
14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxCubemapSize = ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE) + 1;
14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_TEXTURE_SIZE.");
14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maxTextureSize, maxTextureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE.");
14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_X target");
14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Y target");
14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_POSITIVE_Z target");
14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_X target");
14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Y target");
14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_TEXTURE_CUBE_MAP_NEGATIVE_Z target");
14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, maxCubemapSize, maxCubemapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_invalid_border (NegativeTestContext& ctx)
14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 0);
15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage2d_invalid_buffer_target (NegativeTestContext& ctx)
15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				buf = 0x1234;
15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>	data(64);
15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers			(1, &buf);
15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the buffer object's data store is currently mapped.");
15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGB5_A1, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (const GLvoid*)3);
15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexSubImage2D
15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d (NegativeTestContext& ctx)
15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			texture = 0x1234;
15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(1, &texture);
15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D, texture);
15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(0, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if format is not an accepted format constant.");
15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, GL_UNSIGNED_BYTE, 0);
15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, 0, 0);
15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.");
15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, 0);
15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGB, GL_FLOAT, 0);
15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures	(1, &texture);
15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d_neg_level (NegativeTestContext& ctx)
15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			textures[2];
15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(2, &textures[0]);
15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D, textures[0]);
15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D, textures[1]);
16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL,
16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	});
16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, &textures[0]);
16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d_max_level (NegativeTestContext& ctx)
16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			textures[2];
16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(2, &textures[0]);
16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D, textures[0]);
16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_CUBE_MAP, textures[1]);
16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL, ctx.glTexImage2D(faceGL, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0););
16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL,
16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	});
16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, &textures[0]);
16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d_neg_offset (NegativeTestContext& ctx)
16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 texture = 0x1234;
16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures(1, &texture);
16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D, texture);
16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset or yoffset are negative.");
16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, -1, -1, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d_invalid_offset (NegativeTestContext& ctx)
16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			texture = 0x1234;
16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(1, &texture);
16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D, texture);
16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 30, 30, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures	(1, &texture);
16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d_neg_width_height (NegativeTestContext& ctx)
16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			texture = 0x1234;
16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(1, &texture);
16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D, texture);
16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D		(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures	(1, &texture);
17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage2d_invalid_buffer_target (NegativeTestContext& ctx)
17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				buf = 0x1234;
17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>	data(64);
17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers			(1, &buf);
17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the buffer object's data store is currently mapped.");
17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 32, GL_MAP_WRITE_BIT);
17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 32, 32, GL_RGBA, GL_UNSIGNED_BYTE, 0);
17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, 0);
17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage2D			(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexParameteri
17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texparameteri (NegativeTestContext& ctx)
17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1754bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture = 0x1234;
1755bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLint textureMode = -1;
1756bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1757bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(1, &texture);
1758bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, texture);
1759bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteri(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteri(GL_TEXTURE_2D, 0, GL_LINEAR);
17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteri(0, 0, GL_LINEAR);
17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1769bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
1770bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
1771bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1772bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
1773bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1774bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1776bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1778bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1780bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
1781bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1782bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
1783bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1784bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
1785bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1786bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
1787bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1788bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
1789bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1790bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
1791bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1792bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1796bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
1797bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, -1);
1798bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1799bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, -1);
1800bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1801bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1804bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
1805bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.beginSection("GL_INVALID_ENUM is generated if pname is a non-scalar parameter.");
1806bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, 0);
1807bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1808bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.endSection();
1809bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
1810bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1811bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
1812bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1814bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1816bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1818bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
1819bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1820bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
1821bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1822bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
1823bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1824bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1826bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1828bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1830bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1832bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1833bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1834bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
1835bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
1836bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1837bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
1838bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1839bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
1840bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1841bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
1842bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1843bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
1844bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1845bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
1846bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1847bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
1848bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1849bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
1850bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1851bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
1852bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1853bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
1854bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1855bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
1856bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
1857bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1858bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
1859bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, 1);
1860bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
1861bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1862bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1863bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
1864bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, 1);
1865bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
1866bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexParameterf
18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texparameterf (NegativeTestContext& ctx)
18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1876bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture = 0x1234;
1877bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLfloat textureMode = -1.0f;
1878bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(1, &texture);
1879bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, texture);
1880bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterf(0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterf(GL_TEXTURE_2D, 0, GL_LINEAR);
18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterf(0, 0, GL_LINEAR);
18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1890bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
1891bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
1892bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1893bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
1894bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1895bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
1896bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1897bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
1898bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1899bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
1900bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1901bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
1902bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1903bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
1904bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1905bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
1906bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1907bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1909bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1911bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1913bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1917bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
1918bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, -1.0f);
1919bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1920bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, -1.0f);
1921bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1922bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1924bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1925bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
1926bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.beginSection("GL_INVALID_ENUM is generated if pname is a non-scalar parameter.");
1927bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, 0.0f);
1928bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1929bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.endSection();
1930bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
1931bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1932bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
1933bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1935bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1937bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1939bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
1940bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1941bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1943bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1945bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1947bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1949bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
1950bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1951bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
1952bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1953bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1954bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1955bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
1956bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
1957bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1958bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
1959bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1960bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
1961bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1962bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
1963bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1964bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
1965bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1966bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
1967bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1968bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
1969bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1970bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
1971bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1972bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
1973bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1974bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
1975bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
1976bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
1977bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
1978bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1979bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
1980bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, 1.0f);
1981bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
1982bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
1983bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
1984bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
1985bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterf(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, 1.0f);
1986bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
1987bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexParameteriv
19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texparameteriv (NegativeTestContext& ctx)
19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint params[1] = {GL_LINEAR};
199880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
1999bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture = 0x1234;
2000bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(1, &texture);
2001bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, texture);
2002bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2003bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(GL_TEXTURE_2D, 0, &params[0]);
20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(0, 0, &params[0]);
20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2012bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2013bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	params[0] = -1;
2014bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &params[0]);
2015bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2016bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, &params[0]);
2017bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2018bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2019bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2024bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, &params[0]);
2025bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2026bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, &params[0]);
2027bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2028bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, &params[0]);
2029bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2030bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, &params[0]);
2031bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2036bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, &params[0]);
2037bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2040bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
2041bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &params[0]);
2042bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2043bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &params[0]);
2044bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2045bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2047bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2048bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, &params[0]);
20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2050bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, &params[0]);
20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2052bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, &params[0]);
20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2054bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, &params[0]);
20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2056bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, &params[0]);
20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2058bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, &params[0]);
20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2060bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, &params[0]);
2061bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2062bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, &params[0]);
2063bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2064bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, &params[0]);
2065bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2066bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, &params[0]);
20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2068bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2069bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2070bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2071bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, &params[0]);
2072bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2073bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, &params[0]);
2074bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2075bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, &params[0]);
2076bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2077bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, &params[0]);
2078bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2079bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, &params[0]);
2080bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2081bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, &params[0]);
2082bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2083bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, &params[0]);
2084bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2085bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, &params[0]);
2086bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2087bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, &params[0]);
2088bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2089bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2090bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2091bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
2092bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2093bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2094bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2095bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	params[0] = 1;
2096bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, &params[0]);
2097bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
2098bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2099bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2100bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2101bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		params[0] = 1;
2102bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, &params[0]);
2103bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
2104bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
21053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
21063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
21083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
21093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexParameterfv
21113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texparameterfv (NegativeTestContext& ctx)
21133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat params[1] = {GL_LINEAR};
2115bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint texture = 0x1234;
2116bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(1, &texture);
2117bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, texture);
2118bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2119bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.");
2120bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	params[0] = GL_LINEAR;
21213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(0, GL_TEXTURE_MIN_FILTER, &params[0]);
21223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
21233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(GL_TEXTURE_2D, 0, &params[0]);
21243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
21253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(0, 0, &params[0]);
21263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
21273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
21283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2129bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2130bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	params[0] = -1.0f;
2131bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &params[0]);
2132bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2133bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, &params[0]);
2134bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2135bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2136bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
21373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &params[0]);
21383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
21393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &params[0]);
21403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2141bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, &params[0]);
2142bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2143bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, &params[0]);
2144bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2145bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, &params[0]);
2146bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2147bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, &params[0]);
2148bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
21493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &params[0]);
21503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
21513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &params[0]);
21523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2153bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, &params[0]);
2154bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
21553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
21563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2157bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
2158bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &params[0]);
2159bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2160bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &params[0]);
2161bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2162bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
21633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2164bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2165bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, &params[0]);
21663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2167bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, &params[0]);
21683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2169bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, &params[0]);
21703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2171bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, &params[0]);
21723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2173bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, &params[0]);
21743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2175bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, &params[0]);
21763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2177bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, &params[0]);
2178bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2179bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, &params[0]);
2180bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2181bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, &params[0]);
2182bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2183bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, &params[0]);
21843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2185bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2186bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2187bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2188bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, &params[0]);
2189bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2190bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, &params[0]);
2191bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2192bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, &params[0]);
2193bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2194bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, &params[0]);
2195bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2196bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, &params[0]);
2197bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2198bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, &params[0]);
2199bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2200bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, &params[0]);
2201bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2202bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, &params[0]);
2203bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2204bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, &params[0]);
2205bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2206bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, &params[0]);
2207bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_ENUM);
2208bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
2209bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2210bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2211bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2212bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	params[0] = 1.0f;
2213bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, &params[0]);
2214bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
2215bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2216bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_storage_multisample_2d_array"))
2217bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2218bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		params[0] = 1.0f;
2219bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexParameterfv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, &params[0]);
2220bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
2221bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
2222bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
22233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
22253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
22263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2227bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe// glTexParameterIiv
2228bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2229bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid texparameterIiv (NegativeTestContext& ctx)
2230bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
2231bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
2232bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		throw tcu::NotSupportedError("glTexParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
2233bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2234bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
2235bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if target is not a valid target.");
2236bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(0, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2237bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2238bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2239bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2240bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not a valid parameter.");
2241bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, 0, textureMode);
2242bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2243bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2244bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2245bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2246bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[0] = -1;
2247bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[1] = -1;
2248bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2249bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2250bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
2251bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2252bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
2253bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2254bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
2255bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2256bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
2257bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2258bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
2259bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2260bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
2261bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2262bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
2263bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2264bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
2265bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2266bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
2267bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2268bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
2269bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2270bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
2271bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2272bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2273bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2274bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if pname is GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL and param(s) is negative.");
2275bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, textureMode);
2276bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2277bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, textureMode);
2278bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2279bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2280bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2281bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2282bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[0] = 0;
2283bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[1] = 0;
2284bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
2285bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2286bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
2287bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2288bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
2289bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2290bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
2291bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2292bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
2293bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2294bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
2295bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2296bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
2297bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2298bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
2299bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2300bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
2301bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2302bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
2303bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2304bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2305bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
2306bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2307bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
2308bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2309bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
2310bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2311bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
2312bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2313bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
2314bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2315bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
2316bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2317bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
2318bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2319bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
2320bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2321bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
2322bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2323bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
2324bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2325bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2326bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2327bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2328bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[0] = 1;
2329bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[1] = 1;
2330bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, textureMode);
2331bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
2332bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, textureMode);
2333bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
2334bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2335bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
2336bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2337bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe// glTexParameterIuiv
2338bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2339bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid texparameterIuiv (NegativeTestContext& ctx)
2340bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
2341bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
2342bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		throw tcu::NotSupportedError("glTexParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
2343bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2344bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	GLuint textureMode[] = { GL_DEPTH_COMPONENT, GL_STENCIL_INDEX };
2345bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if target is not a valid target.");
2346bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(0, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2347bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2348bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2349bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2350bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not a valid parameter.");
2351bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, 0, textureMode);
2352bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2353bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2354bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2355bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if pname is enum and the value of param(s) is not a valid value.");
2356bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[0] = GL_DONT_CARE;
2357bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, textureMode);
2358bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2359bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, textureMode);
2360bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2361bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, textureMode);
2362bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2363bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, textureMode);
2364bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2365bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, textureMode);
2366bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2367bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, textureMode);
2368bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2369bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, textureMode);
2370bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2371bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, textureMode);
2372bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2373bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, textureMode);
2374bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2375bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureMode);
2376bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2377bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureMode);
2378bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2379bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, textureMode);
2380bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2381bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2382bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2383bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2384bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[0] = 0;
2385bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[1] = 0;
2386bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BORDER_COLOR, textureMode);
2387bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2388bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, textureMode);
2389bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2390bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, textureMode);
2391bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2392bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, textureMode);
2393bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2394bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, textureMode);
2395bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2396bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_R, textureMode);
2397bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2398bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_LOD, textureMode);
2399bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2400bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LOD, textureMode);
2401bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2402bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_MODE, textureMode);
2403bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2404bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_COMPARE_FUNC, textureMode);
2405bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2406bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2407bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BORDER_COLOR, textureMode);
2408bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2409bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_FILTER, textureMode);
2410bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2411bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAG_FILTER, textureMode);
2412bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2413bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_S, textureMode);
2414bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2415bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_T, textureMode);
2416bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2417bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_WRAP_R, textureMode);
2418bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2419bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MIN_LOD, textureMode);
2420bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2421bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_MAX_LOD, textureMode);
2422bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2423bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_MODE, textureMode);
2424bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2425bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_COMPARE_FUNC, textureMode);
2426bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2427bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2428bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2429bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	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.");
2430bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[0] = 1;
2431bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	textureMode[1] = 1;
2432bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, textureMode);
2433bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
2434bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexParameterIuiv(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_BASE_LEVEL, textureMode);
2435bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
2436bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.endSection();
2437bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
2438bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
24393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glCompressedTexSubImage2D
24403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d (NegativeTestContext& ctx)
24423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
24433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
24443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
24453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
24463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
24473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
24493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
24503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
24513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
24523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
24533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
24553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
24563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
24573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
24583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
24603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 4, 0, 10, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
24613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
24623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
24633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
24653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 4, 4, 10, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
24663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
24673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
24683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
24703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
24713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
24723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
24733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
24743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
24753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
24763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
24773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
24793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
24803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_neg_level (NegativeTestContext& ctx)
24823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
24833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				textures[2];
24843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(2, &textures[0]);
24853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, textures[0]);
24863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
24873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_CUBE_MAP, textures[1]);
24883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL, ctx.glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
24893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
24903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
24923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
24933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
24943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
24953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
24973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL,
24983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
24993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glCompressedTexSubImage2D(faceGL, -1, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
25013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	});
25023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
25033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, &textures[0]);
25053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
25063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_max_level (NegativeTestContext& ctx)
25083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
25093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				textures[2];
25103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(2, &textures[0]);
25113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, textures[0]);
25123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0);
25133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_CUBE_MAP, textures[1]);
25143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL, ctx.glCompressedTexImage2D(faceGL, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 0, etc2EacDataSize(18, 18), 0););
25153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
25163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
25183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
25193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, log2MaxTextureSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
25213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
25223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
25243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxCubemapSize = deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
25253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FOR_CUBE_FACES(faceGL,
25263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
25273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glCompressedTexSubImage2D(faceGL, log2MaxCubemapSize, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
25293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	});
25303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
25313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, &textures[0]);
25333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
25343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_neg_offset (NegativeTestContext& ctx)
25363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
25373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
25383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures(1, &texture);
25393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture(GL_TEXTURE_2D, texture);
25403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 8, 8, 0, etc2EacDataSize(8, 8), 0);
25413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note Both GL_INVALID_VALUE and GL_INVALID_OPERATION are valid here since implementation may
25433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	//		 first check if offsets are valid for certain format and only after that check that they
25443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	//		 are not negative.
25453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset or yoffset are negative.");
25463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -4, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
25553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
25573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
25583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_invalid_offset (NegativeTestContext& ctx)
25603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
25613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
25623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
25633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
25643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
25653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
25663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
25683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 0, 8, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
25703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 12, 4, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
25723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 12, 12, 8, 8, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
25743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
25763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
25783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
25793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_neg_width_height (NegativeTestContext& ctx)
25813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
25823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
25833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
25843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
25853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
25863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
25873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width or height is less than 0.");
25893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
25943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
25953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
25963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1,		&texture);
25983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
25993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_invalid_size (NegativeTestContext& ctx)
26013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
26023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
26033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
26043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D, texture);
26053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D	(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
26063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
26073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
26093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
26103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
26113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
26133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
26143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
26173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
26183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage2d_invalid_buffer_target (NegativeTestContext& ctx)
26203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
26213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
26223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					texture = 0x1234;
26233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>		data(128);
26243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures				(1, &texture);
26263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture				(GL_TEXTURE_2D, texture);
26273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage2D		(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 0, etc2EacDataSize(16, 16), 0);
26283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
26293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_PIXEL_UNPACK_BUFFER, buf);
26303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_PIXEL_UNPACK_BUFFER, 128, &data[0], GL_DYNAMIC_COPY);
26313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
26323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
26343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the buffer object's data store is currently mapped.");
26353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange			(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
26363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D	(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
26373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
26383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer				(GL_PIXEL_UNPACK_BUFFER);
26393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
26423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage2D	(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
26433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
26443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
26483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
26493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
26503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexImage3D
26523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d (NegativeTestContext& ctx)
26543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
26553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
26563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(0, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
26573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
26583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
26593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
26603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
26633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 0, 0);
26643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
26653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if format is not an accepted format constant.");
26683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, 0, GL_UNSIGNED_BYTE, 0);
26693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
26703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if internalFormat is not one of the accepted resolution and format symbolic constants.");
26733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, 0, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
26743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
26753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if target is GL_TEXTURE_3D and format is GL_DEPTH_COMPONENT, or GL_DEPTH_STENCIL.");
2678ae7f8e0a07730e693b24d3dc7a23d2372319145eKenneth Graunke	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_STENCIL, 1, 1, 1, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
26793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2680ae7f8e0a07730e693b24d3dc7a23d2372319145eKenneth Graunke	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_DEPTH_COMPONENT, 1, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
26813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
26823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
26833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat, format and type is invalid.");
26853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
26863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
26873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
26883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
26893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB5_A1, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
26903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
26913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB10_A2, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, 0);
26923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
26933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, 1, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, 0);
26943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
26953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2696bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2697bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2698bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2699bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TEXTURE_CUBE_MAP_ARRAY and width and height are not equal.");
2700bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 2, 1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2701bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2702bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.endSection();
2703bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2704bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TEXTURE_CUBE_MAP_ARRAY and depth is not a multiple of six.");
2705bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2706bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2707bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.endSection();
2708bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
27093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
27103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d_neg_level (NegativeTestContext& ctx)
27123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
27143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
27153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
27173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2718bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2719bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2720bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2721bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, -1, GL_RGBA, 1, 1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2722bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2723bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
2724bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
27253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2726bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
27273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
27283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d_max_level (NegativeTestContext& ctx)
27303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
27323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2Max3DTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE)) + 1;
27333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
27343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
27363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
27383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
27393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_RGB, 1, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
27403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
27423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
27433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d_neg_width_height_depth (NegativeTestContext& ctx)
27453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than 0.");
27473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, -1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, -1, -1, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2764bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2765bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2766bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2767bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, -1, 1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2768bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2769bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 1, -1, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2770bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2771bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 1, 1, -6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2772bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2773bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, -1, -1, -6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2774bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2775bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
27763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
27773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
27783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d_max_width_height_depth (NegativeTestContext& ctx)
27803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int max3DTextureSize	= ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE) + 1;
27823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxTextureSize		= ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
27833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_3D_TEXTURE_SIZE.");
27853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, max3DTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, max3DTextureSize, max3DTextureSize, max3DTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
27943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
27963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
27983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, maxTextureSize, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
27993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
28003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 1, 1, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
28023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxTextureSize, maxTextureSize, maxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
28043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
28063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d_invalid_border (NegativeTestContext& ctx)
28083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
28093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0 or 1.");
28103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
28113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
28123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
28133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
28143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, -1, GL_RGB, GL_UNSIGNED_BYTE, 0);
28153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
28163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 1, 1, 1, 2, GL_RGB, GL_UNSIGNED_BYTE, 0);
28173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2818bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2819bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2820bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
2821bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA, 1, 1, 6, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2822bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2823bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA, 1, 1, 6, 1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2824bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2825bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
2826bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
28273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
28293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid teximage3d_invalid_buffer_target (NegativeTestContext& ctx)
28313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
28323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				buf = 0x1234;
28333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
28343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>	data(512);
28353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers			(1, &buf);
28373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
28383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
28393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
28403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_3D, texture);
28413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
28423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
28443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the buffer object's data store is currently mapped.");
28463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 128, GL_MAP_WRITE_BIT);
28473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
28493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
28503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
28533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 64, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
28553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
28583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
28593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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);
28603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
28613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
28663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
28673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
28683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexSubImage3D
28703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d (NegativeTestContext& ctx)
28723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
28733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			texture = 0x1234;
28743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(1, &texture);
28753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_3D, texture);
28763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
28783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
28803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(0, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
28823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
28833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
28843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if format is not an accepted format constant.");
28873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 4, 4, 4, GL_UNSIGNED_BYTE, 0);
28883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
28893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not a type constant.");
28923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, 0, 0);
28933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
28943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
28953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of internalFormat of the previously specified texture array, format and type is not valid.");
28973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, 0);
28983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
28993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
29003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
29013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, 0);
29023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
29033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 0);
29043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
29053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGB, GL_FLOAT, 0);
29063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
29073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
29083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures	(1, &texture);
29103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
29113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d_neg_level (NegativeTestContext& ctx)
29133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2914bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32			textures[3];
2915bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures		(3, &textures[0]);
29163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_3D, textures[0]);
29173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
29193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
29213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
29233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2927bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2928bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2929bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
293002975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese		ctx.glBindTexture		(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
293102975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese		ctx.glTexImage3D		(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
293202975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese		ctx.expectError			(GL_NO_ERROR);
293302975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese
2934bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
2935bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
2936bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
2937bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
29383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
29393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2940bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures	(3, &textures[0]);
29413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
29423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d_max_level (NegativeTestContext& ctx)
29443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
29453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			textures[2];
29463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(2, &textures[0]);
29473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_3D, textures[0]);
29483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
29503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
29523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2Max3DTextureSize	= deLog2Floor32(ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE)) + 1;
29543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize		= deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
29553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
29573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
29603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
29623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
29653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures	(2, &textures[0]);
29673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
29683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d_neg_offset (NegativeTestContext& ctx)
29703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2971bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32			textures[3];
2972bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures		(3, &textures[0]);
29733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_3D, textures[0]);
29743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_2D_ARRAY, textures[1]);
29763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
29783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.");
29803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
29943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
29953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2996bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
2997bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
2998bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
299902975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese		ctx.glBindTexture		(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
300002975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese		ctx.glTexImage3D		(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
300102975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese		ctx.expectError			(GL_NO_ERROR);
300202975695151c5dab312ece3a8bb492c07ed1244aGraeme Leese
3003bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, -1, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3004bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3005bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, -1, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3006bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3007bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3008bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3009bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, -1, -1, -1, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3010bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3011bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
3012bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
30133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3015bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures	(3, &textures[0]);
30163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
30173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d_invalid_offset (NegativeTestContext& ctx)
30193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
30203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			texture = 0x1234;
30213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures		(1, &texture);
30223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture		(GL_TEXTURE_3D, texture);
30233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D		(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_NO_ERROR);
30253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
30273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 2, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
30293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
30323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 2, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
30343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if zoffset + depth > texture_depth.");
30373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
30393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures	(1, &texture);
30423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
30433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d_neg_width_height (NegativeTestContext& ctx)
30453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
30463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
30473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
30493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
30513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
30533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3055bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3056bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3057bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3058bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, -1, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3059bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3060bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, 0, -1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3061bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3062bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, 0, 0, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3063bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3064bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, -1, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3065bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3066bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
3067bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
30683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
30703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texsubimage3d_invalid_buffer_target (NegativeTestContext& ctx)
30723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
30733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				buf = 0x1234;
30743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
30753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>	data(512);
30763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
30783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_3D, texture);
30793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers			(1, &buf);
30813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
30823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 512, &data[0], GL_DYNAMIC_COPY);
30833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
30843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
30863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the buffer object's data store is currently mapped.");
30883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 512, GL_MAP_WRITE_BIT);
30893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
30913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
30923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
30953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 16, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
30963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
30973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
30983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.");
31003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// Set byte offset = 3" << TestLog::EndMessage;
31013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, 0);
31023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0);
31033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
31043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
31053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexSubImage3D			(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (const GLvoid*)3);
31063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
31073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
31083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
31103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
31123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
31133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
31143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glCopyTexSubImage3D
31163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d (NegativeTestContext& ctx)
31183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
31193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
31203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
31213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
31223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
31233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
31253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 4, 4);
31263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
31273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
31283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
31303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
31313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d_neg_level (NegativeTestContext& ctx)
31333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3134bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32	textures[3];
3135bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(3, &textures[0]);
3136bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3137bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3138bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
3139bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3140bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
31413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
31433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, -1, 0, 0, 0, 0, 0, 4, 4);
31443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
31453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
31463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3147bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3148bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3149bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3150bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
3151bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3152bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_NO_ERROR);
3153bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, -1, 0, 0, 0, 0, 0, 4, 4);
3154bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3155bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
3156bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
31573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
31583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3159bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(3, &textures[0]);
31603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
31613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d_max_level (NegativeTestContext& ctx)
31633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3164bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32	log2Max3DTextureSize		= deLog2Floor32(ctx.getInteger(GL_MAX_3D_TEXTURE_SIZE)) + 1;
3165bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32	log2MaxTextureSize			= deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
3166bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32	log2MaxCubeMapTextureSize	= deLog2Floor32(ctx.getInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1;
31673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3168bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32	textures[3];
3169bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(3, &textures[0]);
3170bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3171bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3172bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
3173bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3174bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
31753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_3D_TEXTURE_SIZE).");
31773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, log2Max3DTextureSize, 0, 0, 0, 0, 0, 4, 4);
31783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
31793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
31803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
31823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 4, 4);
31833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
31843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
31853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3186bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3187bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3188bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[2]);
3189bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, 4, 4, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
3190bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_NO_ERROR);
3191bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_CUBE_MAP_TEXTURE_SIZE).");
3192bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, log2MaxCubeMapTextureSize, 0, 0, 0, 0, 0, 4, 4);
3193bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3194bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.endSection();
3195bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
3196bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3197bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(3, &textures[0]);
31983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
31993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d_neg_offset (NegativeTestContext& ctx)
32013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
32033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
32043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
32053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
32063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is negative.");
32083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, 0,  0, 0, 0, 4, 4);
32093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, -1, 0, 0, 0, 4, 4);
32113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, -1, 0, 0, 4, 4);
32133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, -1, -1, -1, 0, 0, 4, 4);
32153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
32193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
32203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d_invalid_offset (NegativeTestContext& ctx)
32223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
32243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
32253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
32263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
32273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if xoffset + width > texture_width.");
32293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0, 0, 0, 4, 4);
32303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if yoffset + height > texture_height.");
32343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 1, 0, 0, 0, 4, 4);
32353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if zoffset + 1 > texture_depth.");
32393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, 0, 0, 4, 4);
32403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
32443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
32453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d_neg_width_height (NegativeTestContext& ctx)
32473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture = 0x1234;
32493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures	(1, &texture);
32503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture	(GL_TEXTURE_3D, texture);
32513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D	(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
32523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width < 0.");
32543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, -4, 4);
32553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if height < 0.");
32593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, -4);
32603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
32613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(1, &texture);
32643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
32653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid copytexsubimage3d_incomplete_framebuffer (NegativeTestContext& ctx)
32673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0x1234;
32693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture[2];
32703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(2, texture);
32723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_3D, texture[0]);
32733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D			(GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
32743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture[1]);
32753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexImage3D			(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
32763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers		(1, &fbo);
32773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer		(GL_READ_FRAMEBUFFER, fbo);
32783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
32793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
32813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 4, 4);
32823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
32833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
32843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
32853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
32863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
32883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
32893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures(2, texture);
32903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
32913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glCompressedTexImage3D
32933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d (NegativeTestContext& ctx)
32953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
32973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
32983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
32993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
33003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
33013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not one of the specific compressed internal formats.");
33043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, 0);
33053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
33063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 0, 0, 0, 0, 0, 0);
33073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
33083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_neg_level (NegativeTestContext& ctx)
33123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
33143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, -1, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
33153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_max_level (NegativeTestContext& ctx)
33203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
33223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
33233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, 0, 0);
33243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_neg_width_height_depth (NegativeTestContext& ctx)
33293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is less than 0.");
33313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0, 0, 0, 0, 0);
33323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, -1, 0, 0, 0, 0);
33343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, -1, 0, 0, 0);
33363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, -1, -1, 0, 0, 0);
33383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_max_width_height_depth (NegativeTestContext& ctx)
33433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxTextureSize = ctx.getInteger(GL_MAX_TEXTURE_SIZE) + 1;
33453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth is greater than GL_MAX_TEXTURE_SIZE.");
33473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, 0, 0, 0, 0, 0);
33483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, maxTextureSize, 0, 0, 0, 0);
33503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, maxTextureSize, 0, 0, 0);
33523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, maxTextureSize, maxTextureSize, maxTextureSize, 0, 0, 0);
33543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_invalid_border (NegativeTestContext& ctx)
33593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if border is not 0.");
33613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, -1, 0, 0);
33623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 1, 0, 0);
33643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_invalid_size (NegativeTestContext& ctx)
33693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
33713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0, 0, 0, -1, 0);
33723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*8, 0);
33743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, 4*4*16, 0);
33763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_SIGNED_R11_EAC, 16, 16, 1, 0, 4*4*16, 0);
33783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
33793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
33803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3382bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppevoid compressedteximage3d_invalid_width_height (NegativeTestContext& ctx)
3383bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe{
3384bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3385bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3386fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		const int				width		= 4;
3387fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		const int				height		= 6;
3388fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		const int				depth		= 6;
3389fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		const int				blockSize	= 16;
3390fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		const int				imageSize	= divRoundUp(width, 4) * divRoundUp(height, 4) * depth * blockSize;
3391fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		std::vector<GLubyte>	data		(imageSize);
3392bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TEXTURE_CUBE_MAP_ARRAY and width and height are not equal.");
33937bf1b814b0216c9793c353fdee3bf295ef9603f2Mika Isojärvi		ctx.glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, width, height, depth, 0, imageSize, &data[0]);
3394bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3395bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.endSection();
3396bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
3397bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe}
3398bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
33993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedteximage3d_invalid_buffer_target (NegativeTestContext& ctx)
34003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
34013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				buf = 0x1234;
34023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLubyte>	data(512);
34033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers			(1, &buf);
34053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer			(GL_PIXEL_UNPACK_BUFFER, buf);
34063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData			(GL_PIXEL_UNPACK_BUFFER, 64, &data[0], GL_DYNAMIC_COPY);
34073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
34083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
34103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glMapBufferRange		(GL_PIXEL_UNPACK_BUFFER, 0, 64, GL_MAP_WRITE_BIT);
34113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 4, 4, 1, 0, etc2DataSize(4, 4), 0);
34123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
34133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer			(GL_PIXEL_UNPACK_BUFFER);
34143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
34173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGB8_ETC2, 16, 16, 1, 0, etc2DataSize(16, 16), 0);
34183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
34193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
34223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
34233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glCompressedTexSubImage3D
34253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d (NegativeTestContext& ctx)
34273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
34283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is invalid.");
34293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(0, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
34303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
34313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
34343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
34353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
34363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 18, 18, 1, 0, etc2EacDataSize(18, 18), 0);
34373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
34383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if format does not match the internal format of the texture image being modified.");
34403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGB8_ETC2, 0, 0);
34413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.");
34453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 18, 18, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(18, 18), 0);
34463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
34503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 4, 0, 0, 10, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(10, 4), 0);
34513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
34553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 4, 0, 4, 10, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 10), 0);
34563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("For ETC2/EAC images GL_INVALID_OPERATION is generated if xoffset or yoffset is not a multiple of four.");
34603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
34613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
34633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 1, 1, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
34653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
34663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
34693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
34703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_neg_level (NegativeTestContext& ctx)
34723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
34733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
34743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
34753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
34763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
34773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
34783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0.");
34803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, -1, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
34813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
34823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
34833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
34853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
34863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_max_level (NegativeTestContext& ctx)
34883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
34893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
34903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
34913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
34923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
34933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
34943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if level is greater than log_2(GL_MAX_TEXTURE_SIZE).");
34963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 log2MaxTextureSize = deLog2Floor32(ctx.getInteger(GL_MAX_TEXTURE_SIZE)) + 1;
34973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, log2MaxTextureSize, 0, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
34983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
34993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
35003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
35023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
35033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_neg_offset (NegativeTestContext& ctx)
35053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
35063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
35073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
35083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
35093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
35103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
35113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset, yoffset or zoffset are negative.");
35133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, 0, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -4, 0, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -4, -4, -4, 0, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
35223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
35243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
35253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_invalid_offset (NegativeTestContext& ctx)
35273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
35283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
35293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
35303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
35313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, etc2EacDataSize(4, 4), 0);
35323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
35333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if xoffset + width > texture_width or yoffset + height > texture_height.");
35353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 0, 0, 8, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 4), 0);
35373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 12, 0, 4, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 8), 0);
35393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 12, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
35413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 12, 12, 12, 8, 8, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(8, 8), 0);
35433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
35453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
35473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
35483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_neg_width_height_depth (NegativeTestContext& ctx)
35503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
35513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
35523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
35533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
35543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
35553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
35563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE or GL_INVALID_OPERATION is generated if width, height or depth are negative.");
35583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, 0, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, -4, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, -4, -4, -4, GL_COMPRESSED_RGBA8_ETC2_EAC, 0, 0);
35653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE, GL_INVALID_OPERATION);
35663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
35673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
35693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
35703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_invalid_size (NegativeTestContext& ctx)
35723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
35733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				texture = 0x1234;
35743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures			(1, &texture);
35753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture			(GL_TEXTURE_2D_ARRAY, texture);
35763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D	(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, 4*4*16, 0);
35773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
35783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.");
35803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, -1, 0);
35813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
35823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, 4*4*16-1, 0);
35843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
35853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
35863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
35883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
35893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compressedtexsubimage3d_invalid_buffer_target (NegativeTestContext& ctx)
35913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3592971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	deUint32						buf = 0x1234;
3593971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	deUint32						texture = 0x1234;
3594971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	GLsizei							bufferSize =  etc2EacDataSize(4, 4);
3595971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	std::vector<GLubyte>			data(bufferSize);
35963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTextures				(1, &texture);
35983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTexture				(GL_TEXTURE_2D_ARRAY, texture);
35993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexImage3D		(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA8_ETC2_EAC, 16, 16, 1, 0, etc2EacDataSize(16, 16), 0);
36003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
36013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_PIXEL_UNPACK_BUFFER, buf);
3602971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	ctx.glBufferData				(GL_PIXEL_UNPACK_BUFFER, bufferSize, &data[0], GL_DYNAMIC_COPY);
36033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
36043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and...");
36063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the buffer object's data store is currently mapped.");
3607971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	ctx.glMapBufferRange			(GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, GL_MAP_WRITE_BIT);
36083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompressedTexSubImage3D	(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(4, 4), 0);
36093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
36103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUnmapBuffer				(GL_PIXEL_UNPACK_BUFFER);
36113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("...the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.");
3614971d41d7125e65b9020d562ec2aeec57ce6b3924Mika Isojärvi	ctx.glCompressedTexSubImage3D	(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 1, GL_COMPRESSED_RGBA8_ETC2_EAC, etc2EacDataSize(16, 16), 0);
36153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
36163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers			(1, &buf);
36203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTextures		(1, &texture);
36213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
36223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexStorage2D
36243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texstorage2d (NegativeTestContext& ctx)
36263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3627bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32  textures[] = {0x1234, 0x1234};
3628bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3629bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(2, textures);
3630bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, textures[0]);
3631bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
36323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3634bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, 0, 16, 16);
3635bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3636bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, 16, 16);
3637bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
36383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3641bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(0, 1, GL_RGBA8, 16, 16);
3642bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
3643bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16);
3644bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
3645bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16);
3646bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
36473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width or height are less than 1.");
3650bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 16);
3651bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3652bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 0);
3653bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3654bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 0, 0);
3655bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3656bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3657bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
3658bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3659bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
3660bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_NO_ERROR);
3661bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 0, 16);
3662bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3663bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 0);
3664bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3665bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 0, 0);
3666bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3667bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
36683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3670bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(2, textures);
36713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
36723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texstorage2d_invalid_binding (NegativeTestContext& ctx)
36743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3675cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	deUint32	textures[]		= {0x1234, 0x1234};
3676cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	deInt32		immutable		= 0x1234;
3677cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	const bool	supportsES32	= contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
36783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3680bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, 0);
3681bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3682bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
3683bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3684cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32)
3685bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3686bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
3687bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 16);
3688bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
3689bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
36903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
36913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3692bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(2, textures);
36933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
3695bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, textures[0]);
36963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
36973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3698bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3699bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
37003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
37013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3702bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 16, 16);
3703bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
3704bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3705cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32)
3706bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3707bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
3708bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3709bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3710bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 16);
3711bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_NO_ERROR);
3712bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3713bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3714bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 16, 16);
3715bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
3716bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
37173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
37183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3719bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(2, textures);
37203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
37213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texstorage2d_invalid_levels (NegativeTestContext& ctx)
37233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3724cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	deUint32	textures[]		= {0x1234, 0x1234};
3725cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	deUint32	log2MaxSize		= deLog2Floor32(deMax32(16, 16)) + 1 + 1;
3726cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	const bool	supportsES32	= contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
3727bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3728bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(2, textures);
3729bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_2D, textures[0]);
3730bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3731cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32)
3732bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
3733bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3734bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
37353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if levels is less than 1.");
3737bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16);
3738bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3739bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0);
3740bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3741bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3742cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32)
3743bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3744bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA8, 16, 16);
3745bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3746bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA8, 0, 0);
3747bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3748bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
37493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
37503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height))) + 1");
3752bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage2D(GL_TEXTURE_2D, log2MaxSize, GL_RGBA8, 16, 16);
3753bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_OPERATION);
3754bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3755cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32)
3756bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3757bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage2D(GL_TEXTURE_CUBE_MAP, log2MaxSize, GL_RGBA8, 16, 16);
3758bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_OPERATION);
3759bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
37603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
37613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3762bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(2, textures);
37633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
37643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// glTexStorage3D
37663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texstorage3d (NegativeTestContext& ctx)
37683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3769bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32 textures[] = {0x1234, 0x1234};
3770bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3771bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(2, textures);
3772bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
3773bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_NO_ERROR);
37743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM or GL_INVALID_VALUE is generated if internalformat is not a valid sized internal format.");
3776bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, 0, 4, 4, 4);
3777bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
3778bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA_INTEGER, 4, 4, 4);
3779bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM, GL_INVALID_VALUE);
37803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
37813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted target enumerants.");
3783bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(0, 1, GL_RGBA8, 4, 4, 4);
3784bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
3785bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 4, 4, 4);
3786bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
3787bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 4);
3788bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
37893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
37903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width, height or depth are less than 1.");
3792bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 4, 4);
3793bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3794bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 0, 4);
3795bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3796bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 0);
3797bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3798bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 0, 0, 0);
3799bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3800bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3801bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3802bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3803bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[1]);
3804bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_NO_ERROR);
3805bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 0, 4, 4);
3806bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3807bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 0, 4);
3808bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3809bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 0);
3810bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3811bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 0, 0, 0);
3812bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3813bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
38143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
38153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3816bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(2, textures);
38173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
38183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texstorage3d_invalid_binding (NegativeTestContext& ctx)
38203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3821bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deUint32	textures[]	= {0x1234, 0x1234};
3822bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	deInt32		immutable	= 0x1234;
38233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the default texture object is curently bound to target.");
3825bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture	(GL_TEXTURE_3D, 0);
38263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
38273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3828bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3829bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3830bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3831bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
3832fb059fdb43c8b6073ada028a68124263c59a000aPyry Haulos		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 6);
3833bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError		(GL_INVALID_OPERATION);
3834bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
38353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
38363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3837bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures	(2, textures);
38383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
3840bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture	(GL_TEXTURE_3D, textures[0]);
38413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
38423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
38433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
38443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
38453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTexParameteriv(GL_TEXTURE_3D, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
38463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
38473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, 1, GL_RGBA8, 4, 4, 4);
38483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3849bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3850bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3851bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3852bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture	(GL_TEXTURE_CUBE_MAP_ARRAY, textures[1]);
3853bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3854bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3855bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 6);
3856bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError		(GL_NO_ERROR);
3857bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glGetTexParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_IMMUTABLE_FORMAT, &immutable);
3858bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.getLog() << TestLog::Message << "// GL_TEXTURE_IMMUTABLE_FORMAT = " << ((immutable != 0) ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
3859bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, 1, GL_RGBA8, 4, 4, 6);
3860bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError		(GL_INVALID_OPERATION);
3861bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
38623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
38633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3864bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(2, textures);
38653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
38663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid texstorage3d_invalid_levels (NegativeTestContext& ctx)
38683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3869cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	deUint32	textures[]		= {0x1234, 0x1234};
3870cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	deUint32	log2MaxSize		= deLog2Floor32(8) + 1 + 1;
3871cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	const bool	supportsES32	= contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
3872bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glGenTextures(2, textures);
3873bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glBindTexture(GL_TEXTURE_3D, textures[0]);
38743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if levels is less than 1.");
3876bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4);
3877bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3878bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glTexStorage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 0, 0, 0);
3879bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
3880bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3881cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32 || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3882bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3883bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures[1]);
3884bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA8, 4, 4, 6);
3885bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3886bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA8, 0, 0, 6);
3887bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError(GL_INVALID_VALUE);
3888bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
38893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
38903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if levels is greater than floor(log_2(max(width, height, depth))) + 1");
38923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 2, 2);
38933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
38943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 8, 2);
38953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
38963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 2, 2, 8);
38973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
38983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTexStorage3D	(GL_TEXTURE_3D, log2MaxSize, GL_RGBA8, 8, 8, 8);
38993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3900bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe
3901cb24d85a6dae33dd3a658b831cd5f0c34918126aPyry Haulos	if (supportsES32 || ctx.getContextInfo().isExtensionSupported("GL_OES_texture_cube_map_array"))
3902bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	{
3903bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, log2MaxSize, GL_RGBA8, 2, 2, 6);
3904bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError		(GL_INVALID_OPERATION);
3905bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, log2MaxSize, GL_RGBA8, 8, 8, 6);
3906bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		ctx.expectError		(GL_INVALID_OPERATION);
3907bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	}
39083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
39093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3910bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe	ctx.glDeleteTextures(2, textures);
39113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
39123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
391380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadleyvoid srgb_decode_texparameteri (NegativeTestContext& ctx)
391480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley{
391580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
391680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
391780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
391880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	texture		= 0x1234;
391980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLint	textureMode	= -1;
392080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
392180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glGenTextures(1, &texture);
392280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glBindTexture(GL_TEXTURE_2D, texture);
392380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
392480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	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).");
392580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
392680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.expectError(GL_INVALID_ENUM);
392780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.endSection();
392880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
392980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glDeleteTextures(1, &texture);
393080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley}
393180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
393280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadleyvoid srgb_decode_texparameterf (NegativeTestContext& ctx)
393380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley{
393480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
393580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
393680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
393780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	texture		= 0x1234;
393880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLfloat	textureMode	= -1.0f;
393980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
394080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glGenTextures(1, &texture);
394180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glBindTexture(GL_TEXTURE_2D, texture);
394280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
394380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	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).");
394480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
394580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.expectError(GL_INVALID_ENUM);
394680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.endSection();
394780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
394880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glDeleteTextures(1, &texture);
394980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley}
395080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
395180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadleyvoid srgb_decode_texparameteriv (NegativeTestContext& ctx)
395280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley{
395380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
395480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
395580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
395680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLint	params[1]	= {GL_LINEAR};
395780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	texture		= 0x1234;
395880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
395980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glGenTextures(1, &texture);
396080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glBindTexture(GL_TEXTURE_2D, texture);
396180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
396280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	params[0] = -1;
396380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	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).");
396480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
396580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.expectError(GL_INVALID_ENUM);
396680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.endSection();
396780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
396880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glDeleteTextures(1, &texture);
396980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley}
397080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
397180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadleyvoid srgb_decode_texparameterfv (NegativeTestContext& ctx)
397280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley{
397380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
397480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
397580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
397680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLfloat	params[1]	= {GL_LINEAR};
397780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	texture		= 0x1234;
397880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
397980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glGenTextures(1, &texture);
398080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glBindTexture(GL_TEXTURE_2D, texture);
398180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
398280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	params[0] = -1.0f;
398380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	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).");
398480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
398580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.expectError(GL_INVALID_ENUM);
398680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.endSection();
398780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
398880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glDeleteTextures(1, &texture);
398980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley}
399080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
399180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadleyvoid srgb_decode_texparameterIiv (NegativeTestContext& ctx)
399280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley{
399380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
399480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError,"glTexParameterIiv is not supported.");
399580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
399680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
399780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
399880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
399980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLint	textureMode[]	= {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
400080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	texture			= 0x1234;
400180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
400280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glGenTextures(1, &texture);
400380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glBindTexture(GL_TEXTURE_2D, texture);
400480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
400580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	textureMode[0] = -1;
400680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	textureMode[1] = -1;
400780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	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).");
400880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glTexParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
400980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.expectError(GL_INVALID_ENUM);
401080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.endSection();
401180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
401280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glDeleteTextures(1, &texture);
401380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley}
401480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
401580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadleyvoid srgb_decode_texparameterIuiv (NegativeTestContext& ctx)
401680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley{
401780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
401880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError,"glTexParameterIuiv is not supported.");
401980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
402080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
402180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
402280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
402380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	textureMode[]	= {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
402480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	GLuint	texture			= 0x1234;
402580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
402680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glGenTextures(1, &texture);
402780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glBindTexture(GL_TEXTURE_2D, texture);
402880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
402980ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	textureMode[0] = GL_DONT_CARE;
403080ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	textureMode[1] = GL_DONT_CARE;
403180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	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).");
403280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glTexParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, textureMode);
403380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.expectError(GL_INVALID_ENUM);
403480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.endSection();
403580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
403680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley	ctx.glDeleteTextures(1, &texture);
403780ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley}
403880ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley
40393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<FunctionContainer> getNegativeTextureApiTestFunctions()
40403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
40413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FunctionContainer funcs[] =
40423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
40433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{activetexture,									"activetexture",									"Invalid glActiveTexture() usage"		   },
40443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{bindtexture,									"bindtexture",										"Invalid glBindTexture() usage"			   },
40453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_invalid_target,			"compressedteximage2d_invalid_target",				"Invalid glCompressedTexImage2D() usage"   },
40463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_invalid_format,			"compressedteximage2d_invalid_format",				"Invalid glCompressedTexImage2D() usage"   },
40473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_neg_level,				"compressedteximage2d_neg_level",					"Invalid glCompressedTexImage2D() usage"   },
40483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_max_level,				"compressedteximage2d_max_level",					"Invalid glCompressedTexImage2D() usage"   },
40493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_neg_width_height,			"compressedteximage2d_neg_width_height",			"Invalid glCompressedTexImage2D() usage"   },
40503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_max_width_height,			"compressedteximage2d_max_width_height",			"Invalid glCompressedTexImage2D() usage"   },
40513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_invalid_border,			"compressedteximage2d_invalid_border",				"Invalid glCompressedTexImage2D() usage"   },
40523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_invalid_size,				"compressedteximage2d_invalid_size",				"Invalid glCompressedTexImage2D() usage"   },
4053bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{compressedteximage2d_neg_size,					"compressedteximage2d_neg_size",					"Invalid glCompressedTexImage2D() usage"   },
4054bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{compressedteximage2d_invalid_width_height,		"compressedteximage2d_invalid_width_height",		"Invalid glCompressedTexImage2D() usage"   },
40553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage2d_invalid_buffer_target,	"compressedteximage2d_invalid_buffer_target",		"Invalid glCompressedTexImage2D() usage"   },
40563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_invalid_target,					"copyteximage2d_invalid_target",					"Invalid glCopyTexImage2D() usage"		   },
40573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_invalid_format,					"copyteximage2d_invalid_format",					"Invalid glCopyTexImage2D() usage"		   },
40583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_inequal_width_height_cube,		"copyteximage2d_inequal_width_height_cube",			"Invalid glCopyTexImage2D() usage"		   },
40593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_neg_level,						"copyteximage2d_neg_level",							"Invalid glCopyTexImage2D() usage"		   },
40603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_max_level,						"copyteximage2d_max_level",							"Invalid glCopyTexImage2D() usage"		   },
40613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_neg_width_height,				"copyteximage2d_neg_width_height",					"Invalid glCopyTexImage2D() usage"		   },
40623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_max_width_height,				"copyteximage2d_max_width_height",					"Invalid glCopyTexImage2D() usage"		   },
40633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_invalid_border,					"copyteximage2d_invalid_border",					"Invalid glCopyTexImage2D() usage"		   },
40643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copyteximage2d_incomplete_framebuffer,			"copyteximage2d_incomplete_framebuffer",			"Invalid glCopyTexImage2D() usage"		   },
40653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_invalid_target,				"copytexsubimage2d_invalid_target",					"Invalid glCopyTexSubImage2D() usage"	   },
4066bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{copytexsubimage2d_read_buffer_is_none,			"copytexsubimage2d_read_buffer_is_none",			"Invalid glCopyTexSubImage2D() usage"	   },
4067bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{copytexsubimage2d_texture_internalformat,		"copytexsubimage2d_texture_internalformat",			"Invalid glCopyTexSubImage2D() usage"	   },
40683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_neg_level,					"copytexsubimage2d_neg_level",						"Invalid glCopyTexSubImage2D() usage"	   },
40693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_max_level,					"copytexsubimage2d_max_level",						"Invalid glCopyTexSubImage2D() usage"	   },
40703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_neg_offset,					"copytexsubimage2d_neg_offset",						"Invalid glCopyTexSubImage2D() usage"	   },
40713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_invalid_offset,				"copytexsubimage2d_invalid_offset",					"Invalid glCopyTexSubImage2D() usage"	   },
40723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_neg_width_height,			"copytexsubimage2d_neg_width_height",				"Invalid glCopyTexSubImage2D() usage"	   },
40733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage2d_incomplete_framebuffer,		"copytexsubimage2d_incomplete_framebuffer",			"Invalid glCopyTexSubImage2D() usage"	   },
40743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{deletetextures,								"deletetextures",									"Invalid glDeleteTextures() usage"		   },
40753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{generatemipmap,								"generatemipmap",									"Invalid glGenerateMipmap() usage"		   },
40763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{gentextures,									"gentextures",										"Invalid glGenTextures() usage"			   },
40773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{pixelstorei,									"pixelstorei",										"Invalid glPixelStorei() usage"			   },
40783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d,									"teximage2d",										"Invalid glTexImage2D() usage"			   },
40793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_inequal_width_height_cube,			"teximage2d_inequal_width_height_cube",				"Invalid glTexImage2D() usage"			   },
40803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_neg_level,							"teximage2d_neg_level",								"Invalid glTexImage2D() usage"			   },
40813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_max_level,							"teximage2d_max_level",								"Invalid glTexImage2D() usage"			   },
40823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_neg_width_height,					"teximage2d_neg_width_height",						"Invalid glTexImage2D() usage"			   },
40833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_max_width_height,					"teximage2d_max_width_height",						"Invalid glTexImage2D() usage"			   },
40843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_invalid_border,						"teximage2d_invalid_border",						"Invalid glTexImage2D() usage"			   },
40853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage2d_invalid_buffer_target,				"teximage2d_invalid_buffer_target",					"Invalid glTexImage2D() usage"			   },
40863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d,									"texsubimage2d",									"Invalid glTexSubImage2D() usage"		   },
40873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d_neg_level,						"texsubimage2d_neg_level",							"Invalid glTexSubImage2D() usage"		   },
40883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d_max_level,						"texsubimage2d_max_level",							"Invalid glTexSubImage2D() usage"		   },
40893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d_neg_offset,						"texsubimage2d_neg_offset",							"Invalid glTexSubImage2D() usage"		   },
40903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d_invalid_offset,					"texsubimage2d_invalid_offset",						"Invalid glTexSubImage2D() usage"		   },
40913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d_neg_width_height,				"texsubimage2d_neg_width_height",					"Invalid glTexSubImage2D() usage"		   },
40923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage2d_invalid_buffer_target,			"texsubimage2d_invalid_buffer_target",				"Invalid glTexSubImage2D() usage"		   },
40933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texparameteri,									"texparameteri",									"Invalid glTexParameteri() usage"		   },
40943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texparameterf,									"texparameterf",									"Invalid glTexParameterf() usage"		   },
40953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texparameteriv,								"texparameteriv",									"Invalid glTexParameteriv() usage"		   },
40963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texparameterfv,								"texparameterfv",									"Invalid glTexParameterfv() usage"		   },
4097bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{texparameterIiv,								"texparameterIiv",									"Invalid glTexParameterIiv() usage"		   },
4098bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{texparameterIuiv,								"texparameterIuiv",									"Invalid glTexParameterIuiv() usage"	   },
40993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d,						"compressedtexsubimage2d",							"Invalid glCompressedTexSubImage2D() usage"},
41003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_neg_level,				"compressedtexsubimage2d_neg_level",				"Invalid glCompressedTexSubImage2D() usage"},
41013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_max_level,				"compressedtexsubimage2d_max_level",				"Invalid glCompressedTexSubImage2D() usage"},
41023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_neg_offset,			"compressedtexsubimage2d_neg_offset",				"Invalid glCompressedTexSubImage2D() usage"},
41033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_invalid_offset,		"compressedtexsubimage2d_invalid_offset",			"Invalid glCompressedTexSubImage2D() usage"},
41043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_neg_width_height,		"compressedtexsubimage2d_neg_width_height",			"Invalid glCompressedTexSubImage2D() usage"},
41053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_invalid_size,			"compressedtexsubimage2d_invalid_size",				"Invalid glCompressedTexImage2D() usage"   },
41063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage2d_invalid_buffer_target,	"compressedtexsubimage2d_invalid_buffer_target",	"Invalid glCompressedTexSubImage2D() usage"},
41073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d,									"teximage3d",										"Invalid glTexImage3D() usage"			   },
41083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d_neg_level,							"teximage3d_neg_level",								"Invalid glTexImage3D() usage"			   },
41093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d_max_level,							"teximage3d_max_level",								"Invalid glTexImage3D() usage"			   },
41103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d_neg_width_height_depth,				"teximage3d_neg_width_height_depth",				"Invalid glTexImage3D() usage"			   },
41113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d_max_width_height_depth,				"teximage3d_max_width_height_depth",				"Invalid glTexImage3D() usage"			   },
41123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d_invalid_border,						"teximage3d_invalid_border",						"Invalid glTexImage3D() usage"			   },
41133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{teximage3d_invalid_buffer_target,				"teximage3d_invalid_buffer_target",					"Invalid glTexImage3D() usage"			   },
41143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d,									"texsubimage3d",									"Invalid glTexSubImage3D() usage"		   },
41153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d_neg_level,						"texsubimage3d_neg_level",							"Invalid glTexSubImage3D() usage"		   },
41163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d_max_level,						"texsubimage3d_max_level",							"Invalid glTexSubImage3D() usage"		   },
41173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d_neg_offset,						"texsubimage3d_neg_offset",							"Invalid glTexSubImage3D() usage"		   },
41183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d_invalid_offset,					"texsubimage3d_invalid_offset",						"Invalid glTexSubImage3D() usage"		   },
41193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d_neg_width_height,				"texsubimage3d_neg_width_height",					"Invalid glTexSubImage3D() usage"		   },
41203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texsubimage3d_invalid_buffer_target,			"texsubimage3d_invalid_buffer_target",				"Invalid glTexSubImage3D() usage"		   },
41213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d,								"copytexsubimage3d",								"Invalid glCopyTexSubImage3D() usage"	   },
41223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d_neg_level,					"copytexsubimage3d_neg_level",						"Invalid glCopyTexSubImage3D() usage"	   },
41233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d_max_level,					"copytexsubimage3d_max_level",						"Invalid glCopyTexSubImage3D() usage"	   },
41243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d_neg_offset,					"copytexsubimage3d_neg_offset",						"Invalid glCopyTexSubImage3D() usage"	   },
41253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d_invalid_offset,				"copytexsubimage3d_invalid_offset",					"Invalid glCopyTexSubImage3D() usage"	   },
41263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d_neg_width_height,			"copytexsubimage3d_neg_width_height",				"Invalid glCopyTexSubImage3D() usage"	   },
41273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{copytexsubimage3d_incomplete_framebuffer,		"copytexsubimage3d_incomplete_framebuffer",			"Invalid glCopyTexSubImage3D() usage"	   },
41283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d,							"compressedteximage3d",								"Invalid glCompressedTexImage3D() usage"   },
41293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_neg_level,				"compressedteximage3d_neg_level",					"Invalid glCompressedTexImage3D() usage"   },
41303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_max_level,				"compressedteximage3d_max_level",					"Invalid glCompressedTexImage3D() usage"   },
41313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_neg_width_height_depth,	"compressedteximage3d_neg_width_height_depth",		"Invalid glCompressedTexImage3D() usage"   },
41323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_max_width_height_depth,	"compressedteximage3d_max_width_height_depth",		"Invalid glCompressedTexImage3D() usage"   },
41333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_invalid_border,			"compressedteximage3d_invalid_border",				"Invalid glCompressedTexImage3D() usage"   },
41343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_invalid_size,				"compressedteximage3d_invalid_size",				"Invalid glCompressedTexImage3D() usage"   },
4135bf50777204ebb09f96c26fc718c8d2422ee03048Daniel Andrade Groppe		{compressedteximage3d_invalid_width_height,		"compressedteximage3d_invalid_width_height",		"Invalid glCompressedTexImage3D() usage"   },
41363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedteximage3d_invalid_buffer_target,	"compressedteximage3d_invalid_buffer_target",		"Invalid glCompressedTexImage3D() usage"   },
41373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d,						"compressedtexsubimage3d",							"Invalid glCompressedTexSubImage3D() usage"},
41383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_neg_level,				"compressedtexsubimage3d_neg_level",				"Invalid glCompressedTexSubImage3D() usage"},
41393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_max_level,				"compressedtexsubimage3d_max_level",				"Invalid glCompressedTexSubImage3D() usage"},
41403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_neg_offset,			"compressedtexsubimage3d_neg_offset",				"Invalid glCompressedTexSubImage3D() usage"},
41413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_invalid_offset,		"compressedtexsubimage3d_invalid_offset",			"Invalid glCompressedTexSubImage3D() usage"},
41423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_neg_width_height_depth,"compressedtexsubimage3d_neg_width_height_depth",	"Invalid glCompressedTexSubImage3D() usage"},
41433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_invalid_size,			"compressedtexsubimage3d_invalid_size",				"Invalid glCompressedTexSubImage3D() usage"},
41443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compressedtexsubimage3d_invalid_buffer_target,	"compressedtexsubimage3d_invalid_buffer_target",	"Invalid glCompressedTexSubImage3D() usage"},
41453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texstorage2d,									"texstorage2d",										"Invalid glTexStorage2D() usage"		   },
41463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texstorage2d_invalid_binding,					"texstorage2d_invalid_binding",						"Invalid glTexStorage2D() usage"		   },
41473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texstorage2d_invalid_levels,					"texstorage2d_invalid_levels",						"Invalid glTexStorage2D() usage"		   },
41483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texstorage3d,									"texstorage3d",										"Invalid glTexStorage3D() usage"		   },
41493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texstorage3d_invalid_binding,					"texstorage3d_invalid_binding",						"Invalid glTexStorage3D() usage"		   },
41503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{texstorage3d_invalid_levels,					"texstorage3d_invalid_levels",						"Invalid glTexStorage3D() usage"		   },
415180ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		{srgb_decode_texparameteri,						"srgb_decode_texparameteri",						"Invalid texparameteri() usage srgb"	   },
415280ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		{srgb_decode_texparameterf,						"srgb_decode_texparameterf",						"Invalid texparameterf() usage srgb"	   },
415380ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		{srgb_decode_texparameteriv,					"srgb_decode_texparameteriv",						"Invalid texparameteriv() usage srgb"	   },
415480ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		{srgb_decode_texparameterfv,					"srgb_decode_texparameterfv",						"Invalid texparameterfv() usage srgb"	   },
415580ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		{srgb_decode_texparameterIiv,					"srgb_decode_texparameterIiv",						"Invalid texparameterIiv() usage srgb"	   },
415680ae66864cf5a5e50389717f7c838364d761d40dMichael Hadley		{srgb_decode_texparameterIuiv,					"srgb_decode_texparameterIuiv",						"Invalid texparameterIuiv() usage srgb"	   },
41573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
41583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
41603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
41613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // NegativeTestShared
41633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
41643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
41653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
4166