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 Shader API tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fNegativeShaderApiTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace NegativeTestShared
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::CallLogWrapper;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* vertexShaderSource		=	"#version 300 es\n"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = vec4(0.0);\n"
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* fragmentShaderSource		=	"#version 300 es\n"
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"layout(location = 0) out mediump vec4 fragColor;"
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	fragColor = vec4(0.0);\n"
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* uniformTestVertSource	=	"#version 300 es\n"
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"uniform mediump vec4 vec4_v;\n"
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"uniform mediump mat4 mat4_v;\n"
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = mat4_v * vec4_v;\n"
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* uniformTestFragSource	=	"#version 300 es\n"
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"uniform mediump ivec4 ivec4_f;\n"
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"uniform mediump uvec4 uvec4_f;\n"
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"uniform sampler2D sampler_f;\n"
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"layout(location = 0) out mediump vec4 fragColor;"
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	fragColor.xy = (vec4(uvec4_f) + vec4(ivec4_f)).xy;\n"
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	fragColor.zw = texture(sampler_f, vec2(0.0, 0.0)).zw;\n"
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* uniformBlockVertSource	=	"#version 300 es\n"
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"layout(shared) uniform Block { lowp float var; };\n"
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = vec4(var);\n"
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Shader control commands
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid create_shader (NegativeTestContext& ctx)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if shaderType is not an accepted value.");
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCreateShader(-1);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid shader_source (NegativeTestContext& ctx)
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note Shader compilation must be supported.
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glShaderSource(1, 0, 0, 0);
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is less than 0.");
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glShaderSource(shader, -1, 0, 0);
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint program = ctx.glCreateProgram();
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glShaderSource(program, 0, 0, 0);
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(program);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid compile_shader (NegativeTestContext& ctx)
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note Shader compilation must be supported.
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompileShader(9);
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint program = ctx.glCreateProgram();
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCompileShader(program);
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(program);
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_shader (NegativeTestContext& ctx)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(9);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid shader_binary (NegativeTestContext& ctx)
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<deInt32> binaryFormats;
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deInt32 numFormats = 0x1234;
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &numFormats);
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numFormats == 0)
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			ctx.getLog() << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			binaryFormats.resize(numFormats);
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			ctx.glGetIntegerv(GL_SHADER_BINARY_FORMATS, &binaryFormats[0]);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deBool shaderBinarySupported = !binaryFormats.empty();
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!shaderBinarySupported)
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage;
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage;
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shaders[2];
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shaders[0]		= ctx.glCreateShader(GL_VERTEX_SHADER);
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shaders[1]		= ctx.glCreateShader(GL_VERTEX_SHADER);
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not an accepted value.");
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glShaderBinary(1, &shaders[0], -1, 0, 0);
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (shaderBinarySupported)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.beginSection("GL_INVALID_VALUE is generated if the data pointed to by binary does not match the format specified by binaryFormat.");
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLbyte data = 0x005F;
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glShaderBinary(1, &shaders[0], binaryFormats[0], &data, 1);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_VALUE);
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.endSection();
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.beginSection("GL_INVALID_OPERATION is generated if more than one of the handles in shaders refers to the same type of shader, or GL_INVALID_VALUE due to invalid data pointer.");
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 0);
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.endSection();
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shaders[0]);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shaders[1]);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid attach_shader (NegativeTestContext& ctx)
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader1 = ctx.glCreateShader(GL_VERTEX_SHADER);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader2 = ctx.glCreateShader(GL_VERTEX_SHADER);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint program = ctx.glCreateProgram();
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(shader1, shader1);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(program, program);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(shader1, program);
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(program, -1);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(-1, shader1);
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(-1, -1);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is already attached to program.");
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(program, shader1);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(program, shader1);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a shader of the same type as shader is already attached to program.");
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glAttachShader(program, shader2);
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(program);
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader1);
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader2);
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid detach_shader (NegativeTestContext& ctx)
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint program = ctx.glCreateProgram();
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(-1, shader);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(program, -1);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(-1, -1);
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(shader, shader);
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(program, program);
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(shader, program);
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not attached to program.");
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDetachShader(program, shader);
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(program);
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid link_program (NegativeTestContext& ctx)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram(-1);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram(shader);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.");
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					tfID = 0x1234;
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(1, &tfID);
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(1, &tfID);
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid use_program (NegativeTestContext& ctx)
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL.");
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(-1);
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(shader);
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback mode is active and not paused.");
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program1(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program2(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					tfID = 0x1234;
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(1, &tfID);
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program1.getProgram());
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program1.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program1.getProgram());
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program2.getProgram());
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPauseTransformFeedback	();
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program2.getProgram());
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(1, &tfID);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_program (NegativeTestContext& ctx)
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(-1);
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid validate_program (NegativeTestContext& ctx)
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glValidateProgram(-1);
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glValidateProgram(shader);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid get_program_binary (NegativeTestContext& ctx)
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram				program			(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram				programInvalid	(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum							binaryFormat	= -1;
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsizei							binaryLength	= -1;
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint							binaryPtr		= -1;
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint							bufSize			= -1;
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint							linkStatus		= -1;
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program.");
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv		(program.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv		(program.getProgram(), GL_LINK_STATUS,				&linkStatus);
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramBinary	(program.getProgram(), 0, &binaryLength, &binaryFormat, &binaryPtr);
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (bufSize > 0)
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.glGetProgramBinary	(program.getProgram(), bufSize-1, &binaryLength, &binaryFormat, &binaryPtr);
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.expectError		(GL_INVALID_OPERATION);
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false.");
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv		(programInvalid.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv		(programInvalid.getProgram(), GL_LINK_STATUS,			&linkStatus);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramBinary	(programInvalid.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryPtr);
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid program_binary (NegativeTestContext& ctx)
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram		srcProgram		(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint					dstProgram		= ctx.glCreateProgram();
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint					dummyShader		= ctx.glCreateShader(GL_VERTEX_SHADER);
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum					binaryFormat	= -1;
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsizei					binaryLength	= -1;
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<deUint8>	binaryBuf;
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint					bufSize			= -1;
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint					linkStatus		= -1;
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv		(srcProgram.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv		(srcProgram.getProgram(), GL_LINK_STATUS,			&linkStatus);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TCU_CHECK(bufSize > 0);
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	binaryBuf.resize(bufSize);
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramBinary	(srcProgram.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryBuf[0]);
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not the name of an existing program object.");
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glProgramBinary		(dummyShader, binaryFormat, &binaryBuf[0], binaryLength);
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not a value recognized by the implementation.");
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glProgramBinary		(dstProgram, -1, &binaryBuf[0], binaryLength);
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_ENUM);
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(dummyShader);
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(dstProgram);
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid program_parameteri (NegativeTestContext& ctx)
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint	program	= ctx.glCreateProgram();
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
476e0fd98e8b8b9ada79446555ead31f847289ffd84Pyry Haulos	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of an existing program object.");
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glProgramParameteri		(0, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
478e0fd98e8b8b9ada79446555ead31f847289ffd84Pyry Haulos	ctx.expectError			(GL_INVALID_VALUE);
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_PROGRAM_BINARY_RETRIEVABLE_HINT.");
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glProgramParameteri		(program, -1, GL_TRUE);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if value is not GL_FALSE or GL_TRUE.");
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glProgramParameteri		(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, 2);
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_VALUE);
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(program);
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid gen_samplers (NegativeTestContext& ctx)
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint sampler = 0;
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(-1, &sampler);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError	(GL_INVALID_VALUE);
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid bind_sampler (NegativeTestContext& ctx)
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				maxTexImageUnits = 0x1234;
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetIntegerv	(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTexImageUnits);
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if unit is greater than or equal to the value of GL_MAX_COMBIED_TEXTURE_IMAGE_UNITS.");
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindSampler	(maxTexImageUnits, sampler);
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError	(GL_INVALID_VALUE);
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not zero or a name previously returned from a call to ctx.glGenSamplers.");
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindSampler	(1, -1);
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError	(GL_INVALID_OPERATION);
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler has been deleted by a call to ctx.glDeleteSamplers.");
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindSampler	(1, sampler);
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError	(GL_INVALID_OPERATION);
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_samplers (NegativeTestContext& ctx)
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(-1, 0);
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError	(GL_INVALID_VALUE);
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid get_sampler_parameteriv (NegativeTestContext& ctx)
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				params = 0x1234;
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetSamplerParameteriv	(-1, GL_TEXTURE_MAG_FILTER, &params);
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_OPERATION);
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetSamplerParameteriv	(sampler, -1, &params);
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid get_sampler_parameterfv (NegativeTestContext& ctx)
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float			params;
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetSamplerParameterfv	(-1, GL_TEXTURE_MAG_FILTER, &params);
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_OPERATION);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetSamplerParameterfv	(sampler, -1, &params);
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid sampler_parameteri (NegativeTestContext& ctx)
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameteri		(-1, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_OPERATION);
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameteri		(sampler, GL_TEXTURE_WRAP_S, -1);
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid sampler_parameteriv (NegativeTestContext& ctx)
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				params = 0x1234;
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	params = GL_CLAMP_TO_EDGE;
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameteriv	(-1, GL_TEXTURE_WRAP_S, &params);
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_OPERATION);
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	params = -1;
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameteriv	(sampler, GL_TEXTURE_WRAP_S, &params);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid sampler_parameterf (NegativeTestContext& ctx)
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameterf		(-1, GL_TEXTURE_MIN_LOD, -1000.0f);
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_OPERATION);
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameterf		(sampler, GL_TEXTURE_WRAP_S, -1.0f);
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid sampler_parameterfv (NegativeTestContext& ctx)
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float			params;
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint			sampler = 0;
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenSamplers	(1, &sampler);
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	params = -1000.0f;
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameterfv	(-1, GL_TEXTURE_WRAP_S, &params);
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_OPERATION);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	params = -1.0f;
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glSamplerParameterfv	(sampler, GL_TEXTURE_WRAP_S, &params);
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError			(GL_INVALID_ENUM);
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSamplers(1, &sampler);
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Shader data commands
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid get_attrib_location (NegativeTestContext& ctx)
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint programEmpty		= ctx.glCreateProgram();
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindAttribLocation		(programEmpty, 0, "test");
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetAttribLocation			(programEmpty, "test");
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a program or shader object.");
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindAttribLocation		(program.getProgram(), 0, "test");
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetAttribLocation			(program.getProgram(), "test");
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetAttribLocation			(-2, "test");
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_VALUE);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetAttribLocation			(shader, "test");
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(0);
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader				(shader);
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram				(programEmpty);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid get_uniform_location (NegativeTestContext& ctx)
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint programEmpty = ctx.glCreateProgram();
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetUniformLocation(programEmpty, "test");
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetUniformLocation(-2, "test");
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetAttribLocation(shader, "test");
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(programEmpty);
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid bind_attrib_location (NegativeTestContext& ctx)
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint program = ctx.glCreateProgram();
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint maxIndex = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindAttribLocation(program, maxIndex, "test");
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\".");
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindAttribLocation(program, maxIndex-1, "gl_test");
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindAttribLocation(-1, maxIndex-1, "test");
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindAttribLocation(shader, maxIndex-1, "test");
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteProgram(program);
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteShader(shader);
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniform_block_binding (NegativeTestContext& ctx)
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformBlockVertSource, uniformTestFragSource));
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram	(program.getProgram());
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint			maxUniformBufferBindings	= -1;
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint			numActiveUniforms			= -1;
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint			numActiveBlocks				= -1;
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetIntegerv	(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS,			&numActiveUniforms);
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_MAX_UNIFORM_BUFFER_BINDINGS = " << maxUniformBufferBindings << TestLog::EndMessage;
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = "				<< numActiveUniforms		<< TestLog::EndMessage;
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "		<< numActiveBlocks			<< TestLog::EndMessage;
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError	(GL_NO_ERROR);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program.");
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformBlockBinding(program.getProgram(), -1, 0);
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformBlockBinding(program.getProgram(), 5, 0);
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS.");
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformBlockBinding(program.getProgram(), maxUniformBufferBindings, 0);
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL.");
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformBlockBinding(-1, 0, 0);
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniform*f
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformf_invalid_program (NegativeTestContext& ctx)
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1f(-1, 0.0f);
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2f(-1, 0.0f, 0.0f);
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformf_incompatible_type (NegativeTestContext& ctx)
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1f(vec4_v, 0.0f);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2f(vec4_v, 0.0f, 0.0f);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3f(vec4_v, 0.0f, 0.0f, 0.0f);
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4f(vec4_v, 0.0f, 0.0f, 0.0f, 0.0f);
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}f is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4f(ivec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4f(uvec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1f(sampler_f, 0.0f);
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformf_invalid_location (NegativeTestContext& ctx)
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1f(-2, 0.0f);
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2f(-2, 0.0f, 0.0f);
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3f(-2, 0.0f, 0.0f, 0.0f);
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f);
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1f(-1, 0.0f);
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2f(-1, 0.0f, 0.0f);
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniform*fv
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformfv_invalid_program (NegativeTestContext& ctx)
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(4);
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1fv(-1, 1, &data[0]);
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2fv(-1, 1, &data[0]);
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3fv(-1, 1, &data[0]);
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(-1, 1, &data[0]);
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformfv_incompatible_type (NegativeTestContext& ctx)
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(4);
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1fv(vec4_v, 1, &data[0]);
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2fv(vec4_v, 1, &data[0]);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3fv(vec4_v, 1, &data[0]);
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(vec4_v, 1, &data[0]);
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}fv is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(ivec4_f, 1, &data[0]);
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(uvec4_f, 1, &data[0]);
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1fv(sampler_f, 1, &data[0]);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformfv_invalid_location (NegativeTestContext& ctx)
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(4);
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1fv(-2, 1, &data[0]);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2fv(-2, 1, &data[0]);
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3fv(-2, 1, &data[0]);
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(-2, 1, &data[0]);
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1fv(-1, 1, &data[0]);
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2fv(-1, 1, &data[0]);
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3fv(-1, 1, &data[0]);
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(-1, 1, &data[0]);
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformfv_invalid_count (NegativeTestContext& ctx)
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram	(program.getProgram());
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v			= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1)
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(8);
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1fv(vec4_v, 2, &data[0]);
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2fv(vec4_v, 2, &data[0]);
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3fv(vec4_v, 2, &data[0]);
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4fv(vec4_v, 2, &data[0]);
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniform*i
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformi_invalid_program (NegativeTestContext& ctx)
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(-1, 0);
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(-1, 0, 0);
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(-1, 0, 0, 0);
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(-1, 0, 0, 0, 0);
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformi_incompatible_type (NegativeTestContext& ctx)
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(ivec4_f, 0);
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(ivec4_f, 0, 0);
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(ivec4_f, 0, 0, 0);
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(ivec4_f, 0, 0, 0, 0);
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type unsigned int, uvec2, uvec3, uvec4, or an array of these.");
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(uvec4_f, 0);
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(uvec4_f, 0, 0);
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(uvec4_f, 0, 0, 0);
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(uvec4_f, 0, 0, 0, 0);
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(vec4_v, 0);
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(vec4_v, 0, 0);
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(vec4_v, 0, 0, 0);
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(vec4_v, 0, 0, 0, 0);
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformi_invalid_location (NegativeTestContext& ctx)
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(-2, 0);
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(-2, 0, 0);
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(-2, 0, 0, 0);
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(-2, 0, 0, 0, 0);
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(-1, 0);
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(-1, 0, 0);
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(-1, 0, 0, 0);
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(-1, 0, 0, 0, 0);
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniform*iv
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformiv_invalid_program (NegativeTestContext& ctx)
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLint> data(4);
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(-1, 1, &data[0]);
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(-1, 1, &data[0]);
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(-1, 1, &data[0]);
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(-1, 1, &data[0]);
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformiv_incompatible_type (NegativeTestContext& ctx)
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLint> data(4);
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(ivec4_f, 1, &data[0]);
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(ivec4_f, 1, &data[0]);
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(ivec4_f, 1, &data[0]);
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(ivec4_f, 1, &data[0]);
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(vec4_v, 1, &data[0]);
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(vec4_v, 1, &data[0]);
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(vec4_v, 1, &data[0]);
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(vec4_v, 1, &data[0]);
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type unsigned int, uvec2, uvec3 or uvec4.");
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(uvec4_f, 1, &data[0]);
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(uvec4_f, 1, &data[0]);
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(uvec4_f, 1, &data[0]);
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(uvec4_f, 1, &data[0]);
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformiv_invalid_location (NegativeTestContext& ctx)
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLint> data(4);
11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(-2, 1, &data[0]);
12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(-2, 1, &data[0]);
12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(-2, 1, &data[0]);
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(-2, 1, &data[0]);
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(-1, 1, &data[0]);
12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(-1, 1, &data[0]);
12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(-1, 1, &data[0]);
12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(-1, 1, &data[0]);
12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformiv_invalid_count (NegativeTestContext& ctx)
12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram			(program.getProgram());
12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f			= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (ivec4_f == -1)
12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLint> data(8);
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1iv(ivec4_f, 2, &data[0]);
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2iv(ivec4_f, 2, &data[0]);
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3iv(ivec4_f, 2, &data[0]);
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4iv(ivec4_f, 2, &data[0]);
12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniform{1234}ui
12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformui_invalid_program (NegativeTestContext& ctx)
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1ui(-1, 0);
12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2ui(-1, 0, 0);
12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3ui(-1, 0, 0, 0);
12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4ui(-1, 0, 0, 0, 0);
12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformui_incompatible_type (NegativeTestContext& ctx)
12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1ui(uvec4_f, 0);
12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2ui(uvec4_f, 0, 0);
12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3ui(uvec4_f, 0, 0, 0);
12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4ui(uvec4_f, 0, 0, 0, 0);
12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type int, ivec2, ivec3, ivec4, or an array of these.");
13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1ui(ivec4_f, 0);
13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2ui(ivec4_f, 0, 0);
13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3ui(ivec4_f, 0, 0, 0);
13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4ui(ivec4_f, 0, 0, 0, 0);
13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1ui(vec4_v, 0);
13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2ui(vec4_v, 0, 0);
13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3ui(vec4_v, 0, 0, 0);
13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4ui(vec4_v, 0, 0, 0, 0);
13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1ui(sampler_f, 0);
13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformui_invalid_location (NegativeTestContext& ctx)
13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(-2, 0);
13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(-2, 0, 0);
13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(-2, 0, 0, 0);
13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(-2, 0, 0, 0, 0);
13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1i(-1, 0);
13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2i(-1, 0, 0);
13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3i(-1, 0, 0, 0);
13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4i(-1, 0, 0, 0, 0);
13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniform{1234}uiv
13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformuiv_invalid_program (NegativeTestContext& ctx)
13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLuint> data(4);
13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(-1, 1, &data[0]);
13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(-1, 1, &data[0]);
13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(-1, 1, &data[0]);
13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(-1, 1, &data[0]);
13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformuiv_incompatible_type (NegativeTestContext& ctx)
13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLuint> data(4);
14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(uvec4_f, 1, &data[0]);
14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(uvec4_f, 1, &data[0]);
14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(uvec4_f, 1, &data[0]);
14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(uvec4_f, 1, &data[0]);
14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(vec4_v, 1, &data[0]);
14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(vec4_v, 1, &data[0]);
14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(vec4_v, 1, &data[0]);
14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(vec4_v, 1, &data[0]);
14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type int, ivec2, ivec3 or ivec4.");
14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(ivec4_f, 1, &data[0]);
14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(ivec4_f, 1, &data[0]);
14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(ivec4_f, 1, &data[0]);
14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(ivec4_f, 1, &data[0]);
14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(sampler_f, 1, &data[0]);
14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformuiv_invalid_location (NegativeTestContext& ctx)
14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLuint> data(4);
14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(-2, 1, &data[0]);
14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(-2, 1, &data[0]);
14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(-2, 1, &data[0]);
14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(-2, 1, &data[0]);
14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(-1, 1, &data[0]);
14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(-1, 1, &data[0]);
14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(-1, 1, &data[0]);
14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(-1, 1, &data[0]);
14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniformuiv_invalid_count (NegativeTestContext& ctx)
14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram			(program.getProgram());
14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int uvec4_f				= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (uvec4_f == -1)
14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLuint> data(8);
14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform1uiv(uvec4_f, 2, &data[0]);
15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform2uiv(uvec4_f, 2, &data[0]);
15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform3uiv(uvec4_f, 2, &data[0]);
15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniform4uiv(uvec4_f, 2, &data[0]);
15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ctx.glUniformMatrix*fv
15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniform_matrixfv_invalid_program (NegativeTestContext& ctx)
15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(16);
15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniform_matrixfv_incompatible_type (NegativeTestContext& ctx)
15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram			(program.getProgram());
15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint mat4_v			= ctx.glGetUniformLocation(program.getProgram(), "mat4_v");	// mat4
15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint sampler_f			= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (mat4_v == -1 || sampler_f == -1)
15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(16);
15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2fv(mat4_v, 1, GL_FALSE, &data[0]);
15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3fv(mat4_v, 1, GL_FALSE, &data[0]);
15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4fv(mat4_v, 1, GL_FALSE, &data[0]);
15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2fv(sampler_f, 1, GL_FALSE, &data[0]);
15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3fv(sampler_f, 1, GL_FALSE, &data[0]);
15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4fv(sampler_f, 1, GL_FALSE, &data[0]);
15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x3fv(sampler_f, 1, GL_FALSE, &data[0]);
15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x2fv(sampler_f, 1, GL_FALSE, &data[0]);
15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x4fv(sampler_f, 1, GL_FALSE, &data[0]);
15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x2fv(sampler_f, 1, GL_FALSE, &data[0]);
15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x4fv(sampler_f, 1, GL_FALSE, &data[0]);
16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x3fv(sampler_f, 1, GL_FALSE, &data[0]);
16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniform_matrixfv_invalid_location (NegativeTestContext& ctx)
16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(16);
16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]);
16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]);
16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]);
16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x3fv(-2, 1, GL_FALSE, &data[0]);
16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x2fv(-2, 1, GL_FALSE, &data[0]);
16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x4fv(-2, 1, GL_FALSE, &data[0]);
16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x2fv(-2, 1, GL_FALSE, &data[0]);
16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x4fv(-2, 1, GL_FALSE, &data[0]);
16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x3fv(-2, 1, GL_FALSE, &data[0]);
16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid uniform_matrixfv_invalid_count (NegativeTestContext& ctx)
16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram			(program.getProgram());
16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint mat4_v			= ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4
16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (mat4_v == -1)
16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.fail("Failed to retrieve uniform location");
16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GLfloat> data(32);
16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2fv(mat4_v, 2, GL_FALSE, &data[0]);
16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3fv(mat4_v, 2, GL_FALSE, &data[0]);
16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4fv(mat4_v, 2, GL_FALSE, &data[0]);
16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Transform feedback
17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid gen_transform_feedbacks (NegativeTestContext& ctx)
17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint id = 0;
17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks(-1, &id);
17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid bind_transform_feedback (NegativeTestContext& ctx)
17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint						tfID[2];
17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(2, tfID);
17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK.");
17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback(-1, tfID[0]);
17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation is active on the currently bound transform feedback object, and is not paused.");
17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[1]);
17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_INVALID_OPERATION);
17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(0);
17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(2, tfID);
17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError				(GL_NO_ERROR);
17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_transform_feedbacks (NegativeTestContext& ctx)
17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint id = 0;
17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks(1, &id);
17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks(-1, &id);
17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks(1, &id);
17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid begin_transform_feedback (NegativeTestContext& ctx)
17703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint						tfID[2];
17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(2, tfID);
17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if primitiveMode is not one of GL_POINTS, GL_LINES, or GL_TRIANGLES.");
17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(-1);
17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_ENUM);
17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is already active.");
17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_POINTS);
17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if any binding point used in transform feedback mode does not have a buffer object bound.");
18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because no program object is active.");
18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(0);
18093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because the active program object has specified no varying variables to record.");
18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 0, 0, GL_INTERLEAVED_ATTRIBS);
18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(2, tfID);
18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid pause_transform_feedback (NegativeTestContext& ctx)
18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint						tfID[2];
18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
18343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(2, tfID);
18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
18373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is paused.");
18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPauseTransformFeedback	();
18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPauseTransformFeedback	();
18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPauseTransformFeedback	();
18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(2, tfID);
18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid resume_transform_feedback (NegativeTestContext& ctx)
18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint						tfID[2];
18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(2, tfID);
18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
18773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is not paused.");
18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glResumeTransformFeedback	();
18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glResumeTransformFeedback	();
18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glPauseTransformFeedback	();
18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glResumeTransformFeedback	();
18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(2, tfID);
18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid end_transform_feedback (NegativeTestContext& ctx)
18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint						tfID = 0;
19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					buf = 0x1234;
19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying		= "gl_Position";
19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenBuffers				(1, &buf);
19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks		(1, &tfID);
19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram				(program.getProgram());
19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram				(program.getProgram());
19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is not active.");
19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_INVALID_OPERATION);
19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndTransformFeedback		();
19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteBuffers				(1, &buf);
19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks	(1, &tfID);
19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError					(GL_NO_ERROR);
19273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid get_transform_feedback_varying (NegativeTestContext& ctx)
19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint					tfID = 0;
19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram		program			(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram		programInvalid	(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying	= "gl_Position";
19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						maxTransformFeedbackVaryings = 0;
19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsizei					length;
19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsizei					size;
19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum					type;
19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	char					name[32];
19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks				(1, &tfID);
19433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings			(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
19453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_NO_ERROR);
19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLinkProgram						(program.getProgram());
19473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_NO_ERROR);
19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindTransformFeedback				(GL_TRANSFORM_FEEDBACK, tfID);
19503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_NO_ERROR);
19513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
19533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTransformFeedbackVarying		(-1, 0, 32, &length, &size, &type, &name[0]);
19543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_INVALID_VALUE);
19553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater or equal to the value of GL_TRANSFORM_FEEDBACK_VARYINGS.");
19583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetProgramiv						(program.getProgram(), GL_TRANSFORM_FEEDBACK_VARYINGS, &maxTransformFeedbackVaryings);
19593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTransformFeedbackVarying		(program.getProgram(), maxTransformFeedbackVaryings, 32, &length, &size, &type, &name[0]);
19603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_INVALID_VALUE);
19613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_VALUE is generated program has not been linked.");
19643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetTransformFeedbackVarying		(programInvalid.getProgram(), 0, 32, &length, &size, &type, &name[0]);
19653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_INVALID_OPERATION, GL_INVALID_VALUE);
19663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks			(1, &tfID);
19693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_NO_ERROR);
19703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
19713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid transform_feedback_varyings (NegativeTestContext& ctx)
19733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint					tfID = 0;
19753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram		program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
19763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* tfVarying	= "gl_Position";
19773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint					maxTransformFeedbackSeparateAttribs = 0;
19783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenTransformFeedbacks				(1, &tfID);
19803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_NO_ERROR);
19813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
19833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings			(0, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
19843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_INVALID_VALUE);
19853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if bufferMode is GL_SEPARATE_ATTRIBS and count is greater than GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGetIntegerv						(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTransformFeedbackSeparateAttribs);
19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glTransformFeedbackVaryings			(program.getProgram(), maxTransformFeedbackSeparateAttribs+1, &tfVarying, GL_SEPARATE_ATTRIBS);
19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_INVALID_VALUE);
19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteTransformFeedbacks			(1, &tfID);
19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError						(GL_NO_ERROR);
19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<FunctionContainer> getNegativeShaderApiTestFunctions ()
19983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FunctionContainer funcs[] =
20003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{create_shader,							"create_shader",						"Invalid glCreateShader() usage"			   },
20023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{shader_source,							"shader_source",						"Invalid glShaderSource() usage"			   },
20033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{compile_shader,						"compile_shader",						"Invalid glCompileShader() usage"			   },
20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{delete_shader,							"delete_shader",						"Invalid glDeleteShader() usage"			   },
20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{shader_binary,							"shader_binary",						"Invalid glShaderBinary() usage"			   },
20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{attach_shader,							"attach_shader",						"Invalid glAttachShader() usage"			   },
20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{detach_shader,							"detach_shader",						"Invalid glDetachShader() usage"			   },
20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{link_program,							"link_program",							"Invalid glLinkProgram() usage"				   },
20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{use_program,							"use_program",							"Invalid glUseProgram() usage"				   },
20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{delete_program,						"delete_program",						"Invalid glDeleteProgram() usage"			   },
20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{validate_program,						"validate_program",						"Invalid glValidateProgram() usage"			   },
20123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{get_program_binary,					"get_program_binary",					"Invalid glGetProgramBinary() usage"		   },
20133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{program_binary,						"program_binary",						"Invalid glProgramBinary() usage"			   },
20143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{program_parameteri,					"program_parameteri",					"Invalid glProgramParameteri() usage"		   },
20153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{gen_samplers,							"gen_samplers",							"Invalid glGenSamplers() usage"				   },
20163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{bind_sampler,							"bind_sampler",							"Invalid glBindSampler() usage"				   },
20173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{delete_samplers,						"delete_samplers",						"Invalid glDeleteSamplers() usage"			   },
20183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{get_sampler_parameteriv,				"get_sampler_parameteriv",				"Invalid glGetSamplerParameteriv() usage"	   },
20193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{get_sampler_parameterfv,				"get_sampler_parameterfv",				"Invalid glGetSamplerParameterfv() usage"	   },
20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{sampler_parameteri,					"sampler_parameteri",					"Invalid glSamplerParameteri() usage"		   },
20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{sampler_parameteriv,					"sampler_parameteriv",					"Invalid glSamplerParameteriv() usage"		   },
20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{sampler_parameterf,					"sampler_parameterf",					"Invalid glSamplerParameterf() usage"		   },
20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{sampler_parameterfv,					"sampler_parameterfv",					"Invalid glSamplerParameterfv() usage"		   },
20243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{get_attrib_location,					"get_attrib_location",					"Invalid glGetAttribLocation() usage"		   },
20253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{get_uniform_location,					"get_uniform_location",					"Invalid glGetUniformLocation() usage"		   },
20263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{bind_attrib_location,					"bind_attrib_location",					"Invalid glBindAttribLocation() usage"		   },
20273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniform_block_binding,					"uniform_block_binding",				"Invalid glUniformBlockBinding() usage"		   },
20283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformf_invalid_program,				"uniformf_invalid_program",				"Invalid glUniform{1234}f() usage"			   },
20293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformf_incompatible_type,			"uniformf_incompatible_type",			"Invalid glUniform{1234}f() usage"			   },
20303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformf_invalid_location,				"uniformf_invalid_location",			"Invalid glUniform{1234}f() usage"			   },
20313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformfv_invalid_program,				"uniformfv_invalid_program",			"Invalid glUniform{1234}fv() usage"			   },
20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformfv_incompatible_type,			"uniformfv_incompatible_type",			"Invalid glUniform{1234}fv() usage"			   },
20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformfv_invalid_location,			"uniformfv_invalid_location",			"Invalid glUniform{1234}fv() usage"			   },
20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformfv_invalid_count,				"uniformfv_invalid_count",				"Invalid glUniform{1234}fv() usage"			   },
20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformi_invalid_program,				"uniformi_invalid_program",				"Invalid glUniform{1234}i() usage"			   },
20363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformi_incompatible_type,			"uniformi_incompatible_type",			"Invalid glUniform{1234}i() usage"			   },
20373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformi_invalid_location,				"uniformi_invalid_location",			"Invalid glUniform{1234}i() usage"			   },
20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformiv_invalid_program,				"uniformiv_invalid_program",			"Invalid glUniform{1234}iv() usage"			   },
20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformiv_incompatible_type,			"uniformiv_incompatible_type",			"Invalid glUniform{1234}iv() usage"			   },
20403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformiv_invalid_location,			"uniformiv_invalid_location",			"Invalid glUniform{1234}iv() usage"			   },
20413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformiv_invalid_count,				"uniformiv_invalid_count",				"Invalid glUniform{1234}iv() usage"			   },
20423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformui_invalid_program,				"uniformui_invalid_program",			"Invalid glUniform{234}ui() usage"			   },
20433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformui_incompatible_type,			"uniformui_incompatible_type",			"Invalid glUniform{1234}ui() usage"			   },
20443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformui_invalid_location,			"uniformui_invalid_location",			"Invalid glUniform{1234}ui() usage"			   },
20453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformuiv_invalid_program,			"uniformuiv_invalid_program",			"Invalid glUniform{234}uiv() usage"			   },
20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformuiv_incompatible_type,			"uniformuiv_incompatible_type",			"Invalid glUniform{1234}uiv() usage"		   },
20473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformuiv_invalid_location,			"uniformuiv_invalid_location",			"Invalid glUniform{1234}uiv() usage"		   },
20483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniformuiv_invalid_count,				"uniformuiv_invalid_count",				"Invalid glUniform{1234}uiv() usage"		   },
20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniform_matrixfv_invalid_program,		"uniform_matrixfv_invalid_program",		"Invalid glUniformMatrix{234}fv() usage"	   },
20503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniform_matrixfv_incompatible_type,	"uniform_matrixfv_incompatible_type",	"Invalid glUniformMatrix{234}fv() usage"	   },
20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniform_matrixfv_invalid_location,		"uniform_matrixfv_invalid_location",	"Invalid glUniformMatrix{234}fv() usage"	   },
20523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{uniform_matrixfv_invalid_count,		"uniform_matrixfv_invalid_count",		"Invalid glUniformMatrix{234}fv() usage"	   },
20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{gen_transform_feedbacks,				"gen_transform_feedbacks",				"Invalid glGenTransformFeedbacks() usage"	   },
20543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{bind_transform_feedback,				"bind_transform_feedback",				"Invalid glBindTransformFeedback() usage"	   },
20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{delete_transform_feedbacks,			"delete_transform_feedbacks",			"Invalid glDeleteTransformFeedbacks() usage"   },
20563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{begin_transform_feedback,				"begin_transform_feedback",				"Invalid glBeginTransformFeedback() usage"	   },
20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{pause_transform_feedback,				"pause_transform_feedback",				"Invalid glPauseTransformFeedback() usage"	   },
20583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{resume_transform_feedback,				"resume_transform_feedback",			"Invalid glResumeTransformFeedback() usage"	   },
20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{end_transform_feedback,				"end_transform_feedback",				"Invalid glEndTransformFeedback() usage"	   },
20603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{get_transform_feedback_varying,		"get_transform_feedback_varying",		"Invalid glGetTransformFeedbackVarying() usage"},
20613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{transform_feedback_varyings,			"transform_feedback_varyings",			"Invalid glTransformFeedbackVaryings() usage"  },
20623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
20633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
20653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
20663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // NegativeTestShared
20683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
20693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
20703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
2071