13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 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 Rbo state query tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fShaderStateQueryTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsStateQueryUtil.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fApiCase.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GLint and other GL types
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* commonTestVertSource		=	"void main (void)\n"
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = vec4(0.0);\n"
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n";
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* commonTestFragSource		=	"void main (void)\n"
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_FragColor = vec4(0.0);\n"
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n";
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* brokenShader				=	"broken, this should not compile!\n"
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"\n";
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// rounds x.1 to x+1
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
613c827367444ee418f129b2c238299f49d3264554Jarkko PoyryT roundGLfloatToNearestIntegerUp (GLfloat val)
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (T)(ceil(val));
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// rounds x.9 to x
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
683c827367444ee418f129b2c238299f49d3264554Jarkko PoyryT roundGLfloatToNearestIntegerDown (GLfloat val)
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (T)(floor(val));
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool checkIntEquals (tcu::TestContext& testCtx, GLint got, GLint expected)
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (got != expected)
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return false;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return true;
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkPointerEquals (tcu::TestContext& testCtx, const void* got, const void* expected)
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (got != expected)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyShaderParam (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint shader, GLenum pname, GLenum reference)
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetShaderiv(shader, pname, &state);
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkIntEquals(testCtx, state, reference);
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool verifyProgramParam (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLenum pname, GLenum reference)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetProgramiv(program, pname, &state);
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return checkIntEquals(testCtx, state, reference);
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return false;
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyCurrentVertexAttribf (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attribValue.verifyValidity(testCtx);
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << "," << attribValue[3] << "]"
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndMessage;
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyCurrentVertexAttribConversion (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[4]> attribValue;
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attribValue.verifyValidity(testCtx);
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLint referenceAsGLintMin[] =
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(x),
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(y),
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(z),
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(w)
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLint referenceAsGLintMax[] =
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(x),
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(y),
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(z),
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(w)
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (attribValue[0] < referenceAsGLintMin[0] || attribValue[0] > referenceAsGLintMax[0] ||
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		attribValue[1] < referenceAsGLintMin[1] || attribValue[1] > referenceAsGLintMax[1] ||
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		attribValue[2] < referenceAsGLintMin[2] || attribValue[2] > referenceAsGLintMax[2] ||
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		attribValue[3] < referenceAsGLintMin[3] || attribValue[3] > referenceAsGLintMax[3])
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "// ERROR: expected in range "
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[0] << " " << referenceAsGLintMax[0] << "], "
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[1] << " " << referenceAsGLintMax[1] << "], "
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[2] << " " << referenceAsGLintMax[2] << "], "
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[3] << " " << referenceAsGLintMax[3] << "]"
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "; got "
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[0] << ", "
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[1] << ", "
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[2] << ", "
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[3] << " "
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "; Input="
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< x << "; "
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< y << "; "
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< z << "; "
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< w << " " << TestLog::EndMessage;
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid attribute value");
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyVertexAttrib (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLenum pname, GLenum reference)
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribiv(index, pname, &state);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkIntEquals(testCtx, state, reference);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue1f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x)
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[1]> state;
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x)
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0]
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue2f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x, float y)
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[2]> state;
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y)
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1]
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue3f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x, float y, float z)
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[3]> state;
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z)
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2]
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue4f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x, float y, float z, float w)
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[4]> state;
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z ||
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[3] != w)
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z << ", "
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< w
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2] << ", "
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[3]
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue1i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x)
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[1]> state;
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x)
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0]
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue2i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x, GLint y)
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[2]> state;
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y)
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1]
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue3i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x, GLint y, GLint z)
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[3]> state;
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z)
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2]
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue4i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w)
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[4]> state;
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z ||
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[3] != w)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z << ", "
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< w
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2] << ", "
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[3]
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int Count>
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValues (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, const GLfloat* values)
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[Count]> state;
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < Count; ++ndx)
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (values[ndx] != state[ndx])
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.getLog() << TestLog::Message << "// ERROR: at index " << ndx << " expected " << values[ndx] << "; got " << state[ndx] << TestLog::EndMessage;
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int N>
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformMatrixValues (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, const GLfloat* values, bool transpose)
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[N*N]> state;
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < N; ++y)
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < N; ++x)
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int refIndex = y*N + x;
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int stateIndex = transpose ? (x*N + y) : (y*N + x);
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (values[refIndex] != state[stateIndex])
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				testCtx.getLog() << TestLog::Message << "// ERROR: at index [" << y << "][" << x << "] expected " << values[refIndex] << "; got " << state[stateIndex] << TestLog::EndMessage;
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid requireShaderCompiler (tcu::TestContext& testCtx, glu::CallLogWrapper& gl)
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLboolean> state;
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetBooleanv(GL_SHADER_COMPILER, &state);
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx) || state != GL_TRUE)
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Test requires SHADER_COMPILER = TRUE");
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderTypeCase : public ApiCase
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderTypeCase (Context& context, const char* name, const char* description)
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum shaderTypes[] = {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER};
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx)
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint shader = glCreateShader(shaderTypes[ndx]);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_TYPE, shaderTypes[ndx]);
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shader);
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderCompileStatusCase : public ApiCase
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderCompileStatusCase (Context& context, const char* name, const char* description)
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		requireShaderCompiler(m_testCtx, *this);
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_FALSE);
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_FALSE);
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderInfoLogCase : public ApiCase
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderInfoLogCase (Context& context, const char* name, const char* description)
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		requireShaderCompiler(m_testCtx, *this);
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// INFO_LOG_LENGTH is 0 by default and it includes null-terminator
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shader, GL_INFO_LOG_LENGTH, 0);
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shader, 1, &brokenShader, DE_NULL);
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shader);
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the log length
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLint> logLength;
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!logLength.verifyValidity(m_testCtx))
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shader);
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (logLength == 0)
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shader);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check normal case
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'}; // non-zero initialization
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0; // written does not include null terminator
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderInfoLog(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check lengths are consistent
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (logLength <= DE_LENGTH_OF_ARRAY(buffer))
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (written != logLength-1)
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << logLength-1 << "; got " << written << TestLog::EndMessage;
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check null-terminator, either at end of buffer or at buffer[written]
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* terminator = &buffer[DE_LENGTH_OF_ARRAY(buffer) - 1];
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (logLength < DE_LENGTH_OF_ARRAY(buffer))
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				terminator = &buffer[written];
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (*terminator != '\0')
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)*terminator << TestLog::EndMessage;
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check with too small buffer
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'}; // non-zero initialization
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check string always ends with \0, even with small buffers
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderInfoLog(shader, 1, &written, buffer);
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length 0; got " << written << TestLog::EndMessage;
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (buffer[0] != '\0')
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)buffer[0] << TestLog::EndMessage;
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shader);
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderSourceCase : public ApiCase
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderSourceCase (Context& context, const char* name, const char* description)
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		requireShaderCompiler(m_testCtx, *this);
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// SHADER_SOURCE_LENGTH does include 0-terminator
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_SOURCE_LENGTH, 0);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the SHADER_SOURCE_LENGTH
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shader, 1, &brokenShader, DE_NULL);
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> sourceLength;
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sourceLength.verifyValidity(m_testCtx);
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = (GLint)std::string(brokenShader).length() + 1; // including the null terminator
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (sourceLength != referenceLength)
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength	<< "; got " << sourceLength << TestLog::EndMessage;
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the concat source SHADER_SOURCE_LENGTH
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* shaders[] = {brokenShader, brokenShader};
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shader, 2, shaders, DE_NULL);
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> sourceLength;
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sourceLength.verifyValidity(m_testCtx);
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = 2 * (GLint)std::string(brokenShader).length() + 1; // including the null terminator
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (sourceLength != referenceLength)
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength << "; got " << sourceLength << TestLog::EndMessage;
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the string length
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(DE_LENGTH_OF_ARRAY(buffer) > 2 * (int)std::string(brokenShader).length());
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0; // not inluding null-terminator
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderSource(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = 2 * (GLint)std::string(brokenShader).length();
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != referenceLength)
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length " << referenceLength << "; got " << written << TestLog::EndMessage;
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check null pointer at
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (buffer[referenceLength] != '\0')
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at " << referenceLength << TestLog::EndMessage;
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "did not get a null terminator");
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check with small buffer
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderSource(shader, 1, &written, buffer);
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written << TestLog::EndMessage;
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (buffer[0] != '\0')
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator; got=" << int(buffer[0]) << ", char=" << buffer[0] << TestLog::EndMessage;
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid terminator");
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shader);
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DeleteStatusCase : public ApiCase
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DeleteStatusCase (Context& context, const char* name, const char* description)
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderProg = glCreateProgram();
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(shaderProg, shaderVert);
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(shaderProg, shaderFrag);
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(shaderProg);
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, shaderProg, GL_LINK_STATUS, GL_TRUE);
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_FALSE);
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_FALSE);
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_FALSE);
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(shaderProg);
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(shaderProg);
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_TRUE);
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_TRUE);
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_TRUE);
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribInitialCase : public ApiCase
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribInitialCase (Context& context, const char* name, const char* description)
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// initial
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			attribValue.verifyValidity(m_testCtx);
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (attribValue[0] != 0.0f || attribValue[1] != 0.0f || attribValue[2] != 0.0f || attribValue[3] != 1.0f)
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "// ERROR: Expected [0, 0, 0, 1];"
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << "," << attribValue[3] << "]"
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< TestLog::EndMessage;
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribFloatCase : public ApiCase
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribFloatCase (Context& context, const char* name, const char* description)
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test write float/read float
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = rnd.getFloat(-64000, 64000);
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib4f(index, x, y, z, w);
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib3f(index, x, y, z);
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib2f(index, x, y);
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = 0.0f;
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib1f(index, x);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribConversionCase : public ApiCase
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribConversionCase (Context& context, const char* name, const char* description)
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test write float/read float
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = rnd.getFloat(-64000, 64000);
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib4f(index, x, y, z, w);
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib3f(index, x, y, z);
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib2f(index, x, y);
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = 0.0f;
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib1f(index, x);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramInfoLogCase : public ApiCase
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramInfoLogCase (Context& context, const char* name, const char* description)
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &brokenShader, DE_NULL);
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &brokenShader, DE_NULL);
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check INFO_LOG_LENGTH == GetProgramInfoLog len
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetProgramInfoLog(program, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> logLength;
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			logLength.verifyValidity(m_testCtx);
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (logLength != 0 && written+1 != logLength) // INFO_LOG_LENGTH contains 0-terminator
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected INFO_LOG_LENGTH " << written+1 << "; got " << logLength << TestLog::EndMessage;
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check GetProgramInfoLog works with too small buffer
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetProgramInfoLog(program, 1, &written, buffer);
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written << TestLog::EndMessage;
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramValidateStatusCase : public ApiCase
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramValidateStatusCase (Context& context, const char* name, const char* description)
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test validate ok
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderVert);
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderFrag);
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint program = glCreateProgram();
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderVert);
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderFrag);
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(program);
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderVert,	GL_COMPILE_STATUS,	GL_TRUE);
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderFrag,	GL_COMPILE_STATUS,	GL_TRUE);
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam	(m_testCtx, *this, program,		GL_LINK_STATUS,		GL_TRUE);
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glValidateProgram(program);
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_TRUE);
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderVert);
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderFrag);
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteProgram(program);
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test with broken shader
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderVert, 1, &commonTestVertSource,	DE_NULL);
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderFrag, 1, &brokenShader,			DE_NULL);
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderVert);
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderFrag);
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint program = glCreateProgram();
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderVert);
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderFrag);
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(program);
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderVert,	GL_COMPILE_STATUS,	GL_TRUE);
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderFrag,	GL_COMPILE_STATUS,	GL_FALSE);
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam	(m_testCtx, *this, program,		GL_LINK_STATUS,		GL_FALSE);
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glValidateProgram(program);
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_FALSE);
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderVert);
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderFrag);
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteProgram(program);
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramAttachedShadersCase : public ApiCase
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramAttachedShadersCase (Context& context, const char* name, const char* description)
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check ATTACHED_SHADERS
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 0);
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 1);
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 2);
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check GetAttachedShaders
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaders[2] = {0, 0};
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint count = 0;
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetAttachedShaders(program, DE_LENGTH_OF_ARRAY(shaders), &count, shaders);
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (count != 2)
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 2; got " << count << TestLog::EndMessage;
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// shaders are the attached shaders?
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!((shaders[0] == shaderVert && shaders[1] == shaderFrag) ||
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				  (shaders[0] == shaderFrag && shaders[1] == shaderVert)))
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected {" << shaderVert << ", " << shaderFrag << "}; got {" << shaders[0] << ", " << shaders[1] << "}" << TestLog::EndMessage;
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check GetAttachedShaders with too small buffer
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaders[2] = {0, 0};
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint count = 0;
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetAttachedShaders(program, 0, &count, shaders);
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (count != 0)
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0; got " << count << TestLog::EndMessage;
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			count = 0;
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetAttachedShaders(program, 1, &count, shaders);
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (count != 1)
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 1; got " << count << TestLog::EndMessage;
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramActiveUniformNameCase : public ApiCase
11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramActiveUniformNameCase (Context& context, const char* name, const char* description)
11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp float uniformNameWithLength23;\n"
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec2 uniformVec2;\n"
12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat4 uniformMat4;\n"
12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0) + vec4(uniformNameWithLength23) + vec4(uniformVec2.x) + vec4(uniformMat4[2][3]);\n"
12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORMS, 3);
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORM_MAX_LENGTH, (GLint)std::string("uniformNameWithLength23").length() + 1); // including a null terminator
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* uniformNames[] =
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniformNameWithLength23",
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniformVec2",
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniformMat4"
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check names
12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformNames); ++ndx)
12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char  buffer[2048]	= {'x'};
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char* bufferEnd		= (buffer + 1);
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0; // null terminator not included
12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint size = 0;
12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum type = 0;
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniform(program, ndx, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written < DE_LENGTH_OF_ARRAY(buffer))
12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				bufferEnd = &buffer[written];
12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// find matching uniform
12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const std::string uniformName(buffer, bufferEnd);
12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				bool found = false;
12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int uniformNdx = 0; uniformNdx < DE_LENGTH_OF_ARRAY(uniformNames); ++uniformNdx)
12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (uniformName == uniformNames[uniformNdx])
12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{
12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						found = true;
12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						break;
12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					}
12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (!found)
12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.getLog() << TestLog::Message << "// ERROR: Got unknown uniform name: " << uniformName << TestLog::EndMessage;
12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name");
12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// and with too small buffer
12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			written = 0;
12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniform(program, ndx, 1, &written, &size, &type, buffer);
12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0 got " << written << TestLog::EndMessage;
12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramUniformCase : public ApiCase
13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramUniformCase (Context& context, const char* name, const char* description)
13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const struct UniformType
13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* declaration;
13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* postDeclaration;
13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* precision;
13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* layout;
13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* getter;
13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum		type;
13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint		size;
13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint		isRowMajor;
13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} uniformTypes[] =
13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "float",					"",			"highp",	"",				"uniformValue",													GL_FLOAT,							1, GL_FALSE },
13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "float",					"[2]",		"highp",	"",				"uniformValue[1]",												GL_FLOAT,							2, GL_FALSE },
13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "vec2",					"",			"highp",	"",				"uniformValue.x",												GL_FLOAT_VEC2,						1, GL_FALSE },
13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "vec3",					"",			"highp",	"",				"uniformValue.x",												GL_FLOAT_VEC3,						1, GL_FALSE },
13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "vec4",					"",			"highp",	"",				"uniformValue.x",												GL_FLOAT_VEC4,						1, GL_FALSE },
13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "int",					"",			"highp",	"",				"float(uniformValue)",											GL_INT,								1, GL_FALSE },
13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "ivec2",					"",			"highp",	"",				"float(uniformValue.x)",										GL_INT_VEC2,						1, GL_FALSE },
13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "ivec3",					"",			"highp",	"",				"float(uniformValue.x)",										GL_INT_VEC3,						1, GL_FALSE },
13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "ivec4",					"",			"highp",	"",				"float(uniformValue.x)",										GL_INT_VEC4,						1, GL_FALSE },
13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bool",					"",			"",			"",				"float(uniformValue)",											GL_BOOL,							1, GL_FALSE },
13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bvec2",					"",			"",			"",				"float(uniformValue.x)",										GL_BOOL_VEC2,						1, GL_FALSE },
13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bvec3",					"",			"",			"",				"float(uniformValue.x)",										GL_BOOL_VEC3,						1, GL_FALSE },
13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bvec4",					"",			"",			"",				"float(uniformValue.x)",										GL_BOOL_VEC4,						1, GL_FALSE },
13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat2",					"",			"highp",	"",				"float(uniformValue[0][0])",									GL_FLOAT_MAT2,						1, GL_FALSE },
13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat3",					"",			"highp",	"",				"float(uniformValue[0][0])",									GL_FLOAT_MAT3,						1, GL_FALSE },
13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat4",					"",			"highp",	"",				"float(uniformValue[0][0])",									GL_FLOAT_MAT4,						1, GL_FALSE },
13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "sampler2D",				"",			"highp",	"",				"float(texture2D(uniformValue, vec2(0.0, 0.0)).r)",				GL_SAMPLER_2D,						1, GL_FALSE },
13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "samplerCube",			"",			"highp",	"",				"float(textureCube(uniformValue, vec3(0.0, 0.0, 0.0)).r)",		GL_SAMPLER_CUBE,					1, GL_FALSE },
13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* vertSource =
13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0);\n"
13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert	= glCreateShader(GL_VERTEX_SHADER);
13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag	= glCreateShader(GL_FRAGMENT_SHADER);
13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program		= glCreateProgram();
13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &vertSource, DE_NULL);
13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformTypes); ++ndx)
13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::ScopedLogSection(m_log, uniformTypes[ndx].declaration, std::string("Verify type of ") + uniformTypes[ndx].declaration + " variable" + uniformTypes[ndx].postDeclaration );
13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// gen fragment shader
13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			std::ostringstream frag;
13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << uniformTypes[ndx].layout << "uniform " << uniformTypes[ndx].precision << " " << uniformTypes[ndx].declaration << " uniformValue" << uniformTypes[ndx].postDeclaration << ";\n";
13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "void main (void)\n";
13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "{\n";
13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "	gl_FragColor = vec4(" << uniformTypes[ndx].getter << ");\n";
13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "}\n";
13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				std::string fragmentSource = frag.str();
13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const char* fragmentSourceCStr = fragmentSource.c_str();
13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glShaderSource(shaderFrag, 1, &fragmentSourceCStr, DE_NULL);
13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// compile & link
13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderFrag);
13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(program);
13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test
13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE))
13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const GLint index = 0; // first and only active uniform
13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				char buffer[]	= "not written to"; // not written to
13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				GLint written	= 0;
13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				GLint size		= 0;
13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				GLenum type		= 0;
13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glGetActiveUniform(program, index, 0, &written, &size, &type, buffer);
13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkIntEquals(m_testCtx, type, uniformTypes[ndx].type);
13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkIntEquals(m_testCtx, size, uniformTypes[ndx].size);
13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ActiveAttributesCase : public ApiCase
14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ActiveAttributesCase (Context& context, const char* name, const char* description)
14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"attribute highp vec2 longInputAttributeName;\n"
14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"attribute highp vec2 shortName;\n"
14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = longInputAttributeName.yxxy + shortName.xyxy;\n"
14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTES, 2);
14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, (GLint)std::string("longInputAttributeName").length() + 1); // does include null-terminator
14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check names
14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int attributeNdx = 0; attributeNdx < 2; ++attributeNdx)
14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint size = 0;
14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum type = 0;
14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveAttrib(program, attributeNdx, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (deStringBeginsWith(buffer, "longInputAttributeName"))
14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkIntEquals(m_testCtx, written, (GLint)std::string("longInputAttributeName").length()); // does NOT include null-terminator
14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else if (deStringBeginsWith(buffer, "shortName"))
14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkIntEquals(m_testCtx, written, (GLint)std::string("shortName").length()); // does NOT include null-terminator
14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Got unexpected attribute name." << TestLog::EndMessage;
14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got unexpected name");
14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// and with too short buffer
14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint size = 0;
14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum type = 0;
14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveAttrib(program, 0, 1, &written, &size, &type, buffer);
14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkIntEquals(m_testCtx, written, 0);
14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct PointerData
15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint		size;
15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum		type;
15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint		stride;
15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLboolean	normalized;
15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void*		pointer;
15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeSizeCase : public ApiCase
15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeSizeCase (Context& context, const char* name, const char* description)
15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLfloat vertexData[4] = {0.0f}; // never accessed
15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test VertexAttribPointer
15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const PointerData pointers[] =
15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// size test
15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 4, GL_FLOAT,		0,	GL_FALSE, vertexData },
15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 3, GL_FLOAT,		0,	GL_FALSE, vertexData },
15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 2, GL_FLOAT,		0,	GL_FALSE, vertexData },
15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FLOAT,		0,	GL_FALSE, vertexData },
15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 4, GL_SHORT,		0,	GL_FALSE, vertexData },
15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 3, GL_SHORT,		0,	GL_FALSE, vertexData },
15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 2, GL_SHORT,		0,	GL_FALSE, vertexData },
15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_SHORT,		0,	GL_FALSE, vertexData },
15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[ndx].size);
15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeTypeCase : public ApiCase
15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeTypeCase (Context& context, const char* name, const char* description)
15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLfloat vertexData[4] = {0.0f}; // never accessed
15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const PointerData pointers[] =
15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_BYTE,								0,	GL_FALSE, vertexData	},
15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE, vertexData	},
15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_SHORT,								0,	GL_FALSE, vertexData	},
15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE, vertexData	},
15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FIXED,								0,	GL_FALSE, vertexData	},
15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FLOAT,								0,	GL_FALSE, vertexData	},
15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx].type);
15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeStrideCase : public ApiCase
15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeStrideCase (Context& context, const char* name, const char* description)
15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLfloat vertexData[4] = {0.0f}; // never accessed
15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		struct StridePointerData
15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint		size;
15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum		type;
15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint		stride;
15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			void*		pointer;
15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test VertexAttribPointer
15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const StridePointerData pointers[] =
16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FLOAT,				0,	vertexData },
16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FLOAT,				1,	vertexData },
16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FLOAT,				4,	vertexData },
16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_SHORT,				0,	vertexData },
16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_SHORT,				1,	vertexData },
16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_SHORT,				4,	vertexData },
16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FIXED,				0,	vertexData },
16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FIXED,				1,	vertexData },
16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FIXED,				4,	vertexData },
16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_BYTE,				0,	vertexData },
16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_UNSIGNED_SHORT,		1,	vertexData },
16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_UNSIGNED_SHORT,		4,	vertexData },
16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 4, GL_UNSIGNED_BYTE,		0,	vertexData },
16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 4, GL_UNSIGNED_BYTE,		1,	vertexData },
16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 4, GL_UNSIGNED_BYTE,		4,	vertexData },
16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			};
16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, GL_FALSE, pointers[ndx].stride, pointers[ndx].pointer);
16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				expectError(GL_NO_ERROR);
16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx].stride);
16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeNormalizedCase : public ApiCase
16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeNormalizedCase (Context& context, const char* name, const char* description)
16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLfloat vertexData[4] = {0.0f}; // never accessed
16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test VertexAttribPointer
16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const PointerData pointers[] =
16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_BYTE,								0,	GL_FALSE,	vertexData	},
16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_SHORT,								0,	GL_FALSE,	vertexData	},
16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE,	vertexData	},
16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE,	vertexData	},
16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_BYTE,								0,	GL_TRUE,	vertexData	},
16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_SHORT,								0,	GL_TRUE,	vertexData	},
16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_UNSIGNED_BYTE,						0,	GL_TRUE,	vertexData	},
16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_UNSIGNED_SHORT,						0,	GL_TRUE,	vertexData	},
16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			};
16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				expectError(GL_NO_ERROR);
16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, pointers[ndx].normalized);
16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeEnabledCase : public ApiCase
16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeEnabledCase (Context& context, const char* name, const char* description)
16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// VERTEX_ATTRIB_ARRAY_ENABLED
16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glEnableVertexAttribArray(0);
16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE);
16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDisableVertexAttribArray(0);
16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeBufferBindingCase : public ApiCase
16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeBufferBindingCase (Context& context, const char* name, const char* description)
16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// initial
16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, 0);
16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint bufferID;
17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &bufferID);
17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_ARRAY_BUFFER, bufferID);
17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufferID);
17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteBuffers(1, &bufferID);
17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributePointerCase : public ApiCase
17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributePointerCase (Context& context, const char* name, const char* description)
17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLvoid*> initialState;
17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &initialState);
17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		initialState.verifyValidity(m_testCtx);
17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkPointerEquals(m_testCtx, initialState, 0);
17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLfloat vertexData[4] = {0.0f}; // never accessed
17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const PointerData pointers[] =
17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_BYTE,				0,	GL_FALSE, &vertexData[2] },
17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_SHORT,				0,	GL_FALSE, &vertexData[1] },
17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FIXED,				0,	GL_FALSE, &vertexData[2] },
17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FIXED,				0,	GL_FALSE, &vertexData[1] },
17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FLOAT,				0,	GL_FALSE, &vertexData[0] },
17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FLOAT,				0,	GL_FALSE, &vertexData[3] },
17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FLOAT,				0,	GL_FALSE, &vertexData[2] },
17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_UNSIGNED_SHORT,		0,	GL_FALSE, &vertexData[0] },
17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 4, GL_UNSIGNED_SHORT,		0,	GL_FALSE, &vertexData[1] },
17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 4, GL_UNSIGNED_SHORT,		0,	GL_FALSE, &vertexData[2] },
17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLvoid*> state;
17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			state.verifyValidity(m_testCtx);
17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkPointerEquals(m_testCtx, state, pointers[ndx].pointer);
17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueFloatCase : public ApiCase
17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueFloatCase (Context& context, const char* name, const char* description)
17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp float floatUniform;\n"
17693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec2 float2Uniform;\n"
17703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec3 float3Uniform;\n"
17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec4 float4Uniform;\n"
17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(floatUniform + float2Uniform.x + float3Uniform.x + float4Uniform.x);\n"
17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(testVertSource, testFragSource));
17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!program.isOk())
17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << program;
17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program.getProgram());
17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "floatUniform");
17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1f(location, 1.0f);
17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program.getProgram(), location, 1.0f);
17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "float2Uniform");
18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2f(location, 1.0f, 2.0f);
18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program.getProgram(), location, 1.0f, 2.0f);
18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "float3Uniform");
18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3f(location, 1.0f, 2.0f, 3.0f);
18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program.getProgram(), location, 1.0f, 2.0f, 3.0f);
18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "float4Uniform");
18093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4f(location, 1.0f, 2.0f, 3.0f, 4.0f);
18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program.getProgram(), location, 1.0f, 2.0f, 3.0f, 4.0f);
18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueIntCase : public ApiCase
18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueIntCase (Context& context, const char* name, const char* description)
18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
18263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp int intUniform;\n"
18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp ivec2 int2Uniform;\n"
18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp ivec3 int3Uniform;\n"
18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp ivec4 int4Uniform;\n"
18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
18333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
18343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(float(intUniform + int2Uniform.x + int3Uniform.x + int4Uniform.x));\n"
18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
18363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
18373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(testVertSource, testFragSource));
18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!program.isOk())
18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << program;
18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program.getProgram());
18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "intUniform");
18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1i(location, 1);
18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "int2Uniform");
18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2i(location, 1, 2);
18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2i(m_testCtx, *this, program.getProgram(), location, 1, 2);
18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "int3Uniform");
18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3i(location, 1, 2, 3);
18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3i(m_testCtx, *this, program.getProgram(), location, 1, 2, 3);
18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "int4Uniform");
18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4i(location, 1, 2, 3, 4);
18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4i(m_testCtx, *this, program.getProgram(), location, 1, 2, 3, 4);
18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueBooleanCase : public ApiCase
18773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueBooleanCase (Context& context, const char* name, const char* description)
18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bool boolUniform;\n"
18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bvec2 bool2Uniform;\n"
18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bvec3 bool3Uniform;\n"
18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bvec4 bool4Uniform;\n"
18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(float(boolUniform) + float(bool2Uniform.x) + float(bool3Uniform.x) + float(bool4Uniform.x));\n"
18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(testVertSource, testFragSource));
19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!program.isOk())
19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << program;
19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program.getProgram());
19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// int conversion
19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "boolUniform");
19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1i(location, 1);
19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "bool2Uniform");
19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2i(location, 1, 2);
19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2i(m_testCtx, *this, program.getProgram(), location, 1, 1);
19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "bool3Uniform");
19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3i(location, 0, 1, 2);
19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3i(m_testCtx, *this, program.getProgram(), location, 0, 1, 1);
19273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "bool4Uniform");
19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4i(location, 1, 0, 1, -1);
19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4i(m_testCtx, *this, program.getProgram(), location, 1, 0, 1, 1);
19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// float conversion
19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "boolUniform");
19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1f(location, 1.0f);
19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "bool2Uniform");
19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2f(location, 1.0f, 0.1f);
19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2i(m_testCtx, *this, program.getProgram(), location, 1, 1);
19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "bool3Uniform");
19433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3f(location, 0.0f, 0.1f, -0.1f);
19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3i(m_testCtx, *this, program.getProgram(), location, 0, 1, 1);
19453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "bool4Uniform");
19473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4f(location, 1.0f, 0.0f, 0.1f, -0.9f);
19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4i(m_testCtx, *this, program.getProgram(), location, 1, 0, 1, 1);
19493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
19513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
19543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueSamplerCase : public ApiCase
19563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
19583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueSamplerCase (Context& context, const char* name, const char* description)
19593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
19603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
19643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
19663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
19673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
19683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0);\n"
19693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
19703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
19713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp sampler2D uniformSampler;\n"
19723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
19743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
19753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(texture2D(uniformSampler, vec2(0.0, 0.0)).x);\n"
19763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
19773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(testVertSource, testFragSource));
19793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!program.isOk())
19803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
19813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << program;
19823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
19833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
19843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
19853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program.getProgram());
19873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "uniformSampler");
19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1i(location, 1);
19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
19993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueArrayCase : public ApiCase
20013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
20023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
20033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueArrayCase (Context& context, const char* name, const char* description)
20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp float arrayUniform[5];"
20123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec2 array2Uniform[5];"
20133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec3 array3Uniform[5];"
20143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec4 array4Uniform[5];"
20153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
20163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
20173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = \n"
20183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(arrayUniform[0]		+ arrayUniform[1]		+ arrayUniform[2]		+ arrayUniform[3]		+ arrayUniform[4])\n"
20193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(array2Uniform[0].x	+ array2Uniform[1].x	+ array2Uniform[2].x	+ array2Uniform[3].x	+ array2Uniform[4].x)\n"
20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(array3Uniform[0].x	+ array3Uniform[1].x	+ array3Uniform[2].x	+ array3Uniform[3].x	+ array3Uniform[4].x)\n"
20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(array4Uniform[0].x	+ array4Uniform[1].x	+ array4Uniform[2].x	+ array4Uniform[3].x	+ array4Uniform[4].x);\n"
20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
20243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
20263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
20273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
20283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
20293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(testVertSource, testFragSource));
20313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!program.isOk())
20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << program;
20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
20363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program.getProgram());
20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
20423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float uniformValue[5 * 4] =
20443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-1.0f,	0.1f,	4.0f,	800.0f,
20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			13.0f,	55.0f,	12.0f,	91.0f,
20473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-55.1f,	1.1f,	98.0f,	19.0f,
20483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			41.0f,	65.0f,	4.0f,	12.2f,
20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			95.0f,	77.0f,	32.0f,	48.0f
20503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "arrayUniform");
20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1fv(location, 5, uniformValue);
20543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "arrayUniform[0]"), uniformValue[0]);
20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "arrayUniform[1]"), uniformValue[1]);
20583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "arrayUniform[2]"), uniformValue[2]);
20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "arrayUniform[3]"), uniformValue[3]);
20603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "arrayUniform[4]"), uniformValue[4]);
20613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(),"array2Uniform");
20643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2fv(location, 5, uniformValue);
20653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array2Uniform[0]"), uniformValue[2 * 0], uniformValue[(2 * 0) + 1]);
20683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array2Uniform[1]"), uniformValue[2 * 1], uniformValue[(2 * 1) + 1]);
20693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array2Uniform[2]"), uniformValue[2 * 2], uniformValue[(2 * 2) + 1]);
20703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array2Uniform[3]"), uniformValue[2 * 3], uniformValue[(2 * 3) + 1]);
20713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array2Uniform[4]"), uniformValue[2 * 4], uniformValue[(2 * 4) + 1]);
20723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(),"array3Uniform");
20753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3fv(location, 5, uniformValue);
20763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array3Uniform[0]"), uniformValue[3 * 0], uniformValue[(3 * 0) + 1], uniformValue[(3 * 0) + 2]);
20793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array3Uniform[1]"), uniformValue[3 * 1], uniformValue[(3 * 1) + 1], uniformValue[(3 * 1) + 2]);
20803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array3Uniform[2]"), uniformValue[3 * 2], uniformValue[(3 * 2) + 1], uniformValue[(3 * 2) + 2]);
20813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array3Uniform[3]"), uniformValue[3 * 3], uniformValue[(3 * 3) + 1], uniformValue[(3 * 3) + 2]);
20823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array3Uniform[4]"), uniformValue[3 * 4], uniformValue[(3 * 4) + 1], uniformValue[(3 * 4) + 2]);
20833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(),"array4Uniform");
20863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4fv(location, 5, uniformValue);
20873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array4Uniform[0]"), uniformValue[4 * 0], uniformValue[(4 * 0) + 1], uniformValue[(4 * 0) + 2], uniformValue[(4 * 0) + 3]);
20903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array4Uniform[1]"), uniformValue[4 * 1], uniformValue[(4 * 1) + 1], uniformValue[(4 * 1) + 2], uniformValue[(4 * 1) + 3]);
20913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array4Uniform[2]"), uniformValue[4 * 2], uniformValue[(4 * 2) + 1], uniformValue[(4 * 2) + 2], uniformValue[(4 * 2) + 3]);
20923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array4Uniform[3]"), uniformValue[4 * 3], uniformValue[(4 * 3) + 1], uniformValue[(4 * 3) + 2], uniformValue[(4 * 3) + 3]);
20933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program.getProgram(), glGetUniformLocation(program.getProgram(), "array4Uniform[4]"), uniformValue[4 * 4], uniformValue[(4 * 4) + 1], uniformValue[(4 * 4) + 2], uniformValue[(4 * 4) + 3]);
20943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
20973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
20993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
21003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueMatrixCase : public ApiCase
21023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
21043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueMatrixCase (Context& context, const char* name, const char* description)
21053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
21063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
21103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
21123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat2 mat2Uniform;"
21133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat3 mat3Uniform;"
21143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat4 mat4Uniform;"
21153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
21163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
21173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(mat2Uniform[0][0] + mat3Uniform[0][0] + mat4Uniform[0][0]);\n"
21183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
21193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
21203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
21223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
21233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_FragColor = vec4(0.0);\n"
21243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
21253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(testVertSource, testFragSource));
21273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!program.isOk())
21283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << program;
21303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
21313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
21323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
21333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program.getProgram());
21353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
21363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
21383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float matrixValues[4 * 4] =
21403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-1.0f,	0.1f,	4.0f,	800.0f,
21423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			13.0f,	55.0f,	12.0f,	91.0f,
21433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-55.1f,	1.1f,	98.0f,	19.0f,
21443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			41.0f,	65.0f,	4.0f,	12.2f,
21453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
21463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// the values of the matrix are returned in column major order but they can be given in either order
21483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "mat2Uniform");
21503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix2fv(location, 1, GL_FALSE, matrixValues);
21513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<2>(m_testCtx, *this, program.getProgram(), location, matrixValues, false);
21523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "mat3Uniform");
21543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix3fv(location, 1, GL_FALSE, matrixValues);
21553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<3>(m_testCtx, *this, program.getProgram(), location, matrixValues, false);
21563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program.getProgram(), "mat4Uniform");
21583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix4fv(location, 1, GL_FALSE, matrixValues);
21593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<4>(m_testCtx, *this, program.getProgram(), location, matrixValues, false);
21603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
21623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
21633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
21653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PrecisionFormatCase : public ApiCase
21673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
21693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct RequiredFormat
21703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int negativeRange;
21723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int positiveRange;
21733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int precision;
21743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
21753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PrecisionFormatCase (Context& context, const char* name, const char* description, glw::GLenum shaderType, glw::GLenum precisionType)
21773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase			(context, name, description)
21783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_shaderType		(shaderType)
21793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_precisionType	(precisionType)
21803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
21843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
21853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const RequiredFormat											expected = getRequiredFormat();
21873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool															error = false;
21883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLboolean>	shaderCompiler;
21893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint[2]>	range;
21903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint>		precision;
21913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// requires SHADER_COMPILER = true
21933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetBooleanv(GL_SHADER_COMPILER, &shaderCompiler);
21943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
21953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!shaderCompiler.verifyValidity(m_testCtx))
21973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
21983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (shaderCompiler != GL_TRUE)
21993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("SHADER_COMPILER = TRUE required");
22003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// query values
22023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetShaderPrecisionFormat(m_shaderType, m_precisionType, range, &precision);
22033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
22043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!range.verifyValidity(m_testCtx))
22063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
22073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!precision.verifyValidity(m_testCtx))
22083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
22093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log
22113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< tcu::TestLog::Message
22123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "range[0] = " << range[0] << "\n"
22133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "range[1] = " << range[1] << "\n"
22143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "precision = " << precision
22153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< tcu::TestLog::EndMessage;
22163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// special case for highp and fragment shader
22183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_shaderType == GL_FRAGMENT_SHADER && (m_precisionType == GL_HIGH_FLOAT || m_precisionType == GL_HIGH_INT))
22203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// not supported is a valid return value
22223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (range[0] == 0 && range[1] == 0 && precision == 0)
22233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				return;
22243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// verify the returned values
22273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (range[0] < expected.negativeRange)
22293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << tcu::TestLog::Message << "// ERROR: Invalid range[0], expected greater or equal to " << expected.negativeRange << tcu::TestLog::EndMessage;
22313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			error = true;
22323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (range[1] < expected.positiveRange)
22353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << tcu::TestLog::Message << "// ERROR: Invalid range[1], expected greater or equal to " << expected.positiveRange << tcu::TestLog::EndMessage;
22373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			error = true;
22383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (precision < expected.precision)
22413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_log << tcu::TestLog::Message << "// ERROR: Invalid precision, expected greater or equal to " << expected.precision << tcu::TestLog::EndMessage;
22433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			error = true;
22443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (error)
22473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid precision/range");
22483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RequiredFormat getRequiredFormat (void) const
22513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Precisions for different types.
22533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// For example highp float: range: (-2^62, 2^62) => min = -2^62 + e, max = 2^62 - e
22543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const RequiredFormat requirements[] =
22553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{  0,  0,  8 }, //!< lowp float
22573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 13, 13, 10 }, //!< mediump float
22583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 61, 61, 16 }, //!< highp float
22593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 7,   7,  0 }, //!< lowp int
22603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 9,   9,  0 }, //!< mediump int
22613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 15, 15,  0 }, //!< highp int
22623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
22633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int ndx = (int)m_precisionType - (int)GL_LOW_FLOAT;
22643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(ndx >= 0);
22663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(ndx < DE_LENGTH_OF_ARRAY(requirements));
22673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return requirements[ndx];
22683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::GLenum m_shaderType;
22713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::GLenum m_precisionType;
22723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
22733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
22753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryShaderStateQueryTests::ShaderStateQueryTests (Context& context)
22783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "shader", "Shader State Query tests")
22793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
22813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ShaderStateQueryTests::init (void)
22833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// shader
22853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderTypeCase						(m_context, "shader_type",							"SHADER_TYPE"));
22863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderCompileStatusCase			(m_context, "shader_compile_status",				"COMPILE_STATUS"));
22873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderInfoLogCase					(m_context, "shader_info_log_length",				"INFO_LOG_LENGTH"));
22883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderSourceCase					(m_context, "shader_source_length",					"SHADER_SOURCE_LENGTH"));
22893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// shader and program
22913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new DeleteStatusCase					(m_context, "delete_status",						"DELETE_STATUS"));
22923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// vertex-attrib
22943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribInitialCase		(m_context, "current_vertex_attrib_initial",		"CURRENT_VERTEX_ATTRIB"));
22953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribFloatCase		(m_context, "current_vertex_attrib_float",			"CURRENT_VERTEX_ATTRIB"));
22963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribConversionCase	(m_context, "current_vertex_attrib_float_to_int",	"CURRENT_VERTEX_ATTRIB"));
22973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// program
22993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramInfoLogCase					(m_context, "program_info_log_length",				"INFO_LOG_LENGTH"));
23003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramValidateStatusCase			(m_context, "program_validate_status",				"VALIDATE_STATUS"));
23013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramAttachedShadersCase			(m_context, "program_attached_shaders",				"ATTACHED_SHADERS"));
23023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramActiveUniformNameCase		(m_context, "program_active_uniform_name",			"ACTIVE_UNIFORMS and ACTIVE_UNIFORM_MAX_LENGTH"));
23043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramUniformCase					(m_context, "program_active_uniform_types",			"UNIFORM_TYPE and UNIFORM_SIZE"));
23053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// attribute related
23073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ActiveAttributesCase				(m_context, "active_attributes",					"ACTIVE_ATTRIBUTES and ACTIVE_ATTRIBUTE_MAX_LENGTH"));
23083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeSizeCase			(m_context, "vertex_attrib_size",					"VERTEX_ATTRIB_ARRAY_SIZE"));
23093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeTypeCase			(m_context, "vertex_attrib_type",					"VERTEX_ATTRIB_ARRAY_TYPE"));
23103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeStrideCase			(m_context, "vertex_attrib_stride",					"VERTEX_ATTRIB_ARRAY_STRIDE"));
23113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeNormalizedCase		(m_context, "vertex_attrib_normalized",				"VERTEX_ATTRIB_ARRAY_NORMALIZED"));
23123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeEnabledCase			(m_context, "vertex_attrib_array_enabled",			"VERTEX_ATTRIB_ARRAY_ENABLED"));
23133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeBufferBindingCase	(m_context, "vertex_attrib_array_buffer_binding",	"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"));
23143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributePointerCase			(m_context, "vertex_attrib_pointerv",				"GetVertexAttribPointerv"));
23153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// uniform values
23173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueFloatCase				(m_context, "uniform_value_float",					"GetUniform*"));
23183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueIntCase				(m_context, "uniform_value_int",					"GetUniform*"));
23193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueBooleanCase			(m_context, "uniform_value_boolean",				"GetUniform*"));
23203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueSamplerCase			(m_context, "uniform_value_sampler",				"GetUniform*"));
23213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueArrayCase				(m_context, "uniform_value_array",					"GetUniform*"));
23223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueMatrixCase				(m_context, "uniform_value_matrix",					"GetUniform*"));
23233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// precision format query
23253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_lowp_float",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_LOW_FLOAT));
23263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_mediump_float",		"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_MEDIUM_FLOAT));
23273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_highp_float",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_HIGH_FLOAT));
23283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_lowp_int",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_LOW_INT));
23293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_mediump_int",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_MEDIUM_INT));
23303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_highp_int",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_HIGH_INT));
23313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_lowp_float",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_LOW_FLOAT));
23323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_mediump_float",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_MEDIUM_FLOAT));
23333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_highp_float",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_HIGH_FLOAT));
23343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_lowp_int",			"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_LOW_INT));
23353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_mediump_int",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_MEDIUM_INT));
23363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_highp_int",			"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_HIGH_INT));
23373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
23383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
23403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
23413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
2342