13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.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 "es3fShaderStateQueryTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsStateQueryUtil.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fApiCase.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GLint and other GL types
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* commonTestVertSource		=	"#version 300 es\n"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = vec4(0.0);\n"
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* commonTestFragSource		=	"#version 300 es\n"
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"layout(location = 0) out mediump vec4 fragColor;\n"
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	fragColor = vec4(0.0);\n"
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* brokenShader				=	"#version 300 es\n"
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"broken, this should not compile!\n"
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"\n\0";
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// rounds x.1 to x+1
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
643c827367444ee418f129b2c238299f49d3264554Jarkko PoyryT roundGLfloatToNearestIntegerUp (GLfloat val)
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (T)(ceil(val));
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// rounds x.9 to x
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
713c827367444ee418f129b2c238299f49d3264554Jarkko PoyryT roundGLfloatToNearestIntegerDown (GLfloat val)
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (T)(floor(val));
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool checkIntEquals (tcu::TestContext& testCtx, GLint got, GLint expected)
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (got != expected)
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return false;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return true;
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkPointerEquals (tcu::TestContext& testCtx, const void* got, const void* expected)
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (got != expected)
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyShaderParam (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint shader, GLenum pname, GLenum reference)
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetShaderiv(shader, pname, &state);
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkIntEquals(testCtx, state, reference);
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool verifyProgramParam (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLenum pname, GLenum reference)
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetProgramiv(program, pname, &state);
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return state.verifyValidity(testCtx) && checkIntEquals(testCtx, state, reference);
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyActiveUniformParam  (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLuint index, GLenum pname, GLenum reference)
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetActiveUniformsiv(program, 1, &index, pname, &state);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkIntEquals(testCtx, state, reference);
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyActiveUniformBlockParam  (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLuint blockIndex, GLenum pname, GLenum reference)
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetActiveUniformBlockiv(program, blockIndex, pname, &state);
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkIntEquals(testCtx, state, reference);
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyCurrentVertexAttribf (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attribValue.verifyValidity(testCtx);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << "," << attribValue[3] << "]"
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndMessage;
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyCurrentVertexAttribIi (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLint x, GLint y, GLint z, GLint w)
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[4]> attribValue;
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribIiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attribValue.verifyValidity(testCtx);
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << "," << attribValue[3] << "]"
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndMessage;
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyCurrentVertexAttribIui (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLuint x, GLuint y, GLuint z, GLuint w)
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLuint[4]> attribValue;
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribIuiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attribValue.verifyValidity(testCtx);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << "," << attribValue[3] << "]"
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndMessage;
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyCurrentVertexAttribConversion (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[4]> attribValue;
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attribValue.verifyValidity(testCtx);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLint referenceAsGLintMin[] =
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(x),
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(y),
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(z),
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerDown<GLint>(w)
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLint referenceAsGLintMax[] =
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(x),
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(y),
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(z),
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		roundGLfloatToNearestIntegerUp<GLint>(w)
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (attribValue[0] < referenceAsGLintMin[0] || attribValue[0] > referenceAsGLintMax[0] ||
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		attribValue[1] < referenceAsGLintMin[1] || attribValue[1] > referenceAsGLintMax[1] ||
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		attribValue[2] < referenceAsGLintMin[2] || attribValue[2] > referenceAsGLintMax[2] ||
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		attribValue[3] < referenceAsGLintMin[3] || attribValue[3] > referenceAsGLintMax[3])
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "// ERROR: expected in range "
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[0] << " " << referenceAsGLintMax[0] << "], "
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[1] << " " << referenceAsGLintMax[1] << "], "
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[2] << " " << referenceAsGLintMax[2] << "], "
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "[" << referenceAsGLintMin[3] << " " << referenceAsGLintMax[3] << "]"
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "; got "
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[0] << ", "
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[1] << ", "
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[2] << ", "
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< attribValue[3] << " "
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "; Input="
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< x << "; "
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< y << "; "
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< z << "; "
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< w << " " << TestLog::EndMessage;
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid attribute value");
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyVertexAttrib (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLint index, GLenum pname, GLenum reference)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetVertexAttribIiv(index, pname, &state);
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state.verifyValidity(testCtx))
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkIntEquals(testCtx, state, reference);
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue1f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x)
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[1]> state;
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x)
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0]
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 verifyUniformValue2f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x, float y)
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[2]> 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	{
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1]
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue3f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x, float y, float z)
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[3]> state;
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z)
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2]
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 verifyUniformValue4f (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, float x, float y, float z, float w)
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[4]> state;
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(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		state[2] != z ||
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[3] != w)
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z << ", "
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< w
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2] << ", "
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[3]
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue1i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x)
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[1]> state;
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x)
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0]
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 verifyUniformValue2i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x, GLint y)
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[2]> 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	{
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1]
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue3i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x, GLint y, GLint z)
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[3]> state;
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z)
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2]
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue4i (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w)
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint[4]> state;
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformiv(program, location, state);
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z ||
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[3] != w)
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z << ", "
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< w
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2] << ", "
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[3]
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue1ui (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLuint x)
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLuint[1]> state;
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformuiv(program, location, state);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x)
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0]
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue2ui (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLuint x, GLuint y)
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLuint[2]> state;
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformuiv(program, location, state);
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y)
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1]
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue3ui (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLuint x, GLuint y, GLuint z)
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLuint[3]> state;
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformuiv(program, location, state);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z)
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2]
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValue4ui (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, GLuint x, GLuint y, GLuint z, GLuint w)
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLuint[4]> state;
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformuiv(program, location, state);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state[0] != x ||
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[1] != y ||
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[2] != z ||
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		state[3] != w)
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "// ERROR: expected ["
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< x << ", "
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< y << ", "
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< z << ", "
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< w
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]; got ["
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[0] << ", "
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[1] << ", "
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[2] << ", "
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< state[3]
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "]"
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::EndMessage;
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int Count>
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformValues (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, const GLfloat* values)
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[Count]> state;
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < Count; ++ndx)
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (values[ndx] != state[ndx])
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.getLog() << TestLog::Message << "// ERROR: at index " << ndx << " expected " << values[ndx] << "; got " << state[ndx] << TestLog::EndMessage;
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int N>
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid verifyUniformMatrixValues (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLuint program, GLint location, const GLfloat* values, bool transpose)
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat[N*N]> state;
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glGetUniformfv(program, location, state);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < N; ++y)
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < N; ++x)
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int refIndex = y*N + x;
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int stateIndex = transpose ? (x*N + y) : (y*N + x);
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (values[refIndex] != state[stateIndex])
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				testCtx.getLog() << TestLog::Message << "// ERROR: at index [" << y << "][" << x << "] expected " << values[refIndex] << "; got " << state[stateIndex] << TestLog::EndMessage;
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderTypeCase : public ApiCase
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderTypeCase (Context& context, const char* name, const char* description)
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum shaderTypes[] = {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER};
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx)
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint shader = glCreateShader(shaderTypes[ndx]);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_TYPE, shaderTypes[ndx]);
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shader);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderCompileStatusCase : public ApiCase
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderCompileStatusCase (Context& context, const char* name, const char* description)
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_FALSE);
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_FALSE);
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderInfoLogCase : public ApiCase
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderInfoLogCase (Context& context, const char* name, const char* description)
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// INFO_LOG_LENGTH is 0 by default and it includes null-terminator
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shader, GL_INFO_LOG_LENGTH, 0);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shader, 1, &brokenShader, DE_NULL);
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shader);
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the log length
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLint> logLength;
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!logLength.verifyValidity(m_testCtx))
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shader);
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (logLength == 0)
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shader);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check normal case
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'}; // non-zero initialization
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0; // written does not include null terminator
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderInfoLog(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check lengths are consistent
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (logLength <= DE_LENGTH_OF_ARRAY(buffer))
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (written != logLength-1)
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << logLength-1 << "; got " << written << TestLog::EndMessage;
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check null-terminator, either at end of buffer or at buffer[written]
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* terminator = &buffer[DE_LENGTH_OF_ARRAY(buffer) - 1];
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (logLength < DE_LENGTH_OF_ARRAY(buffer))
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				terminator = &buffer[written];
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (*terminator != '\0')
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)*terminator << TestLog::EndMessage;
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check with too small buffer
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'}; // non-zero initialization
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check string always ends with \0, even with small buffers
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderInfoLog(shader, 1, &written, buffer);
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length 0; got " << written << TestLog::EndMessage;
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (buffer[0] != '\0')
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)buffer[0] << TestLog::EndMessage;
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shader);
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderSourceCase : public ApiCase
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderSourceCase (Context& context, const char* name, const char* description)
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// SHADER_SOURCE_LENGTH does include 0-terminator
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_SOURCE_LENGTH, 0);
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the SHADER_SOURCE_LENGTH
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shader, 1, &brokenShader, DE_NULL);
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> sourceLength;
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sourceLength.verifyValidity(m_testCtx);
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = (GLint)std::string(brokenShader).length() + 1; // including the null terminator
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (sourceLength != referenceLength)
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength	<< "; got " << sourceLength << TestLog::EndMessage;
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the concat source SHADER_SOURCE_LENGTH
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* shaders[] = {brokenShader, brokenShader};
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shader, 2, shaders, DE_NULL);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> sourceLength;
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sourceLength.verifyValidity(m_testCtx);
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = 2 * (GLint)std::string(brokenShader).length() + 1; // including the null terminator
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (sourceLength != referenceLength)
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength << "; got " << sourceLength << TestLog::EndMessage;
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check the string length
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(DE_LENGTH_OF_ARRAY(buffer) > 2 * (int)std::string(brokenShader).length());
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0; // not inluding null-terminator
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderSource(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = 2 * (GLint)std::string(brokenShader).length();
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != referenceLength)
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length " << referenceLength << "; got " << written << TestLog::EndMessage;
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// check null pointer at
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (buffer[referenceLength] != '\0')
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at " << referenceLength << TestLog::EndMessage;
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "did not get a null terminator");
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check with small buffer
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetShaderSource(shader, 1, &written, buffer);
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written << TestLog::EndMessage;
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (buffer[0] != '\0')
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator; got=" << int(buffer[0]) << ", char=" << buffer[0] << TestLog::EndMessage;
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid terminator");
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shader);
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DeleteStatusCase : public ApiCase
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DeleteStatusCase (Context& context, const char* name, const char* description)
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderProg = glCreateProgram();
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(shaderProg, shaderVert);
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(shaderProg, shaderFrag);
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(shaderProg);
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, shaderProg, GL_LINK_STATUS, GL_TRUE);
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_FALSE);
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_FALSE);
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_FALSE);
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(shaderProg);
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(shaderProg);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_TRUE);
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_TRUE);
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_TRUE);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribInitialCase : public ApiCase
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribInitialCase (Context& context, const char* name, const char* description)
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// initial
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			attribValue.verifyValidity(m_testCtx);
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (attribValue[0] != 0.0f || attribValue[1] != 0.0f || attribValue[2] != 0.0f || attribValue[3] != 1.0f)
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "// ERROR: Expected [0, 0, 0, 1];"
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << "," << attribValue[3] << "]"
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< TestLog::EndMessage;
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribFloatCase : public ApiCase
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribFloatCase (Context& context, const char* name, const char* description)
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test write float/read float
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = rnd.getFloat(-64000, 64000);
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib4f(index, x, y, z, w);
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib3f(index, x, y, z);
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib2f(index, x, y);
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = 0.0f;
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib1f(index, x);
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribIntCase : public ApiCase
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribIntCase (Context& context, const char* name, const char* description)
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test write float/read float
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint x = rnd.getInt(-64000, 64000);
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint y = rnd.getInt(-64000, 64000);
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint z = rnd.getInt(-64000, 64000);
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint w = rnd.getInt(-64000, 64000);
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribI4i(index, x, y, z, w);
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribIi(m_testCtx, *this, index, x, y, z, w);
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribUintCase : public ApiCase
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribUintCase (Context& context, const char* name, const char* description)
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test write float/read float
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint x = rnd.getInt(0, 64000);
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint y = rnd.getInt(0, 64000);
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint z = rnd.getInt(0, 64000);
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint w = rnd.getInt(0, 64000);
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribI4ui(index, x, y, z, w);
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribIui(m_testCtx, *this, index, x, y, z, w);
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CurrentVertexAttribConversionCase : public ApiCase
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CurrentVertexAttribConversionCase (Context& context, const char* name, const char* description)
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int attribute_count = 16;
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test write float/read float
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = rnd.getFloat(-64000, 64000);
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib4f(index, x, y, z, w);
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = rnd.getFloat(-64000, 64000);
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib3f(index, x, y, z);
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = rnd.getFloat(-64000, 64000);
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib2f(index, x, y);
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int index = 0; index < attribute_count; ++index)
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat x = rnd.getFloat(-64000, 64000);
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat y = 0.0f;
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat z = 0.0f;
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat w = 1.0f;
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttrib1f(index, x);
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramInfoLogCase : public ApiCase
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1192c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	enum BuildErrorType
1193c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	{
1194c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		BUILDERROR_COMPILE = 0,
1195c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		BUILDERROR_LINK
1196c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	};
1197c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
1198c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	ProgramInfoLogCase (Context& context, const char* name, const char* description, BuildErrorType buildErrorType)
1199c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		: ApiCase			(context, name, description)
1200c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		, m_buildErrorType	(buildErrorType)
12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1208c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		enum
1209c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		{
1210c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			BUF_SIZE = 2048
1211c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		};
1212c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
1213c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		static const char* const linkErrorVtxSource = "#version 300 es\n"
1214c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "in highp vec4 a_pos;\n"
1215c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "uniform highp vec4 u_uniform;\n"
1216c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "void main ()\n"
1217c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "{\n"
1218c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "	gl_Position = a_pos + u_uniform;\n"
1219c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "}\n";
1220c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		static const char* const linkErrorFrgSource = "#version 300 es\n"
1221c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "in highp vec4 v_missingVar;\n"
1222c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "uniform highp int u_uniform;\n"
1223c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "layout(location = 0) out mediump vec4 fragColor;\n"
1224c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "void main ()\n"
1225c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "{\n"
1226c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "	fragColor = v_missingVar + vec4(float(u_uniform));\n"
1227c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry													  "}\n";
1228c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
1229c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		const char* vtxSource = (m_buildErrorType == BUILDERROR_COMPILE) ? (brokenShader) : (linkErrorVtxSource);
1230c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		const char* frgSource = (m_buildErrorType == BUILDERROR_COMPILE) ? (brokenShader) : (linkErrorFrgSource);
1231c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1235c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		glShaderSource(shaderVert, 1, &vtxSource, DE_NULL);
1236c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		glShaderSource(shaderFrag, 1, &frgSource, DE_NULL);
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1247c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		StateQueryMemoryWriteGuard<GLint> logLength;
1248c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
1249c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		logLength.verifyValidity(m_testCtx);
1250c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check INFO_LOG_LENGTH == GetProgramInfoLog len
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1253c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			const tcu::ScopedLogSection	section				(m_testCtx.getLog(), "QueryLarge", "Query to large buffer");
1254c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			char						buffer[BUF_SIZE]	= {'x'};
1255c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			GLint						written				= 0;
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1257c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			glGetProgramInfoLog(program, BUF_SIZE, &written, buffer);
1258c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
1259c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			if (logLength != 0 && written+1 != logLength) // INFO_LOG_LENGTH contains 0-terminator
1260c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			{
1261c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected INFO_LOG_LENGTH " << written+1 << "; got " << logLength << TestLog::EndMessage;
1262c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1263c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
1264c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			}
1265c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			else if (logLength != 0 && buffer[written] != '\0')
1266c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			{
1267c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at index " << written << TestLog::EndMessage;
1268c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1269c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "missing null terminator");
1270c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			}
1271c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		}
12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		// check query to just correct sized buffer
1274c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		if (BUF_SIZE > logLength)
1275c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry		{
1276c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			const tcu::ScopedLogSection	section				(m_testCtx.getLog(), "QueryAll", "Query all to exactly right sized buffer");
1277c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			char						buffer[BUF_SIZE]	= {'x'};
1278c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			GLint						written				= 0;
1279c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
1280c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			glGetProgramInfoLog(program, logLength, &written, buffer);
12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (logLength != 0 && written+1 != logLength) // INFO_LOG_LENGTH contains 0-terminator
12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected INFO_LOG_LENGTH " << written+1 << "; got " << logLength << TestLog::EndMessage;
12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1288c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			else if (logLength != 0 && buffer[written] != '\0')
1289c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			{
1290c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at index " << written << TestLog::EndMessage;
1291c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1292c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "missing null terminator");
1293c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			}
12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check GetProgramInfoLog works with too small buffer
12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1298c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			const tcu::ScopedLogSection	section				(m_testCtx.getLog(), "QueryNone", "Query none");
1299c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			char						buffer[BUF_SIZE]	= {'x'};
1300c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry			GLint						written				= 0;
13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetProgramInfoLog(program, 1, &written, buffer);
13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written << TestLog::EndMessage;
13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1317c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry
1318c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	const BuildErrorType m_buildErrorType;
13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramValidateStatusCase : public ApiCase
13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramValidateStatusCase (Context& context, const char* name, const char* description)
13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test validate ok
13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderVert);
13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderFrag);
13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint program = glCreateProgram();
13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderVert);
13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderFrag);
13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(program);
13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderVert,	GL_COMPILE_STATUS,	GL_TRUE);
13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderFrag,	GL_COMPILE_STATUS,	GL_TRUE);
13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam	(m_testCtx, *this, program,		GL_LINK_STATUS,		GL_TRUE);
13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glValidateProgram(program);
13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_TRUE);
13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderVert);
13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderFrag);
13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteProgram(program);
13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test with broken shader
13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderVert, 1, &commonTestVertSource,	DE_NULL);
13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glShaderSource(shaderFrag, 1, &brokenShader,			DE_NULL);
13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderVert);
13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderFrag);
13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint program = glCreateProgram();
13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderVert);
13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glAttachShader(program, shaderFrag);
13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(program);
13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderVert,	GL_COMPILE_STATUS,	GL_TRUE);
13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyShaderParam	(m_testCtx, *this, shaderFrag,	GL_COMPILE_STATUS,	GL_FALSE);
13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam	(m_testCtx, *this, program,		GL_LINK_STATUS,		GL_FALSE);
13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glValidateProgram(program);
13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_FALSE);
13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderVert);
13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteShader(shaderFrag);
13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteProgram(program);
13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramAttachedShadersCase : public ApiCase
13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramAttachedShadersCase (Context& context, const char* name, const char* description)
13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check ATTACHED_SHADERS
14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 0);
14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 1);
14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 2);
14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check GetAttachedShaders
14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaders[2] = {0, 0};
14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint count = 0;
14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetAttachedShaders(program, DE_LENGTH_OF_ARRAY(shaders), &count, shaders);
14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (count != 2)
14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 2; got " << count << TestLog::EndMessage;
14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// shaders are the attached shaders?
14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!((shaders[0] == shaderVert && shaders[1] == shaderFrag) ||
14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				  (shaders[0] == shaderFrag && shaders[1] == shaderVert)))
14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected {" << shaderVert << ", " << shaderFrag << "}; got {" << shaders[0] << ", " << shaders[1] << "}" << TestLog::EndMessage;
14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check GetAttachedShaders with too small buffer
14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint shaders[2] = {0, 0};
14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint count = 0;
14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetAttachedShaders(program, 0, &count, shaders);
14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (count != 0)
14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0; got " << count << TestLog::EndMessage;
14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			count = 0;
14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetAttachedShaders(program, 1, &count, shaders);
14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (count != 1)
14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 1; got " << count << TestLog::EndMessage;
14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramActiveUniformNameCase : public ApiCase
14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramActiveUniformNameCase (Context& context, const char* name, const char* description)
14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp float uniformNameWithLength23;\n"
14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec2 uniformVec2;\n"
14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat4 uniformMat4;\n"
15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0) + vec4(uniformNameWithLength23) + vec4(uniformVec2.x) + vec4(uniformMat4[2][3]);\n"
15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORMS, 3);
15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORM_MAX_LENGTH, (GLint)std::string("uniformNameWithLength23").length() + 1); // including a null terminator
15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* uniformNames[] =
15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniformNameWithLength23",
15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniformVec2",
15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniformMat4"
15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLuint[DE_LENGTH_OF_ARRAY(uniformNames)]> uniformIndices;
15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetUniformIndices(program, DE_LENGTH_OF_ARRAY(uniformNames), uniformNames, uniformIndices);
15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		uniformIndices.verifyValidity(m_testCtx);
15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check name lengths
15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformNames); ++ndx)
15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint uniformIndex = uniformIndices[ndx];
15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> uniformNameLen;
15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniformsiv(program, 1, &uniformIndex, GL_UNIFORM_NAME_LENGTH, &uniformNameLen);
15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			uniformNameLen.verifyValidity(m_testCtx);
15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = (GLint)std::string(uniformNames[ndx]).length() + 1;
15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (referenceLength != uniformNameLen) // uniformNameLen is with null terminator
15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << referenceLength << "got " << uniformNameLen << TestLog::EndMessage;
15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check names
15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformNames); ++ndx)
15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLuint uniformIndex = uniformIndices[ndx];
15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0; // null terminator not included
15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint size = 0;
15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum type = 0;
15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniform(program, uniformIndex, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = (GLint)std::string(uniformNames[ndx]).length();
15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (referenceLength != written)
15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << referenceLength << "got " << written << TestLog::EndMessage;
15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// and with too small buffer
15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			written = 0;
15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniform(program, uniformIndex, 1, &written, &size, &type, buffer);
15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (written != 0)
15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0 got " << written << TestLog::EndMessage;
15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramUniformCase : public ApiCase
16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramUniformCase (Context& context, const char* name, const char* description)
16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const struct UniformType
16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* declaration;
16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* postDeclaration;
16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* precision;
16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* layout;
16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* getter;
16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum		type;
16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint		size;
16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint		isRowMajor;
16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} uniformTypes[] =
16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "float",					"",			"highp",	"",						"uniformValue",							GL_FLOAT,							1, GL_FALSE },
16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "float[2]",				"",			"highp",	"",						"uniformValue[1]",						GL_FLOAT,							2, GL_FALSE },
16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "vec2",					"",			"highp",	"",						"uniformValue.x",						GL_FLOAT_VEC2,						1, GL_FALSE },
16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "vec3",					"",			"highp",	"",						"uniformValue.x",						GL_FLOAT_VEC3,						1, GL_FALSE },
16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "vec4",					"",			"highp",	"",						"uniformValue.x",						GL_FLOAT_VEC4,						1, GL_FALSE },
16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "int",					"",			"highp",	"",						"float(uniformValue)",					GL_INT,								1, GL_FALSE },
16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "ivec2",					"",			"highp",	"",						"float(uniformValue.x)",				GL_INT_VEC2,						1, GL_FALSE },
16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "ivec3",					"",			"highp",	"",						"float(uniformValue.x)",				GL_INT_VEC3,						1, GL_FALSE },
16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "ivec4",					"",			"highp",	"",						"float(uniformValue.x)",				GL_INT_VEC4,						1, GL_FALSE },
16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "uint",					"",			"highp",	"",						"float(uniformValue)",					GL_UNSIGNED_INT,					1, GL_FALSE },
16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "uvec2",					"",			"highp",	"",						"float(uniformValue.x)",				GL_UNSIGNED_INT_VEC2,				1, GL_FALSE },
16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "uvec3",					"",			"highp",	"",						"float(uniformValue.x)",				GL_UNSIGNED_INT_VEC3,				1, GL_FALSE },
16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "uvec4",					"",			"highp",	"",						"float(uniformValue.x)",				GL_UNSIGNED_INT_VEC4,				1, GL_FALSE },
16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bool",					"",			"",			"",						"float(uniformValue)",					GL_BOOL,							1, GL_FALSE },
16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bvec2",					"",			"",			"",						"float(uniformValue.x)",				GL_BOOL_VEC2,						1, GL_FALSE },
16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bvec3",					"",			"",			"",						"float(uniformValue.x)",				GL_BOOL_VEC3,						1, GL_FALSE },
16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "bvec4",					"",			"",			"",						"float(uniformValue.x)",				GL_BOOL_VEC4,						1, GL_FALSE },
16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat2",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT2,						1, GL_FALSE },
16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat3",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT3,						1, GL_FALSE },
16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat4",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT4,						1, GL_FALSE },
16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat2x3",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT2x3,					1, GL_FALSE },
16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat2x4",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT2x4,					1, GL_FALSE },
16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat3x2",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT3x2,					1, GL_FALSE },
16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat3x4",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT3x4,					1, GL_FALSE },
16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat4x2",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT4x2,					1, GL_FALSE },
16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "mat4x3",					"",			"highp",	"",						"float(uniformValue[0][0])",			GL_FLOAT_MAT4x3,					1, GL_FALSE },
16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "sampler2D",				"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_2D,						1, GL_FALSE },
16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "sampler3D",				"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_3D,						1, GL_FALSE },
16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "samplerCube",			"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_CUBE,					1, GL_FALSE },
16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "sampler2DShadow",		"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_2D_SHADOW,				1, GL_FALSE },
16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "sampler2DArray",			"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_2D_ARRAY,				1, GL_FALSE },
16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "sampler2DArrayShadow",	"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_2D_ARRAY_SHADOW,			1, GL_FALSE },
16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "samplerCubeShadow",		"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_SAMPLER_CUBE_SHADOW,				1, GL_FALSE },
16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "isampler2D",				"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_INT_SAMPLER_2D,					1, GL_FALSE },
16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "isampler3D",				"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_INT_SAMPLER_3D,					1, GL_FALSE },
16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "isamplerCube",			"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_INT_SAMPLER_CUBE,				1, GL_FALSE },
16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "isampler2DArray",		"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_INT_SAMPLER_2D_ARRAY,			1, GL_FALSE },
16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "usampler2D",				"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_UNSIGNED_INT_SAMPLER_2D,			1, GL_FALSE },
16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "usampler3D",				"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_UNSIGNED_INT_SAMPLER_3D,			1, GL_FALSE },
16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "usamplerCube",			"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_UNSIGNED_INT_SAMPLER_CUBE,		1, GL_FALSE },
16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "usampler2DArray",		"",			"highp",	"",						"float(textureSize(uniformValue,0).r)",	GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,	1, GL_FALSE },
16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* vertSource =
16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0);\n"
16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert	= glCreateShader(GL_VERTEX_SHADER);
16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag	= glCreateShader(GL_FRAGMENT_SHADER);
16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program		= glCreateProgram();
16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &vertSource, DE_NULL);
16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformTypes); ++ndx)
16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::ScopedLogSection(m_log, uniformTypes[ndx].declaration, std::string("Verify type of ") + uniformTypes[ndx].declaration + " variable" + uniformTypes[ndx].postDeclaration );
16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// gen fragment shader
16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			std::ostringstream frag;
16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "#version 300 es\n";
16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << uniformTypes[ndx].layout << "uniform " << uniformTypes[ndx].precision << " " << uniformTypes[ndx].declaration << " uniformValue" << uniformTypes[ndx].postDeclaration << ";\n";
16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "layout(location = 0) out mediump vec4 fragColor;\n";
16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "void main (void)\n";
16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "{\n";
16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "	fragColor = vec4(" << uniformTypes[ndx].getter << ");\n";
16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			frag << "}\n";
16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				std::string fragmentSource = frag.str();
17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const char* fragmentSourceCStr = fragmentSource.c_str();
17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glShaderSource(shaderFrag, 1, &fragmentSourceCStr, DE_NULL);
17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// compile & link
17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCompileShader(shaderFrag);
17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(program);
17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test
17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE))
17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const char* uniformNames[] = {"uniformValue"};
17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				StateQueryMemoryWriteGuard<GLuint> uniformIndex;
17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glGetUniformIndices(program, 1, uniformNames, &uniformIndex);
17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				uniformIndex.verifyValidity(m_testCtx);
17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				verifyActiveUniformParam(m_testCtx, *this, program, uniformIndex, GL_UNIFORM_TYPE,			uniformTypes[ndx].type);
17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				verifyActiveUniformParam(m_testCtx, *this, program, uniformIndex, GL_UNIFORM_SIZE,			uniformTypes[ndx].size);
17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				verifyActiveUniformParam(m_testCtx, *this, program, uniformIndex, GL_UNIFORM_IS_ROW_MAJOR,	uniformTypes[ndx].isRowMajor);
17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramActiveUniformBlocksCase : public ApiCase
17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramActiveUniformBlocksCase (Context& context, const char* name, const char* description)
17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform longlongUniformBlockName {highp vec2 vector2;} longlongUniformInstanceName;\n"
17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform shortUniformBlockName {highp vec2 vector2;highp vec4 vector4;} shortUniformInstanceName;\n"
17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = shortUniformInstanceName.vector4 + vec4(longlongUniformInstanceName.vector2.x) + vec4(shortUniformInstanceName.vector2.x);\n"
17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform longlongUniformBlockName {highp vec2 vector2;} longlongUniformInstanceName;\n"
17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(longlongUniformInstanceName.vector2.y);\n"
17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderVert,	GL_COMPILE_STATUS,	GL_TRUE);
17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam	(m_testCtx, *this, shaderFrag,	GL_COMPILE_STATUS,	GL_TRUE);
17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, program,		GL_LINK_STATUS,		GL_TRUE);
17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, program,		GL_ACTIVE_UNIFORM_BLOCKS, 2);
17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam	(m_testCtx, *this, program,		GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, (GLint)std::string("longlongUniformBlockName").length() + 1); // including a null terminator
17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint longlongUniformBlockIndex	= glGetUniformBlockIndex(program, "longlongUniformBlockName");
17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint shortUniformBlockIndex	= glGetUniformBlockIndex(program, "shortUniformBlockName");
17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* uniformNames[] =
17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"longlongUniformBlockName.vector2",
17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"shortUniformBlockName.vector2",
17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"shortUniformBlockName.vector4"
17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test UNIFORM_BLOCK_INDEX
17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(uniformNames) == 3);
17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLuint[DE_LENGTH_OF_ARRAY(uniformNames)]> uniformIndices;
17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLint[DE_LENGTH_OF_ARRAY(uniformNames)]> uniformsBlockIndices;
18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetUniformIndices(program, DE_LENGTH_OF_ARRAY(uniformNames), uniformNames, uniformIndices);
18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		uniformIndices.verifyValidity(m_testCtx);
18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetActiveUniformsiv(program, DE_LENGTH_OF_ARRAY(uniformNames), uniformIndices, GL_UNIFORM_BLOCK_INDEX, uniformsBlockIndices);
18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		uniformsBlockIndices.verifyValidity(m_testCtx);
18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (uniformsBlockIndices[0] != longlongUniformBlockIndex ||
18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			uniformsBlockIndices[1] != shortUniformBlockIndex ||
18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			uniformsBlockIndices[2] != shortUniformBlockIndex)
18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << TestLog::Message
18143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				<< "// ERROR: Expected ["	<< longlongUniformBlockIndex	<< ", " << shortUniformBlockIndex	<< ", " << shortUniformBlockIndex	<< "];"
18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				<<	"got ["					<< uniformsBlockIndices[0]		<< ", " << uniformsBlockIndices[1]	<< ", " << uniformsBlockIndices[2]	<< "]" << TestLog::EndMessage;
18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform block index");
18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test UNIFORM_BLOCK_NAME_LENGTH
18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,	GL_UNIFORM_BLOCK_NAME_LENGTH, (GLint)std::string("longlongUniformBlockName").length() + 1); // including null-terminator
18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,	GL_UNIFORM_BLOCK_NAME_LENGTH, (GLint)std::string("shortUniformBlockName").length() + 1); // including null-terminator
18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER & UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,	GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,	GL_TRUE);
18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,	GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER,	GL_TRUE);
18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,	GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,	GL_TRUE);
18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,	GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER,	GL_FALSE);
18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test UNIFORM_BLOCK_ACTIVE_UNIFORMS
18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,	GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS,	1);
18373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,	GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS,	2);
18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> longlongUniformBlockUniforms;
18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniformBlockiv(program, longlongUniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &longlongUniformBlockUniforms);
18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			longlongUniformBlockUniforms.verifyValidity(m_testCtx);
18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (longlongUniformBlockUniforms == 2)
18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				StateQueryMemoryWriteGuard<GLint[2]> longlongUniformBlockUniformIndices;
18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glGetActiveUniformBlockiv(program, longlongUniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, longlongUniformBlockUniformIndices);
18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				longlongUniformBlockUniformIndices.verifyValidity(m_testCtx);
18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if ((GLuint(longlongUniformBlockUniformIndices[0]) != uniformIndices[0] || GLuint(longlongUniformBlockUniformIndices[1]) != uniformIndices[1]) &&
18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					(GLuint(longlongUniformBlockUniformIndices[1]) != uniformIndices[0] || GLuint(longlongUniformBlockUniformIndices[0]) != uniformIndices[1]))
18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.getLog() << TestLog::Message
18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "// ERROR: Expected {"	<< uniformIndices[0]						<< ", " << uniformIndices[1] << "};"
18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<<	"got {"					<< longlongUniformBlockUniformIndices[0]	<< ", " << longlongUniformBlockUniformIndices[1] << "}" << TestLog::EndMessage;
18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform indices");
18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check block names
18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniformBlockName(program, longlongUniformBlockIndex, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkIntEquals(m_testCtx, written, (GLint)std::string("longlongUniformBlockName").length());
18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			written = 0;
18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniformBlockName(program, shortUniformBlockIndex, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
18773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkIntEquals(m_testCtx, written, (GLint)std::string("shortUniformBlockName").length());
18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// and one with too small buffer
18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			written = 0;
18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveUniformBlockName(program, longlongUniformBlockIndex, 1, &written, buffer);
18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkIntEquals(m_testCtx, written, 0);
18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramBinaryCase : public ApiCase
18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramBinaryCase (Context& context, const char* name, const char* description)
18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test PROGRAM_BINARY_RETRIEVABLE_HINT
19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_FALSE);
19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// test PROGRAM_BINARY_LENGTH does something
19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StateQueryMemoryWriteGuard<GLint> programLength;
19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &programLength);
19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		programLength.verifyValidity(m_testCtx);
19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
19433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
19453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TransformFeedbackCase : public ApiCase
19473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
19493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TransformFeedbackCase (Context& context, const char* name, const char* description)
19503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
19513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
19553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
19573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* transformFeedbackTestVertSource =
19593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
19603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec4 tfOutput2withLongName;\n"
19613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
19623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
19633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0);\n"
19643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	tfOutput2withLongName = vec4(0.0);\n"
19653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
19663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* transformFeedbackTestFragSource =
19673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
19683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp vec4 fragColor;\n"
19693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
19703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
19713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
19723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
19733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
19753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
19763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderProg = glCreateProgram();
19773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, shaderProg, GL_TRANSFORM_FEEDBACK_BUFFER_MODE, GL_INTERLEAVED_ATTRIBS);
19793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
19813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
19823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
19843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
19853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
19873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(shaderProg, shaderVert);
19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(shaderProg, shaderFrag);
19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check TRANSFORM_FEEDBACK_BUFFER_MODE
19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* transform_feedback_outputs[] = {"gl_Position", "tfOutput2withLongName"};
19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* longest_output = transform_feedback_outputs[1];
19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum bufferModes[] = {GL_SEPARATE_ATTRIBS, GL_INTERLEAVED_ATTRIBS};
19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(bufferModes); ++ndx)
19993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTransformFeedbackVaryings(shaderProg, DE_LENGTH_OF_ARRAY(transform_feedback_outputs), transform_feedback_outputs, bufferModes[ndx]);
20013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glLinkProgram(shaderProg);
20023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
20033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam(m_testCtx, *this, shaderProg, GL_LINK_STATUS, GL_TRUE);
20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyProgramParam(m_testCtx, *this, shaderProg, GL_TRANSFORM_FEEDBACK_BUFFER_MODE, bufferModes[ndx]);
20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// TRANSFORM_FEEDBACK_VARYINGS
20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, shaderProg, GL_TRANSFORM_FEEDBACK_VARYINGS, 2);
20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
20123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> maxOutputLen;
20143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetProgramiv(shaderProg, GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, &maxOutputLen);
20153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			maxOutputLen.verifyValidity(m_testCtx);
20173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint referenceLength = (GLint)std::string(longest_output).length() + 1;
20193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkIntEquals(m_testCtx, maxOutputLen, referenceLength);
20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check varyings
20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLint> varyings;
20253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetProgramiv(shaderProg, GL_TRANSFORM_FEEDBACK_VARYINGS, &varyings);
20263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!varyings.isUndefined())
20283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int index = 0; index < varyings; ++index)
20293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
20303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					char buffer[2048] = {'x'};
20313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					GLint written = 0;
20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					GLint size = 0;
20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					GLenum type = 0;
20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glGetTransformFeedbackVarying(shaderProg, index, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
20363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (written < DE_LENGTH_OF_ARRAY(buffer) && buffer[written] != '\0')
20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{
20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator" << TestLog::EndMessage;
20403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
20413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid string terminator");
20423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					}
20433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					// check with too small buffer
20453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					written = 0;
20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glGetTransformFeedbackVarying(shaderProg, index, 1, &written, &size, &type, buffer);
20473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (written != 0)
20483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{
20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0; got " << written << TestLog::EndMessage;
20503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid write length");
20523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					}
20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
20543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
20583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(shaderProg);
20603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
20613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
20623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
20633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ActiveAttributesCase : public ApiCase
20653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
20663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ActiveAttributesCase (Context& context, const char* name, const char* description)
20683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
20693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
20713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
20733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
20753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
20773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
20783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec2 longInputAttributeName;\n"
20793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec2 shortName;\n"
20803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
20813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
20823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = longInputAttributeName.yxxy + shortName.xyxy;\n"
20833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
20843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
20853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
20863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
20873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
20883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
20893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
20903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n\0";
20913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
20933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
20943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
20963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
20973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
20993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
21003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
21013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
21033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
21043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
21053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
21063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
21073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTES, 2);
21093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, (GLint)std::string("longInputAttributeName").length() + 1); // does include null-terminator
21103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check names
21123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int attributeNdx = 0; attributeNdx < 2; ++attributeNdx)
21133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
21153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
21173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint size = 0;
21183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum type = 0;
21193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveAttrib(program, attributeNdx, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
21203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
21213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (deStringBeginsWith(buffer, "longInputAttributeName"))
21233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
21243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkIntEquals(m_testCtx, written, (GLint)std::string("longInputAttributeName").length()); // does NOT include null-terminator
21253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
21263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else if (deStringBeginsWith(buffer, "shortName"))
21273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
21283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkIntEquals(m_testCtx, written, (GLint)std::string("shortName").length()); // does NOT include null-terminator
21293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
21303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
21313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
21323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.getLog() << TestLog::Message << "// ERROR: Got unexpected attribute name." << TestLog::EndMessage;
21333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
21343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got unexpected name");
21353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
21363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
21373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// and with too short buffer
21393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			char buffer[2048] = {'x'};
21413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint written = 0;
21433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLint size = 0;
21443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLenum type = 0;
21453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetActiveAttrib(program, 0, 1, &written, &size, &type, buffer);
21473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
21483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkIntEquals(m_testCtx, written, 0);
21493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
21503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
21523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
21533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
21543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
21553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
21573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct PointerData
21593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint		size;
21613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum		type;
21623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint		stride;
21633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLboolean	normalized;
21643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const void*	pointer;
21653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
21663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeSizeCase : public ApiCase
21683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
21703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeSizeCase (Context& context, const char* name, const char* description)
21713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
21723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
21763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLfloat vertexData[4] = {0.0f}; // never accessed
21783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const PointerData pointers[] =
21803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// size test
21823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 4, GL_FLOAT,		0,	GL_FALSE, vertexData },
21833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 3, GL_FLOAT,		0,	GL_FALSE, vertexData },
21843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 2, GL_FLOAT,		0,	GL_FALSE, vertexData },
21853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_FLOAT,		0,	GL_FALSE, vertexData },
21863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 4, GL_INT,		0,	GL_FALSE, vertexData },
21873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 3, GL_INT,		0,	GL_FALSE, vertexData },
21883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 2, GL_INT,		0,	GL_FALSE, vertexData },
21893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 1, GL_INT,		0,	GL_FALSE, vertexData },
21903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
21913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
21933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
21953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
21973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
21983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
21993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				expectError(GL_NO_ERROR);
22003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[ndx].size);
22023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
22033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
22063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
22083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint buf		= 0;
22103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2]	= {0};
22113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
22133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &buf);
22143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, buf);
22153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// initial
22183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
22193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, 4);
22203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
22233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, pointers[0].size, pointers[0].type, pointers[0].normalized, pointers[0].stride, DE_NULL);
22243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
22273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
22283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, pointers[1].size, pointers[1].type, pointers[1].normalized, pointers[1].stride, DE_NULL);
22293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
22323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[1].size);
22333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
22363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
22373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[0].size);
22383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
22413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &buf);
22423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
22433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
22463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeTypeCase : public ApiCase
22483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
22503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeTypeCase (Context& context, const char* name, const char* description)
22513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
22523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
22563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
22583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
22603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat vertexData[4] = {0.0f}; // never accessed
22623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test VertexAttribPointer
22643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
22653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const PointerData pointers[] =
22663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
22673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,								0,	GL_FALSE, vertexData	},
22683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,								0,	GL_FALSE, vertexData	},
22693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,								0,	GL_FALSE, vertexData	},
22703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FIXED,								0,	GL_FALSE, vertexData	},
22713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FLOAT,								0,	GL_FALSE, vertexData	},
22723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_HALF_FLOAT,							0,	GL_FALSE, vertexData	},
22733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE, vertexData	},
22743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE, vertexData	},
22753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,						0,	GL_FALSE, vertexData	},
22763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_INT_2_10_10_10_REV,					0,	GL_FALSE, vertexData	},
22773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_INT_2_10_10_10_REV,		0,	GL_FALSE, vertexData	},
22783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
22793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
22813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
22823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
22833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
22843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx].type);
22863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
22873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
22883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test glVertexAttribIPointer
22903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
22913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const PointerData pointers[] =
22923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
22933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,								0,	GL_FALSE, vertexData	},
22943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,								0,	GL_FALSE, vertexData	},
22953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,								0,	GL_FALSE, vertexData	},
22963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE, vertexData	},
22973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE, vertexData	},
22983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,						0,	GL_FALSE, vertexData	},
22993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
23003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
23023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
23033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride, pointers[ndx].pointer);
23043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
23053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx].type);
23073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
23083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
23093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
23103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
23123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
23133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
23143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint buf		= 0;
23163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2]	= {0};
23173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
23193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &buf);
23203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, buf);
23213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// initial
23243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
23253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_FLOAT);
23263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
23293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, DE_NULL);
23303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
23333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
23343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_SHORT, GL_FALSE, 0, DE_NULL);
23353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
23383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_SHORT);
23393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
23423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
23433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_FLOAT);
23443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
23473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &buf);
23483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
23493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
23503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
23513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
23523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeStrideCase : public ApiCase
23543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
23553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
23563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeStrideCase (Context& context, const char* name, const char* description)
23573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
23583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
23593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
23603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
23623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
23633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
23643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
23653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
23663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat vertexData[4] = {0.0f}; // never accessed
23683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			struct StridePointerData
23703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
23713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				GLint		size;
23723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				GLenum		type;
23733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				GLint		stride;
23743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const void*	pointer;
23753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			};
23763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test VertexAttribPointer
23783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
23793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const StridePointerData pointers[] =
23803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
23813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FLOAT,			0,	vertexData },
23823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FLOAT,			1,	vertexData },
23833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FLOAT,			4,	vertexData },
23843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_HALF_FLOAT,		0,	vertexData },
23853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_HALF_FLOAT,		1,	vertexData },
23863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_HALF_FLOAT,		4,	vertexData },
23873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FIXED,			0,	vertexData },
23883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FIXED,			1,	vertexData },
23893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FIXED,			4,	vertexData },
23903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
23913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
23933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
23943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, GL_FALSE, pointers[ndx].stride, pointers[ndx].pointer);
23953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
23963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx].stride);
23983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
23993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
24003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test glVertexAttribIPointer
24023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
24033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const StridePointerData pointers[] =
24043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
24053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,				0,	vertexData },
24063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,				1,	vertexData },
24073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,				4,	vertexData },
24083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_BYTE,		0,	vertexData },
24093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_BYTE,		1,	vertexData },
24103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_BYTE,		4,	vertexData },
24113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 2, GL_SHORT,				0,	vertexData },
24123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 2, GL_SHORT,				1,	vertexData },
24133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 2, GL_SHORT,				4,	vertexData },
24143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
24153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
24173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
24183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride, pointers[ndx].pointer);
24193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
24203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx].stride);
24223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
24233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
24243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
24253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
24273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
24283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
24293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint buf		= 0;
24313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2]	= {0};
24323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
24343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &buf);
24353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, buf);
24363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// initial
24393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
24403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 0);
24413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
24443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 4, DE_NULL);
24453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
24483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
24493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_SHORT, GL_FALSE, 8, DE_NULL);
24503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
24533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 8);
24543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
24573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
24583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 4);
24593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
24623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &buf);
24633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
24643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
24653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
24663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
24673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeNormalizedCase : public ApiCase
24693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
24703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
24713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeNormalizedCase (Context& context, const char* name, const char* description)
24723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
24733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
24743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
24753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
24773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
24783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
24793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
24803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
24813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat vertexData[4] = {0.0f}; // never accessed
24833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test VertexAttribPointer
24853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
24863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const PointerData pointers[] =
24873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
24883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,								0,	GL_FALSE,	vertexData	},
24893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,								0,	GL_FALSE,	vertexData	},
24903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,								0,	GL_FALSE,	vertexData	},
24913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE,	vertexData	},
24923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE,	vertexData	},
24933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,						0,	GL_FALSE,	vertexData	},
24943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_INT_2_10_10_10_REV,					0,	GL_FALSE,	vertexData	},
24953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_INT_2_10_10_10_REV,		0,	GL_FALSE,	vertexData	},
24963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,								0,	GL_TRUE,	vertexData	},
24973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,								0,	GL_TRUE,	vertexData	},
24983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,								0,	GL_TRUE,	vertexData	},
24993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,						0,	GL_TRUE,	vertexData	},
25003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,						0,	GL_TRUE,	vertexData	},
25013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,						0,	GL_TRUE,	vertexData	},
25023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_INT_2_10_10_10_REV,					0,	GL_TRUE,	vertexData	},
25033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_INT_2_10_10_10_REV,		0,	GL_TRUE,	vertexData	},
25043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
25053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
25073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
25083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
25093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
25103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, pointers[ndx].normalized);
25123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
25133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
25143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test glVertexAttribIPointer
25163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
25173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const PointerData pointers[] =
25183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
25193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,				0,	GL_FALSE, vertexData	},
25203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,				0,	GL_FALSE, vertexData	},
25213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,				0,	GL_FALSE, vertexData	},
25223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,		0,	GL_FALSE, vertexData	},
25233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,		0,	GL_FALSE, vertexData	},
25243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,		0,	GL_FALSE, vertexData	},
25253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
25263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
25283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
25293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride, pointers[ndx].pointer);
25303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
25313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_FALSE);
25333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
25343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
25353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
25363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
25383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
25393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
25403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint buf		= 0;
25423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2]	= {0};
25433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
25453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &buf);
25463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, buf);
25473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// initial
25503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
25513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_FALSE);
25523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
25553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_INT, GL_TRUE, 0, DE_NULL);
25563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
25593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
25603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_INT, GL_FALSE, 0, DE_NULL);
25613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
25643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_FALSE);
25653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
25683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
25693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_TRUE);
25703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
25733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &buf);
25743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
25753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
25763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
25773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
25783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeIntegerCase : public ApiCase
25803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
25813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
25823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeIntegerCase (Context& context, const char* name, const char* description)
25833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
25843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
25853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
25863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
25883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
25893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
25903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
25913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
25923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat vertexData[4] = {0.0f}; // never accessed
25943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test VertexAttribPointer
25963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
25973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const PointerData pointers[] =
25983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
25993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,								0,	GL_FALSE, vertexData	},
26003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,								0,	GL_FALSE, vertexData	},
26013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,								0,	GL_FALSE, vertexData	},
26023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FIXED,								0,	GL_FALSE, vertexData	},
26033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_FLOAT,								0,	GL_FALSE, vertexData	},
26043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_HALF_FLOAT,							0,	GL_FALSE, vertexData	},
26053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE, vertexData	},
26063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE, vertexData	},
26073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,						0,	GL_FALSE, vertexData	},
26083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_INT_2_10_10_10_REV,					0,	GL_FALSE, vertexData	},
26093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 4, GL_UNSIGNED_INT_2_10_10_10_REV,		0,	GL_FALSE, vertexData	},
26103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
26113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
26133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
26143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
26153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
26163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_FALSE);
26183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
26193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
26203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// test glVertexAttribIPointer
26223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
26233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const PointerData pointers[] =
26243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
26253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_BYTE,								0,	GL_FALSE, vertexData	},
26263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_SHORT,								0,	GL_FALSE, vertexData	},
26273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_INT,								0,	GL_FALSE, vertexData	},
26283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_BYTE,						0,	GL_FALSE, vertexData	},
26293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_SHORT,						0,	GL_FALSE, vertexData	},
26303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{ 1, GL_UNSIGNED_INT,						0,	GL_FALSE, vertexData	},
26313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				};
26323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
26343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
26353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride, pointers[ndx].pointer);
26363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					expectError(GL_NO_ERROR);
26373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_TRUE);
26393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
26403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
26413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
26423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
26443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
26453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
26463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint buf		= 0;
26483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2]	= {0};
26493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
26513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &buf);
26523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, buf);
26533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// initial
26563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
26573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_FALSE);
26583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
26613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribIPointer(0, 1, GL_INT, 0, DE_NULL);
26623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
26653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
26663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, DE_NULL);
26673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
26703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_FALSE);
26713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
26743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
26753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_TRUE);
26763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
26793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &buf);
26803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
26813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
26823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
26833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
26843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeEnabledCase : public ApiCase
26863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
26873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
26883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeEnabledCase (Context& context, const char* name, const char* description)
26893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
26903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
26913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
26923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
26943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
26953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// VERTEX_ATTRIB_ARRAY_ENABLED
26963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
26983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
26993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
27003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
27023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glEnableVertexAttribArray(0);
27033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE);
27043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDisableVertexAttribArray(0);
27053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
27063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
27073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
27093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
27103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
27113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2] = {0};
27133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
27153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
27183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
27193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glEnableVertexAttribArray(0);
27203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
27233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
27243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDisableVertexAttribArray(0);
27253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
27283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
27293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
27323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
27333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE);
27343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
27373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
27393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
27403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
27413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeDivisorCase : public ApiCase
27433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
27453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeDivisorCase (Context& context, const char* name, const char* description)
27463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
27473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
27483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
27493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
27513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
27523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
27533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
27543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
27553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR,	0);
27573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribDivisor(0, 1);
27583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR,	1);
27593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribDivisor(0, 5);
27603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR,	5);
27613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
27623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
27643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
27653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
27663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2] = {0};
27683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
27703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
27733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
27743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribDivisor(0, 1);
27753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
27783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
27793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribDivisor(0, 5);
27803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
27833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 5);
27843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
27873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
27883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 1);
27893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
27923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
27933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
27943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
27953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
27963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributeBufferBindingCase : public ApiCase
27983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
28003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributeBufferBindingCase (Context& context, const char* name, const char* description)
28013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
28023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
28033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
28043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
28063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
28073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
28083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
28093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
28103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// initial
28123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, 0);
28133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint bufferID;
28153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &bufferID);
28163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, bufferID);
28173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
28203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufferID);
28233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &bufferID);
28253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
28273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
28293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
28303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
28313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2] = {0};
28333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint bufs[2] = {0};
28343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(2, bufs);
28363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
28393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
28423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
28433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, bufs[0]);
28443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
28453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
28483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
28493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, bufs[1]);
28503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
28513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
28543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufs[1]);
28553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
28583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
28593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufs[0]);
28603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
28633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(2, bufs);
28643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
28653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
28663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
28673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
28683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexAttributePointerCase : public ApiCase
28703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
28713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
28723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexAttributePointerCase (Context& context, const char* name, const char* description)
28733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
28743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
28753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
28763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
28783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
28793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with default VAO
28803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
28813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
28823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			StateQueryMemoryWriteGuard<GLvoid*> initialState;
28843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &initialState);
28853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			initialState.verifyValidity(m_testCtx);
28863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			checkPointerEquals(m_testCtx, initialState, 0);
28873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat vertexData[4] = {0.0f}; // never accessed
28893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const PointerData pointers[] =
28903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
28913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_BYTE,				0,	GL_FALSE, &vertexData[2] },
28923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_SHORT,				0,	GL_FALSE, &vertexData[1] },
28933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_INT,				0,	GL_FALSE, &vertexData[2] },
28943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FIXED,				0,	GL_FALSE, &vertexData[2] },
28953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FIXED,				0,	GL_FALSE, &vertexData[1] },
28963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FLOAT,				0,	GL_FALSE, &vertexData[0] },
28973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FLOAT,				0,	GL_FALSE, &vertexData[3] },
28983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_FLOAT,				0,	GL_FALSE, &vertexData[2] },
28993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 1, GL_HALF_FLOAT,			0,	GL_FALSE, &vertexData[0] },
29003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 4, GL_HALF_FLOAT,			0,	GL_FALSE, &vertexData[1] },
29013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{ 4, GL_HALF_FLOAT,			0,	GL_FALSE, &vertexData[2] },
29023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			};
29033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
29053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
29063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized, pointers[ndx].stride, pointers[ndx].pointer);
29073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				expectError(GL_NO_ERROR);
29083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				StateQueryMemoryWriteGuard<GLvoid*> state;
29103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
29113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				state.verifyValidity(m_testCtx);
29123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkPointerEquals(m_testCtx, state, pointers[ndx].pointer);
29133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
29143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
29153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Test with multiple VAOs
29173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
29183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
29193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint vaos[2] = {0};
29213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint bufs[2] = {0};
29223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(2, bufs);
29243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenVertexArrays(2, vaos);
29273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 0 to some value
29303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
29313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, bufs[0]);
29323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, ((deUint8*)DE_NULL) + 8);
29333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// set vao 1 to some other value
29363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[1]);
29373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_ARRAY_BUFFER, bufs[1]);
29383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, ((deUint8*)DE_NULL) + 4);
29393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 1 state
29423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
29433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				StateQueryMemoryWriteGuard<GLvoid*> state;
29443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
29453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				state.verifyValidity(m_testCtx);
29463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkPointerEquals(m_testCtx, state, ((deUint8*)DE_NULL) + 4);
29473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
29483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// verify vao 0 state
29513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindVertexArray(vaos[0]);
29523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
29533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				StateQueryMemoryWriteGuard<GLvoid*> state;
29543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
29553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				state.verifyValidity(m_testCtx);
29563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				checkPointerEquals(m_testCtx, state, ((deUint8*)DE_NULL) + 8);
29573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
29583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteVertexArrays(2, vaos);
29613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(2, bufs);
29623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
29633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
29643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
29653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
29663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueFloatCase : public ApiCase
29683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
29693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
29703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueFloatCase (Context& context, const char* name, const char* description)
29713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
29723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
29733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
29743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
29763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
29773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
29783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
29793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp float floatUniform;\n"
29803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec2 float2Uniform;\n"
29813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec3 float3Uniform;\n"
29823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec4 float4Uniform;\n"
29833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
29843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
29853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(floatUniform + float2Uniform.x + float3Uniform.x + float4Uniform.x);\n"
29863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
29873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
29883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
29893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
29903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
29913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
29923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
29933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
29943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
29963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
29973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
29993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
30003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
30023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
30033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
30043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
30063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
30073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
30083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
30093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
30103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
30113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
30133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"floatUniform");
30153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1f(location, 1.0f);
30163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program, location, 1.0f);
30173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"float2Uniform");
30193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2f(location, 1.0f, 2.0f);
30203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program, location, 1.0f, 2.0f);
30213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"float3Uniform");
30233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3f(location, 1.0f, 2.0f, 3.0f);
30243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program, location, 1.0f, 2.0f, 3.0f);
30253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"float4Uniform");
30273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4f(location, 1.0f, 2.0f, 3.0f, 4.0f);
30283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program, location, 1.0f, 2.0f, 3.0f, 4.0f);
30293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
30313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
30323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
30333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
30343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
30353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
30363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
30373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueIntCase : public ApiCase
30393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
30403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
30413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueIntCase (Context& context, const char* name, const char* description)
30423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
30433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
30443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
30453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
30473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
30483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
30493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
30503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp int intUniform;\n"
30513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp ivec2 int2Uniform;\n"
30523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp ivec3 int3Uniform;\n"
30533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp ivec4 int4Uniform;\n"
30543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
30553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
30563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(float(intUniform + int2Uniform.x + int3Uniform.x + int4Uniform.x));\n"
30573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
30583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
30593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
30603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
30613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
30623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
30633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
30643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
30653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
30673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
30683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
30703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
30713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
30733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
30743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
30753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
30773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
30783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
30793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
30803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
30813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
30823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
30843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"intUniform");
30863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1i(location, 1);
30873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program, location, 1);
30883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"int2Uniform");
30903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2i(location, 1, 2);
30913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2i(m_testCtx, *this, program, location, 1, 2);
30923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"int3Uniform");
30943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3i(location, 1, 2, 3);
30953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3i(m_testCtx, *this, program, location, 1, 2, 3);
30963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"int4Uniform");
30983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4i(location, 1, 2, 3, 4);
30993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4i(m_testCtx, *this, program, location, 1, 2, 3, 4);
31003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
31023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
31033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
31043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
31053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
31063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
31083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueUintCase : public ApiCase
31103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
31113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
31123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueUintCase (Context& context, const char* name, const char* description)
31133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
31143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
31183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
31203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
31213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp uint uintUniform;\n"
31223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp uvec2 uint2Uniform;\n"
31233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp uvec3 uint3Uniform;\n"
31243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp uvec4 uint4Uniform;\n"
31253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
31263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
31273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(float(uintUniform + uint2Uniform.x + uint3Uniform.x + uint4Uniform.x));\n"
31283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
31293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
31303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
31313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
31323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
31333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
31343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
31353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
31363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
31383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
31393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
31413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
31423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
31443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
31453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
31463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
31483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
31493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
31503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
31513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
31523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
31533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
31553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"uintUniform");
31573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1ui(location, 1);
31583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1ui(m_testCtx, *this, program, location, 1);
31593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"uint2Uniform");
31613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2ui(location, 1, 2);
31623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2ui(m_testCtx, *this, program, location, 1, 2);
31633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"uint3Uniform");
31653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3ui(location, 1, 2, 3);
31663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3ui(m_testCtx, *this, program, location, 1, 2, 3);
31673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"uint4Uniform");
31693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4ui(location, 1, 2, 3, 4);
31703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4ui(m_testCtx, *this, program, location, 1, 2, 3, 4);
31713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
31733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
31743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
31753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
31763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
31773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
31793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueBooleanCase : public ApiCase
31823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
31833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
31843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueBooleanCase (Context& context, const char* name, const char* description)
31853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
31863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
31903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
31923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
31933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bool boolUniform;\n"
31943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bvec2 bool2Uniform;\n"
31953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bvec3 bool3Uniform;\n"
31963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform bvec4 bool4Uniform;\n"
31973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
31983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
31993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(float(boolUniform) + float(bool2Uniform.x) + float(bool3Uniform.x) + float(bool4Uniform.x));\n"
32003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
32013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
32023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
32033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
32043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
32053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
32063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
32073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
32083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
32103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
32113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
32133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
32143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
32163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
32173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
32183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
32203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
32213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
32223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
32233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
32243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
32253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
32273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// int conversion
32293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"boolUniform");
32313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1i(location, 1);
32323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program, location, 1);
32333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"bool2Uniform");
32353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2i(location, 1, 2);
32363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2i(m_testCtx, *this, program, location, 1, 1);
32373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"bool3Uniform");
32393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3i(location, 0, 1, 2);
32403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3i(m_testCtx, *this, program, location, 0, 1, 1);
32413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"bool4Uniform");
32433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4i(location, 1, 0, 1, -1);
32443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4i(m_testCtx, *this, program, location, 1, 0, 1, 1);
32453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// float conversion
32473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"boolUniform");
32493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1f(location, 1.0f);
32503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program, location, 1);
32513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"bool2Uniform");
32533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2f(location, 1.0f, 0.1f);
32543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2i(m_testCtx, *this, program, location, 1, 1);
32553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"bool3Uniform");
32573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3f(location, 0.0f, 0.1f, -0.1f);
32583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3i(m_testCtx, *this, program, location, 0, 1, 1);
32593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"bool4Uniform");
32613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4f(location, 1.0f, 0.0f, 0.1f, -0.9f);
32623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4i(m_testCtx, *this, program, location, 1, 0, 1, 1);
32633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
32653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
32663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
32673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
32683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
32693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
32703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
32713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueSamplerCase : public ApiCase
32733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
32753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueSamplerCase (Context& context, const char* name, const char* description)
32763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
32773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
32783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
32793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
32813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
32823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
32833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
32843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
32853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
32863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(0.0);\n"
32873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
32883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
32893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
32903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp sampler2D uniformSampler;\n"
32913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
32923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
32933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
32943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(textureSize(uniformSampler, 0).x);\n"
32953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
32963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
32983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
32993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
33013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
33023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
33043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
33053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
33083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
33093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
33103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
33113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
33123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
33153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"uniformSampler");
33173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1i(location, 1);
33183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1i(m_testCtx, *this, program, location, 1);
33193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
33213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
33223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
33233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
33243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
33263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
33273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueArrayCase : public ApiCase
33293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
33313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueArrayCase (Context& context, const char* name, const char* description)
33323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
33333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
33343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
33353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
33373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
33383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
33393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
33403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp float arrayUniform[5];"
33413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec2 array2Uniform[5];"
33423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec3 array3Uniform[5];"
33433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp vec4 array4Uniform[5];"
33443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
33453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
33463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = \n"
33473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(arrayUniform[0]		+ arrayUniform[1]		+ arrayUniform[2]		+ arrayUniform[3]		+ arrayUniform[4])\n"
33483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(array2Uniform[0].x	+ array2Uniform[1].x	+ array2Uniform[2].x	+ array2Uniform[3].x	+ array2Uniform[4].x)\n"
33493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(array3Uniform[0].x	+ array3Uniform[1].x	+ array3Uniform[2].x	+ array3Uniform[3].x	+ array3Uniform[4].x)\n"
33503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"		+ vec4(array4Uniform[0].x	+ array4Uniform[1].x	+ array4Uniform[2].x	+ array4Uniform[3].x	+ array4Uniform[4].x);\n"
33513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
33523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
33533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
33543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
33553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
33563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
33573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
33583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
33593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
33613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
33623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
33643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
33653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
33673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
33683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
33713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
33723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
33733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
33743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
33753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
33783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float uniformValue[5 * 4] =
33803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
33813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-1.0f,	0.1f,	4.0f,	800.0f,
33823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			13.0f,	55.0f,	12.0f,	91.0f,
33833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-55.1f,	1.1f,	98.0f,	19.0f,
33843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			41.0f,	65.0f,	4.0f,	12.2f,
33853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			95.0f,	77.0f,	32.0f,	48.0f
33863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
33873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"arrayUniform");
33893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform1fv(location, 5, uniformValue);
33903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program,"arrayUniform[0]"), uniformValue[0]);
33933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program,"arrayUniform[1]"), uniformValue[1]);
33943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program,"arrayUniform[2]"), uniformValue[2]);
33953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program,"arrayUniform[3]"), uniformValue[3]);
33963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program,"arrayUniform[4]"), uniformValue[4]);
33973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
33983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"array2Uniform");
34003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform2fv(location, 5, uniformValue);
34013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program,"array2Uniform[0]"), uniformValue[2 * 0], uniformValue[(2 * 0) + 1]);
34043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program,"array2Uniform[1]"), uniformValue[2 * 1], uniformValue[(2 * 1) + 1]);
34053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program,"array2Uniform[2]"), uniformValue[2 * 2], uniformValue[(2 * 2) + 1]);
34063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program,"array2Uniform[3]"), uniformValue[2 * 3], uniformValue[(2 * 3) + 1]);
34073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program,"array2Uniform[4]"), uniformValue[2 * 4], uniformValue[(2 * 4) + 1]);
34083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"array3Uniform");
34113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform3fv(location, 5, uniformValue);
34123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program,"array3Uniform[0]"), uniformValue[3 * 0], uniformValue[(3 * 0) + 1], uniformValue[(3 * 0) + 2]);
34153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program,"array3Uniform[1]"), uniformValue[3 * 1], uniformValue[(3 * 1) + 1], uniformValue[(3 * 1) + 2]);
34163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program,"array3Uniform[2]"), uniformValue[3 * 2], uniformValue[(3 * 2) + 1], uniformValue[(3 * 2) + 2]);
34173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program,"array3Uniform[3]"), uniformValue[3 * 3], uniformValue[(3 * 3) + 1], uniformValue[(3 * 3) + 2]);
34183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program,"array3Uniform[4]"), uniformValue[3 * 4], uniformValue[(3 * 4) + 1], uniformValue[(3 * 4) + 2]);
34193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"array4Uniform");
34223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniform4fv(location, 5, uniformValue);
34233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program,"array4Uniform[0]"), uniformValue[4 * 0], uniformValue[(4 * 0) + 1], uniformValue[(4 * 0) + 2], uniformValue[(4 * 0) + 3]);
34263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program,"array4Uniform[1]"), uniformValue[4 * 1], uniformValue[(4 * 1) + 1], uniformValue[(4 * 1) + 2], uniformValue[(4 * 1) + 3]);
34273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program,"array4Uniform[2]"), uniformValue[4 * 2], uniformValue[(4 * 2) + 1], uniformValue[(4 * 2) + 2], uniformValue[(4 * 2) + 3]);
34283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program,"array4Uniform[3]"), uniformValue[4 * 3], uniformValue[(4 * 3) + 1], uniformValue[(4 * 3) + 2], uniformValue[(4 * 3) + 3]);
34293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program,"array4Uniform[4]"), uniformValue[4 * 4], uniformValue[(4 * 4) + 1], uniformValue[(4 * 4) + 2], uniformValue[(4 * 4) + 3]);
34303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
34333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
34343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
34353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
34363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
34383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
34393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UniformValueMatrixCase : public ApiCase
34413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
34423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
34433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformValueMatrixCase (Context& context, const char* name, const char* description)
34443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase(context, name, description)
34453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
34473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
34493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testVertSource =
34513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
34523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat2 mat2Uniform;"
34533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat3 mat3Uniform;"
34543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp mat4 mat4Uniform;"
34553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
34563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
34573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = vec4(mat2Uniform[0][0] + mat3Uniform[0][0] + mat4Uniform[0][0]);\n"
34583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
34593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const char* testFragSource =
34603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
34613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out mediump vec4 fragColor;"
34623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
34633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
34643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	fragColor = vec4(0.0);\n"
34653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
34663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
34683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
34693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
34713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
34723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderVert);
34743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glCompileShader(shaderFrag);
34753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint program = glCreateProgram();
34783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderVert);
34793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glAttachShader(program, shaderFrag);
34803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glLinkProgram(program);
34813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(program);
34823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
34833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLint location;
34853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float matrixValues[4 * 4] =
34873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
34883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-1.0f,	0.1f,	4.0f,	800.0f,
34893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			13.0f,	55.0f,	12.0f,	91.0f,
34903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-55.1f,	1.1f,	98.0f,	19.0f,
34913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			41.0f,	65.0f,	4.0f,	12.2f,
34923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
34933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// the values of the matrix are returned in column major order but they can be given in either order
34953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"mat2Uniform");
34973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix2fv(location, 1, GL_FALSE, matrixValues);
34983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<2>(m_testCtx, *this, program, location, matrixValues, false);
34993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix2fv(location, 1, GL_TRUE, matrixValues);
35003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<2>(m_testCtx, *this, program, location, matrixValues, true);
35013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"mat3Uniform");
35033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix3fv(location, 1, GL_FALSE, matrixValues);
35043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<3>(m_testCtx, *this, program, location, matrixValues, false);
35053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix3fv(location, 1, GL_TRUE, matrixValues);
35063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<3>(m_testCtx, *this, program, location, matrixValues, true);
35073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		location = glGetUniformLocation(program,"mat4Uniform");
35093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix4fv(location, 1, GL_FALSE, matrixValues);
35103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<4>(m_testCtx, *this, program, location, matrixValues, false);
35113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUniformMatrix4fv(location, 1, GL_TRUE, matrixValues);
35123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		verifyUniformMatrixValues<4>(m_testCtx, *this, program, location, matrixValues, true);
35133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glUseProgram(0);
35153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderVert);
35163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteShader(shaderFrag);
35173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteProgram(program);
35183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
35193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
35203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
35213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PrecisionFormatCase : public ApiCase
35233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
35243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
35253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct RequiredFormat
35263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
35273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int negativeRange;
35283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int positiveRange;
35293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int precision;
35303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
35313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PrecisionFormatCase (Context& context, const char* name, const char* description, glw::GLenum shaderType, glw::GLenum precisionType)
35333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase			(context, name, description)
35343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_shaderType		(shaderType)
35353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_precisionType	(precisionType)
35363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
35373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
35383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
35403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
35413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
35423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const RequiredFormat											expected = getRequiredFormat();
35433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool															error = false;
35443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLboolean>	shaderCompiler;
35453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint[2]>	range;
35463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint>		precision;
35473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// query values
35493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGetShaderPrecisionFormat(m_shaderType, m_precisionType, range, &precision);
35503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
35513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!range.verifyValidity(m_testCtx))
35533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
35543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!precision.verifyValidity(m_testCtx))
35553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
35563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log
35583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< tcu::TestLog::Message
35593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "range[0] = " << range[0] << "\n"
35603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "range[1] = " << range[1] << "\n"
35613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "precision = " << precision
35623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< tcu::TestLog::EndMessage;
35633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// verify values
35653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_precisionType == GL_HIGH_FLOAT)
35673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
35683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// highp float must be IEEE 754 single
35693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (range[0] != expected.negativeRange ||
35713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				range[1] != expected.positiveRange ||
35723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				precision != expected.precision)
35733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
35743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_log
35753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< tcu::TestLog::Message
35763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "// ERROR: Invalid precision format, expected:\n"
35773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "\trange[0] = " << expected.negativeRange << "\n"
35783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "\trange[1] = " << expected.positiveRange << "\n"
35793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< "\tprecision = " << expected.precision
35803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< tcu::TestLog::EndMessage;
35813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				error = true;
35823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
35833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
35843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
35853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
35863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (range[0] < expected.negativeRange)
35873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
35883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_log << tcu::TestLog::Message << "// ERROR: Invalid range[0], expected greater or equal to " << expected.negativeRange << tcu::TestLog::EndMessage;
35893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				error = true;
35903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
35913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (range[1] < expected.positiveRange)
35933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
35943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_log << tcu::TestLog::Message << "// ERROR: Invalid range[1], expected greater or equal to " << expected.positiveRange << tcu::TestLog::EndMessage;
35953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				error = true;
35963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
35973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (precision < expected.precision)
35993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
36003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_log << tcu::TestLog::Message << "// ERROR: Invalid precision, expected greater or equal to " << expected.precision << tcu::TestLog::EndMessage;
36013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				error = true;
36023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
36033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
36043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (error)
36063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid precision/range");
36073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
36083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RequiredFormat getRequiredFormat (void) const
36103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
36113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Precisions for different types.
36123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const RequiredFormat requirements[] =
36133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{   0,   0,  8 }, //!< lowp float
36153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{  13,  13, 10 }, //!< mediump float
36163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ 127, 127, 23 }, //!< highp float
36173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{   8,   7,  0 }, //!< lowp int
36183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{  15,  14,  0 }, //!< mediump int
36193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{  31,  30,  0 }, //!< highp int
36203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
36213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int ndx = (int)m_precisionType - (int)GL_LOW_FLOAT;
36223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(ndx >= 0);
36243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(ndx < DE_LENGTH_OF_ARRAY(requirements));
36253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return requirements[ndx];
36263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
36273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::GLenum m_shaderType;
36293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::GLenum m_precisionType;
36303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
36313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
36333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36353c827367444ee418f129b2c238299f49d3264554Jarkko PoyryShaderStateQueryTests::ShaderStateQueryTests (Context& context)
36363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "shader", "Shader State Query tests")
36373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
36383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
36393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ShaderStateQueryTests::init (void)
36413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
36423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// shader
36433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderTypeCase						(m_context, "shader_type",							"SHADER_TYPE"));
36443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderCompileStatusCase			(m_context, "shader_compile_status",				"COMPILE_STATUS"));
36453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderInfoLogCase					(m_context, "shader_info_log_length",				"INFO_LOG_LENGTH"));
36463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ShaderSourceCase					(m_context, "shader_source_length",					"SHADER_SOURCE_LENGTH"));
36473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// shader and program
36493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new DeleteStatusCase					(m_context, "delete_status",						"DELETE_STATUS"));
36503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// vertex-attrib
36523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribInitialCase		(m_context, "current_vertex_attrib_initial",		"CURRENT_VERTEX_ATTRIB"));
36533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribFloatCase		(m_context, "current_vertex_attrib_float",			"CURRENT_VERTEX_ATTRIB"));
36543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribIntCase			(m_context, "current_vertex_attrib_int",			"CURRENT_VERTEX_ATTRIB"));
36553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribUintCase		(m_context, "current_vertex_attrib_uint",			"CURRENT_VERTEX_ATTRIB"));
36563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new CurrentVertexAttribConversionCase	(m_context, "current_vertex_attrib_float_to_int",	"CURRENT_VERTEX_ATTRIB"));
36573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// program
3659c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	addChild(new ProgramInfoLogCase					(m_context, "program_info_log_length",				"INFO_LOG_LENGTH",	ProgramInfoLogCase::BUILDERROR_COMPILE));
3660c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry	addChild(new ProgramInfoLogCase					(m_context, "program_info_log_length_link_error",	"INFO_LOG_LENGTH",	ProgramInfoLogCase::BUILDERROR_LINK));
36613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramValidateStatusCase			(m_context, "program_validate_status",				"VALIDATE_STATUS"));
36623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramAttachedShadersCase			(m_context, "program_attached_shaders",				"ATTACHED_SHADERS"));
36633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramActiveUniformNameCase		(m_context, "program_active_uniform_name",			"ACTIVE_UNIFORMS and ACTIVE_UNIFORM_MAX_LENGTH"));
36653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramUniformCase					(m_context, "program_active_uniform_types",			"UNIFORM_TYPE, UNIFORM_SIZE, and UNIFORM_IS_ROW_MAJOR"));
36663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramActiveUniformBlocksCase		(m_context, "program_active_uniform_blocks",		"ACTIVE_UNIFORM_BLOCK_x"));
36673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ProgramBinaryCase					(m_context, "program_binary",						"PROGRAM_BINARY_LENGTH and PROGRAM_BINARY_RETRIEVABLE_HINT"));
36683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// transform feedback
36703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new TransformFeedbackCase				(m_context, "transform_feedback",					"TRANSFORM_FEEDBACK_BUFFER_MODE, TRANSFORM_FEEDBACK_VARYINGS, TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH"));
36713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// attribute related
36733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new ActiveAttributesCase				(m_context, "active_attributes",					"ACTIVE_ATTRIBUTES and ACTIVE_ATTRIBUTE_MAX_LENGTH"));
36743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeSizeCase			(m_context, "vertex_attrib_size",					"VERTEX_ATTRIB_ARRAY_SIZE"));
36753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeTypeCase			(m_context, "vertex_attrib_type",					"VERTEX_ATTRIB_ARRAY_TYPE"));
36763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeStrideCase			(m_context, "vertex_attrib_stride",					"VERTEX_ATTRIB_ARRAY_STRIDE"));
36773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeNormalizedCase		(m_context, "vertex_attrib_normalized",				"VERTEX_ATTRIB_ARRAY_NORMALIZED"));
36783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeIntegerCase			(m_context, "vertex_attrib_integer",				"VERTEX_ATTRIB_ARRAY_INTEGER"));
36793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeEnabledCase			(m_context, "vertex_attrib_array_enabled",			"VERTEX_ATTRIB_ARRAY_ENABLED"));
36803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeDivisorCase			(m_context, "vertex_attrib_array_divisor",			"VERTEX_ATTRIB_ARRAY_DIVISOR"));
36813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributeBufferBindingCase	(m_context, "vertex_attrib_array_buffer_binding",	"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"));
36823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new VertexAttributePointerCase			(m_context, "vertex_attrib_pointerv",				"GetVertexAttribPointerv"));
36833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// uniform values
36853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueFloatCase				(m_context, "uniform_value_float",					"GetUniform*"));
36863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueIntCase				(m_context, "uniform_value_int",					"GetUniform*"));
36873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueUintCase				(m_context, "uniform_value_uint",					"GetUniform*"));
36883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueBooleanCase			(m_context, "uniform_value_boolean",				"GetUniform*"));
36893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueSamplerCase			(m_context, "uniform_value_sampler",				"GetUniform*"));
36903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueArrayCase				(m_context, "uniform_value_array",					"GetUniform*"));
36913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new UniformValueMatrixCase				(m_context, "uniform_value_matrix",					"GetUniform*"));
36923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// precision format query
36943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_lowp_float",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_LOW_FLOAT));
36953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_mediump_float",		"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_MEDIUM_FLOAT));
36963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_highp_float",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_HIGH_FLOAT));
36973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_lowp_int",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_LOW_INT));
36983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_mediump_int",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_MEDIUM_INT));
36993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_vertex_highp_int",			"GetShaderPrecisionFormat",		GL_VERTEX_SHADER,	GL_HIGH_INT));
37003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_lowp_float",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_LOW_FLOAT));
37013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_mediump_float",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_MEDIUM_FLOAT));
37023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_highp_float",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_HIGH_FLOAT));
37033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_lowp_int",			"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_LOW_INT));
37043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_mediump_int",		"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_MEDIUM_INT));
37053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new PrecisionFormatCase				(m_context, "precision_fragment_highp_int",			"GetShaderPrecisionFormat",		GL_FRAGMENT_SHADER,	GL_HIGH_INT));
37063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
37073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
37093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
37103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
3711