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 Uniform block tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fUniformBlockTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsUniformBlockCase.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsRandomUniformBlockCase.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::UniformBlockCase;
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::RandomUniformBlockCase;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::ub;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void createRandomCaseGroup (tcu::TestCaseGroup* parentGroup, Context& context, const char* groupName, const char* description, UniformBlockCase::BufferMode bufferMode, deUint32 features, int numCases, deUint32 baseSeed)
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup* group = new tcu::TestCaseGroup(context.getTestContext(), groupName, description);
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	parentGroup->addChild(group);
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	baseSeed += (deUint32)context.getTestContext().getCommandLine().getBaseSeed();
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < numCases; ndx++)
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group->addChild(new RandomUniformBlockCase(context.getTestContext(), context.getRenderContext(), glu::GLSL_VERSION_300_ES,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												   de::toString(ndx).c_str(), "", bufferMode, features, (deUint32)ndx+baseSeed));
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockBasicTypeCase : public UniformBlockCase
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockBasicTypeCase (Context& context, const char* name, const char* description, const VarType& type, deUint32 layoutFlags, int numInstances)
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, BUFFERMODE_PER_BLOCK)
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& block = m_interface.allocBlock("Block");
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("var", type, 0));
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setFlags(layoutFlags);
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numInstances > 0)
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setArraySize(numInstances);
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setInstanceName("block");
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void createBlockBasicTypeCases (tcu::TestCaseGroup* group, Context& context, const char* name, const VarType& type, deUint32 layoutFlags, int numInstances = 0)
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	group->addChild(new BlockBasicTypeCase(context, (string(name) + "_vertex").c_str(),		"", type, layoutFlags|DECLARE_VERTEX,					numInstances));
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	group->addChild(new BlockBasicTypeCase(context, (string(name) + "_fragment").c_str(),	"", type, layoutFlags|DECLARE_FRAGMENT,					numInstances));
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!(layoutFlags & LAYOUT_PACKED))
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group->addChild(new BlockBasicTypeCase(context, (string(name) + "_both").c_str(),		"", type, layoutFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	numInstances));
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockSingleStructCase : public UniformBlockCase
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockSingleStructCase (Context& context, const char* name, const char* description, deUint32 layoutFlags, BufferMode bufferMode, int numInstances)
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase	(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, bufferMode)
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_layoutFlags		(layoutFlags)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_numInstances	(numInstances)
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void init (void)
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeS = m_interface.allocStruct("S");
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("a", VarType(glu::TYPE_INT_VEC3, PRECISION_HIGH), UNUSED_BOTH); // First member is unused.
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("b", VarType(VarType(glu::TYPE_FLOAT_MAT3, PRECISION_MEDIUM), 4));
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("c", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_HIGH));
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& block = m_interface.allocBlock("Block");
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("s", VarType(&typeS), 0));
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setFlags(m_layoutFlags);
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_numInstances > 0)
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setInstanceName("block");
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setArraySize(m_numInstances);
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_layoutFlags;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_numInstances;
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockSingleStructArrayCase : public UniformBlockCase
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockSingleStructArrayCase (Context& context, const char* name, const char* description, deUint32 layoutFlags, BufferMode bufferMode, int numInstances)
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase	(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, bufferMode)
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_layoutFlags		(layoutFlags)
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_numInstances	(numInstances)
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void init (void)
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeS = m_interface.allocStruct("S");
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("a", VarType(glu::TYPE_INT_VEC3, PRECISION_HIGH), UNUSED_BOTH);
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("b", VarType(VarType(glu::TYPE_FLOAT_MAT3, PRECISION_MEDIUM), 4));
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("c", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_HIGH));
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& block = m_interface.allocBlock("Block");
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("u", VarType(glu::TYPE_UINT, PRECISION_LOW)));
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("s", VarType(VarType(&typeS), 3)));
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("v", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_MEDIUM)));
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setFlags(m_layoutFlags);
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_numInstances > 0)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setInstanceName("block");
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setArraySize(m_numInstances);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_layoutFlags;
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_numInstances;
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockSingleNestedStructCase : public UniformBlockCase
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockSingleNestedStructCase (Context& context, const char* name, const char* description, deUint32 layoutFlags, BufferMode bufferMode, int numInstances)
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase	(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, bufferMode)
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_layoutFlags		(layoutFlags)
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_numInstances	(numInstances)
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void init (void)
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeS = m_interface.allocStruct("S");
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("a", VarType(glu::TYPE_INT_VEC3, PRECISION_HIGH));
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("b", VarType(VarType(glu::TYPE_FLOAT_MAT3, PRECISION_MEDIUM), 4));
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("c", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_HIGH), UNUSED_BOTH);
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeT = m_interface.allocStruct("T");
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("a", VarType(glu::TYPE_FLOAT_MAT3, PRECISION_MEDIUM));
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("b", VarType(&typeS));
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& block = m_interface.allocBlock("Block");
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("s", VarType(&typeS), 0));
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("v", VarType(glu::TYPE_FLOAT_VEC2, PRECISION_LOW), UNUSED_BOTH));
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("t", VarType(&typeT), 0));
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("u", VarType(glu::TYPE_UINT, PRECISION_HIGH), 0));
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setFlags(m_layoutFlags);
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_numInstances > 0)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setInstanceName("block");
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setArraySize(m_numInstances);
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_layoutFlags;
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_numInstances;
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockSingleNestedStructArrayCase : public UniformBlockCase
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockSingleNestedStructArrayCase (Context& context, const char* name, const char* description, deUint32 layoutFlags, BufferMode bufferMode, int numInstances)
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase	(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, bufferMode)
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_layoutFlags		(layoutFlags)
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_numInstances	(numInstances)
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void init (void)
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeS = m_interface.allocStruct("S");
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("a", VarType(glu::TYPE_INT_VEC3, PRECISION_HIGH));
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("b", VarType(VarType(glu::TYPE_INT_VEC2, PRECISION_MEDIUM), 4));
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("c", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_HIGH), UNUSED_BOTH);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeT = m_interface.allocStruct("T");
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("a", VarType(glu::TYPE_FLOAT_MAT3, PRECISION_MEDIUM));
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("b", VarType(VarType(&typeS), 3));
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& block = m_interface.allocBlock("Block");
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("s", VarType(&typeS), 0));
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("v", VarType(glu::TYPE_FLOAT_VEC2, PRECISION_LOW), UNUSED_BOTH));
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("t", VarType(VarType(&typeT), 2), 0));
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.addUniform(Uniform("u", VarType(glu::TYPE_UINT, PRECISION_HIGH), 0));
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setFlags(m_layoutFlags);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_numInstances > 0)
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setInstanceName("block");
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			block.setArraySize(m_numInstances);
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_layoutFlags;
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_numInstances;
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockMultiBasicTypesCase : public UniformBlockCase
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockMultiBasicTypesCase (Context& context, const char* name, const char* description, deUint32 flagsA, deUint32 flagsB, BufferMode bufferMode, int numInstances)
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase	(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, bufferMode)
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_flagsA			(flagsA)
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_flagsB			(flagsB)
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_numInstances	(numInstances)
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void init (void)
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& blockA = m_interface.allocBlock("BlockA");
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.addUniform(Uniform("a", VarType(glu::TYPE_FLOAT, PRECISION_HIGH)));
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.addUniform(Uniform("b", VarType(glu::TYPE_UINT_VEC3, PRECISION_LOW), UNUSED_BOTH));
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.addUniform(Uniform("c", VarType(glu::TYPE_FLOAT_MAT2, PRECISION_MEDIUM)));
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.setInstanceName("blockA");
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.setFlags(m_flagsA);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& blockB = m_interface.allocBlock("BlockB");
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("a", VarType(glu::TYPE_FLOAT_MAT3, PRECISION_MEDIUM)));
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("b", VarType(glu::TYPE_INT_VEC2, PRECISION_LOW)));
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("c", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_HIGH), UNUSED_BOTH));
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("d", VarType(glu::TYPE_BOOL, 0)));
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.setInstanceName("blockB");
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.setFlags(m_flagsB);
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_numInstances > 0)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			blockA.setArraySize(m_numInstances);
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			blockB.setArraySize(m_numInstances);
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_flagsA;
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_flagsB;
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_numInstances;
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BlockMultiNestedStructCase : public UniformBlockCase
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BlockMultiNestedStructCase (Context& context, const char* name, const char* description, deUint32 flagsA, deUint32 flagsB, BufferMode bufferMode, int numInstances)
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: UniformBlockCase	(context.getTestContext(), context.getRenderContext(), name, description, glu::GLSL_VERSION_300_ES, bufferMode)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_flagsA			(flagsA)
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_flagsB			(flagsB)
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_numInstances	(numInstances)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void init (void)
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeS = m_interface.allocStruct("S");
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("a", VarType(glu::TYPE_FLOAT_MAT3, PRECISION_LOW));
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("b", VarType(VarType(glu::TYPE_INT_VEC2, PRECISION_MEDIUM), 4));
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeS.addMember("c", VarType(glu::TYPE_FLOAT_VEC4, PRECISION_HIGH));
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& typeT = m_interface.allocStruct("T");
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("a", VarType(glu::TYPE_UINT, PRECISION_MEDIUM), UNUSED_BOTH);
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("b", VarType(&typeS));
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeT.addMember("c", VarType(glu::TYPE_BOOL_VEC4, 0));
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& blockA = m_interface.allocBlock("BlockA");
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.addUniform(Uniform("a", VarType(glu::TYPE_FLOAT, PRECISION_HIGH)));
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.addUniform(Uniform("b", VarType(&typeS)));
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.addUniform(Uniform("c", VarType(glu::TYPE_UINT_VEC3, PRECISION_LOW), UNUSED_BOTH));
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.setInstanceName("blockA");
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockA.setFlags(m_flagsA);
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlock& blockB = m_interface.allocBlock("BlockB");
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("a", VarType(glu::TYPE_FLOAT_MAT2, PRECISION_MEDIUM)));
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("b", VarType(&typeT)));
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("c", VarType(glu::TYPE_BOOL_VEC4, 0), UNUSED_BOTH));
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.addUniform(Uniform("d", VarType(glu::TYPE_BOOL, 0)));
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.setInstanceName("blockB");
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blockB.setFlags(m_flagsB);
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_numInstances > 0)
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			blockA.setArraySize(m_numInstances);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			blockB.setArraySize(m_numInstances);
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_flagsA;
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_flagsB;
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_numInstances;
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3243c827367444ee418f129b2c238299f49d3264554Jarkko PoyryUniformBlockTests::UniformBlockTests (Context& context)
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "ubo", "Uniform Block tests")
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3293c827367444ee418f129b2c238299f49d3264554Jarkko PoyryUniformBlockTests::~UniformBlockTests (void)
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UniformBlockTests::init (void)
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const glu::DataType basicTypes[] =
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT,
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_VEC2,
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_VEC3,
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_VEC4,
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_INT,
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_INT_VEC2,
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_INT_VEC3,
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_INT_VEC4,
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_UINT,
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_UINT_VEC2,
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_UINT_VEC3,
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_UINT_VEC4,
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_BOOL,
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_BOOL_VEC2,
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_BOOL_VEC3,
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_BOOL_VEC4,
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT2,
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT3,
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT4,
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT2X3,
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT2X4,
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT3X2,
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT3X4,
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT4X2,
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TYPE_FLOAT_MAT4X3
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		flags;
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} precisionFlags[] =
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "lowp",		PRECISION_LOW		},
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "mediump",	PRECISION_MEDIUM	},
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "highp",		PRECISION_HIGH		}
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		flags;
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} layoutFlags[] =
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "shared",		LAYOUT_SHARED	},
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "packed",		LAYOUT_PACKED	},
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "std140",		LAYOUT_STD140	}
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		flags;
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} matrixFlags[] =
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "row_major",		LAYOUT_ROW_MAJOR	},
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "column_major",	LAYOUT_COLUMN_MAJOR }
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*							name;
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UniformBlockCase::BufferMode		mode;
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} bufferModes[] =
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "per_block_buffer",	UniformBlockCase::BUFFERMODE_PER_BLOCK },
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "single_buffer",		UniformBlockCase::BUFFERMODE_SINGLE	}
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.single_basic_type
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* singleBasicTypeGroup = new tcu::TestCaseGroup(m_testCtx, "single_basic_type", "Single basic variable in single buffer");
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(singleBasicTypeGroup);
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* layoutGroup = new tcu::TestCaseGroup(m_testCtx, layoutFlags[layoutFlagNdx].name, "");
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			singleBasicTypeGroup->addChild(layoutGroup);
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int basicTypeNdx = 0; basicTypeNdx < DE_LENGTH_OF_ARRAY(basicTypes); basicTypeNdx++)
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glu::DataType	type		= basicTypes[basicTypeNdx];
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const char*		typeName	= glu::getDataTypeName(type);
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (glu::isDataTypeBoolOrBVec(type))
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					createBlockBasicTypeCases(layoutGroup, m_context, typeName, VarType(type, 0), layoutFlags[layoutFlagNdx].flags);
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisionFlags); precNdx++)
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						createBlockBasicTypeCases(layoutGroup, m_context, (string(precisionFlags[precNdx].name) + "_" + typeName).c_str(),
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  VarType(type, precisionFlags[precNdx].flags), layoutFlags[layoutFlagNdx].flags);
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (glu::isDataTypeMatrix(type))
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					for (int matFlagNdx = 0; matFlagNdx < DE_LENGTH_OF_ARRAY(matrixFlags); matFlagNdx++)
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					{
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisionFlags); precNdx++)
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							createBlockBasicTypeCases(layoutGroup, m_context, (string(matrixFlags[matFlagNdx].name) + "_" + precisionFlags[precNdx].name + "_" + typeName).c_str(),
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry													  VarType(type, precisionFlags[precNdx].flags), layoutFlags[layoutFlagNdx].flags|matrixFlags[matFlagNdx].flags);
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					}
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.single_basic_array
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* singleBasicArrayGroup = new tcu::TestCaseGroup(m_testCtx, "single_basic_array", "Single basic array variable in single buffer");
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(singleBasicArrayGroup);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* layoutGroup = new tcu::TestCaseGroup(m_testCtx, layoutFlags[layoutFlagNdx].name, "");
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			singleBasicArrayGroup->addChild(layoutGroup);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int basicTypeNdx = 0; basicTypeNdx < DE_LENGTH_OF_ARRAY(basicTypes); basicTypeNdx++)
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glu::DataType	type		= basicTypes[basicTypeNdx];
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const char*		typeName	= glu::getDataTypeName(type);
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		arraySize	= 3;
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				createBlockBasicTypeCases(layoutGroup, m_context, typeName,
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  VarType(VarType(type, glu::isDataTypeBoolOrBVec(type) ? 0 : PRECISION_HIGH), arraySize),
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  layoutFlags[layoutFlagNdx].flags);
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (glu::isDataTypeMatrix(type))
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					for (int matFlagNdx = 0; matFlagNdx < DE_LENGTH_OF_ARRAY(matrixFlags); matFlagNdx++)
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						createBlockBasicTypeCases(layoutGroup, m_context, (string(matrixFlags[matFlagNdx].name) + "_" + typeName).c_str(),
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  VarType(VarType(type, PRECISION_HIGH), arraySize),
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  layoutFlags[layoutFlagNdx].flags|matrixFlags[matFlagNdx].flags);
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.single_struct
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* singleStructGroup = new tcu::TestCaseGroup(m_testCtx, "single_struct", "Single struct in uniform block");
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(singleStructGroup);
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int modeNdx = 0; modeNdx < DE_LENGTH_OF_ARRAY(bufferModes); modeNdx++)
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* modeGroup = new tcu::TestCaseGroup(m_testCtx, bufferModes[modeNdx].name, "");
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			singleStructGroup->addChild(modeGroup);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int isArray = 0; isArray < 2; isArray++)
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::string	baseName	= layoutFlags[layoutFlagNdx].name;
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					deUint32	baseFlags	= layoutFlags[layoutFlagNdx].flags;
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (bufferModes[modeNdx].mode == UniformBlockCase::BUFFERMODE_SINGLE && isArray == 0)
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						continue; // Doesn't make sense to add this variant.
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (isArray)
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						baseName += "_instance_array";
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleStructCase(m_context, (baseName + "_vertex").c_str(),	"", baseFlags|DECLARE_VERTEX,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleStructCase(m_context, (baseName + "_fragment").c_str(),	"", baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (!(baseFlags & LAYOUT_PACKED))
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						modeGroup->addChild(new BlockSingleStructCase(m_context, (baseName + "_both").c_str(),		"", baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	bufferModes[modeNdx].mode, isArray ? 3 : 0));
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.single_struct_array
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* singleStructArrayGroup = new tcu::TestCaseGroup(m_testCtx, "single_struct_array", "Struct array in one uniform block");
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(singleStructArrayGroup);
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int modeNdx = 0; modeNdx < DE_LENGTH_OF_ARRAY(bufferModes); modeNdx++)
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* modeGroup = new tcu::TestCaseGroup(m_testCtx, bufferModes[modeNdx].name, "");
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			singleStructArrayGroup->addChild(modeGroup);
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int isArray = 0; isArray < 2; isArray++)
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::string	baseName	= layoutFlags[layoutFlagNdx].name;
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					deUint32	baseFlags	= layoutFlags[layoutFlagNdx].flags;
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (bufferModes[modeNdx].mode == UniformBlockCase::BUFFERMODE_SINGLE && isArray == 0)
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						continue; // Doesn't make sense to add this variant.
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (isArray)
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						baseName += "_instance_array";
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleStructArrayCase(m_context, (baseName + "_vertex").c_str(),	"", baseFlags|DECLARE_VERTEX,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleStructArrayCase(m_context, (baseName + "_fragment").c_str(),	"", baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (!(baseFlags & LAYOUT_PACKED))
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						modeGroup->addChild(new BlockSingleStructArrayCase(m_context, (baseName + "_both").c_str(),		"", baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	bufferModes[modeNdx].mode, isArray ? 3 : 0));
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.single_nested_struct
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* singleNestedStructGroup = new tcu::TestCaseGroup(m_testCtx, "single_nested_struct", "Nested struct in one uniform block");
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(singleNestedStructGroup);
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int modeNdx = 0; modeNdx < DE_LENGTH_OF_ARRAY(bufferModes); modeNdx++)
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* modeGroup = new tcu::TestCaseGroup(m_testCtx, bufferModes[modeNdx].name, "");
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			singleNestedStructGroup->addChild(modeGroup);
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int isArray = 0; isArray < 2; isArray++)
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::string	baseName	= layoutFlags[layoutFlagNdx].name;
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					deUint32	baseFlags	= layoutFlags[layoutFlagNdx].flags;
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (bufferModes[modeNdx].mode == UniformBlockCase::BUFFERMODE_SINGLE && isArray == 0)
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						continue; // Doesn't make sense to add this variant.
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (isArray)
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						baseName += "_instance_array";
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleNestedStructCase(m_context, (baseName + "_vertex").c_str(),		"", baseFlags|DECLARE_VERTEX,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleNestedStructCase(m_context, (baseName + "_fragment").c_str(),	"", baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (!(baseFlags & LAYOUT_PACKED))
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						modeGroup->addChild(new BlockSingleNestedStructCase(m_context, (baseName + "_both").c_str(),		"", baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	bufferModes[modeNdx].mode, isArray ? 3 : 0));
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.single_nested_struct_array
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* singleNestedStructArrayGroup = new tcu::TestCaseGroup(m_testCtx, "single_nested_struct_array", "Nested struct array in one uniform block");
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(singleNestedStructArrayGroup);
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int modeNdx = 0; modeNdx < DE_LENGTH_OF_ARRAY(bufferModes); modeNdx++)
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* modeGroup = new tcu::TestCaseGroup(m_testCtx, bufferModes[modeNdx].name, "");
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			singleNestedStructArrayGroup->addChild(modeGroup);
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int isArray = 0; isArray < 2; isArray++)
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::string	baseName	= layoutFlags[layoutFlagNdx].name;
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					deUint32	baseFlags	= layoutFlags[layoutFlagNdx].flags;
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (bufferModes[modeNdx].mode == UniformBlockCase::BUFFERMODE_SINGLE && isArray == 0)
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						continue; // Doesn't make sense to add this variant.
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (isArray)
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						baseName += "_instance_array";
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleNestedStructArrayCase(m_context, (baseName + "_vertex").c_str(),		"", baseFlags|DECLARE_VERTEX,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockSingleNestedStructArrayCase(m_context, (baseName + "_fragment").c_str(),	"", baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (!(baseFlags & LAYOUT_PACKED))
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						modeGroup->addChild(new BlockSingleNestedStructArrayCase(m_context, (baseName + "_both").c_str(),		"", baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	bufferModes[modeNdx].mode, isArray ? 3 : 0));
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.instance_array_basic_type
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* instanceArrayBasicTypeGroup = new tcu::TestCaseGroup(m_testCtx, "instance_array_basic_type", "Single basic variable in instance array");
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(instanceArrayBasicTypeGroup);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* layoutGroup = new tcu::TestCaseGroup(m_testCtx, layoutFlags[layoutFlagNdx].name, "");
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			instanceArrayBasicTypeGroup->addChild(layoutGroup);
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int basicTypeNdx = 0; basicTypeNdx < DE_LENGTH_OF_ARRAY(basicTypes); basicTypeNdx++)
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glu::DataType	type			= basicTypes[basicTypeNdx];
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const char*		typeName		= glu::getDataTypeName(type);
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		numInstances	= 3;
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				createBlockBasicTypeCases(layoutGroup, m_context, typeName,
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  VarType(type, glu::isDataTypeBoolOrBVec(type) ? 0 : PRECISION_HIGH),
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  layoutFlags[layoutFlagNdx].flags, numInstances);
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (glu::isDataTypeMatrix(type))
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					for (int matFlagNdx = 0; matFlagNdx < DE_LENGTH_OF_ARRAY(matrixFlags); matFlagNdx++)
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						createBlockBasicTypeCases(layoutGroup, m_context, (string(matrixFlags[matFlagNdx].name) + "_" + typeName).c_str(),
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  VarType(type, PRECISION_HIGH), layoutFlags[layoutFlagNdx].flags|matrixFlags[matFlagNdx].flags,
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  numInstances);
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.multi_basic_types
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* multiBasicTypesGroup = new tcu::TestCaseGroup(m_testCtx, "multi_basic_types", "Multiple buffers with basic types");
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(multiBasicTypesGroup);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int modeNdx = 0; modeNdx < DE_LENGTH_OF_ARRAY(bufferModes); modeNdx++)
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* modeGroup = new tcu::TestCaseGroup(m_testCtx, bufferModes[modeNdx].name, "");
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			multiBasicTypesGroup->addChild(modeGroup);
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int isArray = 0; isArray < 2; isArray++)
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::string	baseName	= layoutFlags[layoutFlagNdx].name;
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					deUint32	baseFlags	= layoutFlags[layoutFlagNdx].flags;
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (isArray)
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						baseName += "_instance_array";
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockMultiBasicTypesCase(m_context, (baseName + "_vertex").c_str(),		"", baseFlags|DECLARE_VERTEX,					baseFlags|DECLARE_VERTEX,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockMultiBasicTypesCase(m_context, (baseName + "_fragment").c_str(),	"", baseFlags|DECLARE_FRAGMENT,					baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (!(baseFlags & LAYOUT_PACKED))
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						modeGroup->addChild(new BlockMultiBasicTypesCase(m_context, (baseName + "_both").c_str(),		"", baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	bufferModes[modeNdx].mode, isArray ? 3 : 0));
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockMultiBasicTypesCase(m_context, (baseName + "_mixed").c_str(),		"", baseFlags|DECLARE_VERTEX,					baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.multi_nested_struct
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* multiNestedStructGroup = new tcu::TestCaseGroup(m_testCtx, "multi_nested_struct", "Multiple buffers with nested structs");
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(multiNestedStructGroup);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int modeNdx = 0; modeNdx < DE_LENGTH_OF_ARRAY(bufferModes); modeNdx++)
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TestCaseGroup* modeGroup = new tcu::TestCaseGroup(m_testCtx, bufferModes[modeNdx].name, "");
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			multiNestedStructGroup->addChild(modeGroup);
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int layoutFlagNdx = 0; layoutFlagNdx < DE_LENGTH_OF_ARRAY(layoutFlags); layoutFlagNdx++)
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int isArray = 0; isArray < 2; isArray++)
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::string	baseName	= layoutFlags[layoutFlagNdx].name;
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					deUint32	baseFlags	= layoutFlags[layoutFlagNdx].flags;
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (isArray)
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						baseName += "_instance_array";
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockMultiNestedStructCase(m_context, (baseName + "_vertex").c_str(),	"", baseFlags|DECLARE_VERTEX,					baseFlags|DECLARE_VERTEX,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockMultiNestedStructCase(m_context, (baseName + "_fragment").c_str(),	"", baseFlags|DECLARE_FRAGMENT,					baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (!(baseFlags & LAYOUT_PACKED))
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						modeGroup->addChild(new BlockMultiNestedStructCase(m_context, (baseName + "_both").c_str(),		"", baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	baseFlags|DECLARE_VERTEX|DECLARE_FRAGMENT,	bufferModes[modeNdx].mode, isArray ? 3 : 0));
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					modeGroup->addChild(new BlockMultiNestedStructCase(m_context, (baseName + "_mixed").c_str(),	"", baseFlags|DECLARE_VERTEX,					baseFlags|DECLARE_FRAGMENT,					bufferModes[modeNdx].mode, isArray ? 3 : 0));
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// ubo.random
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32	allShaders		= FEATURE_VERTEX_BLOCKS|FEATURE_FRAGMENT_BLOCKS|FEATURE_SHARED_BLOCKS;
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32	allLayouts		= FEATURE_PACKED_LAYOUT|FEATURE_SHARED_LAYOUT|FEATURE_STD140_LAYOUT;
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32	allBasicTypes	= FEATURE_VECTORS|FEATURE_MATRICES;
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32	unused			= FEATURE_UNUSED_MEMBERS|FEATURE_UNUSED_UNIFORMS;
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32	matFlags		= FEATURE_MATRIX_LAYOUT;
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32	allFeatures		= ~FEATURE_ARRAYS_OF_ARRAYS;
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* randomGroup = new tcu::TestCaseGroup(m_testCtx, "random", "Random Uniform Block cases");
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(randomGroup);
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Basic types.
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "scalar_types",	"Scalar types only, per-block buffers",				UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused,										25, 0);
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "vector_types",	"Scalar and vector types only, per-block buffers",	UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|FEATURE_VECTORS,						25, 25);
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "basic_types",	"All basic types, per-block buffers",				UniformBlockCase::BUFFERMODE_PER_BLOCK, allShaders|allLayouts|unused|allBasicTypes|matFlags,				25, 50);
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "basic_arrays",	"Arrays, per-block buffers",						UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|allBasicTypes|matFlags|FEATURE_ARRAYS,	25, 50);
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "basic_instance_arrays",					"Basic instance arrays, per-block buffers",				UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|allBasicTypes|matFlags|FEATURE_INSTANCE_ARRAYS,								25, 75);
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "nested_structs",							"Nested structs, per-block buffers",					UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|allBasicTypes|matFlags|FEATURE_STRUCTS,										25, 100);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "nested_structs_arrays",					"Nested structs, arrays, per-block buffers",			UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|allBasicTypes|matFlags|FEATURE_STRUCTS|FEATURE_ARRAYS,							25, 150);
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "nested_structs_instance_arrays",			"Nested structs, instance arrays, per-block buffers",	UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|allBasicTypes|matFlags|FEATURE_STRUCTS|FEATURE_INSTANCE_ARRAYS,				25, 125);
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "nested_structs_arrays_instance_arrays",	"Nested structs, instance arrays, per-block buffers",	UniformBlockCase::BUFFERMODE_PER_BLOCK,	allShaders|allLayouts|unused|allBasicTypes|matFlags|FEATURE_STRUCTS|FEATURE_ARRAYS|FEATURE_INSTANCE_ARRAYS,	25, 175);
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "all_per_block_buffers",	"All random features, per-block buffers",	UniformBlockCase::BUFFERMODE_PER_BLOCK,	allFeatures,	50, 200);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createRandomCaseGroup(randomGroup, m_context, "all_shared_buffer",		"All random features, shared buffer",		UniformBlockCase::BUFFERMODE_SINGLE,	allFeatures,	50, 250);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
733