13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) 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 Random uniform block layout case.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsRandomUniformBlockCase.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::ub;
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomUniformBlockCase::RandomUniformBlockCase (tcu::TestContext&	testCtx,
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												glu::RenderContext&	renderCtx,
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												glu::GLSLVersion	glslVersion,
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												const char*			name,
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												const char*			description,
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												BufferMode			bufferMode,
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												deUint32			features,
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												deUint32			seed)
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: UniformBlockCase		(testCtx, renderCtx, name, description, glslVersion, bufferMode)
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_features			(features)
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxVertexBlocks		((features & FEATURE_VERTEX_BLOCKS)		? 4 : 0)
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxFragmentBlocks	((features & FEATURE_FRAGMENT_BLOCKS)	? 4 : 0)
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxSharedBlocks		((features & FEATURE_SHARED_BLOCKS)		? 4 : 0)
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxInstances		((features & FEATURE_INSTANCE_ARRAYS)	? 3 : 0)
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxArrayLength		((features & FEATURE_ARRAYS)			? 8 : 0)
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxStructDepth		((features & FEATURE_STRUCTS)			? 2 : 0)
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxBlockMembers		(5)
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_maxStructMembers	(4)
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_seed				(seed)
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_blockNdx			(1)
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_uniformNdx			(1)
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_structNdx			(1)
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomUniformBlockCase::init (void)
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random rnd(m_seed);
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numShared		= m_maxSharedBlocks				> 0	? rnd.getInt(1, m_maxSharedBlocks)				: 0;
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numVtxBlocks	= m_maxVertexBlocks-numShared	> 0	? rnd.getInt(1, m_maxVertexBlocks-numShared)	: 0;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int	numFragBlocks	= m_maxFragmentBlocks-numShared	> 0 ? rnd.getInt(1, m_maxFragmentBlocks-numShared)	: 0;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < numShared; ndx++)
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		generateBlock(rnd, DECLARE_VERTEX|DECLARE_FRAGMENT);
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < numVtxBlocks; ndx++)
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		generateBlock(rnd, DECLARE_VERTEX);
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < numFragBlocks; ndx++)
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		generateBlock(rnd, DECLARE_FRAGMENT);
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomUniformBlockCase::generateBlock (de::Random& rnd, deUint32 layoutFlags)
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_blockNdx <= 'z' - 'a');
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float		instanceArrayWeight	= 0.3f;
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UniformBlock&	block				= m_interface.allocBlock((string("Block") + (char)('A' + m_blockNdx)).c_str());
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numInstances		= (m_maxInstances > 0 && rnd.getFloat() < instanceArrayWeight) ? rnd.getInt(0, m_maxInstances) : 0;
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numUniforms			= rnd.getInt(1, m_maxBlockMembers);
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numInstances > 0)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setArraySize(numInstances);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numInstances > 0 || rnd.getBool())
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		block.setInstanceName((string("block") + (char)('A' + m_blockNdx)).c_str());
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Layout flag candidates.
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<deUint32> layoutFlagCandidates;
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	layoutFlagCandidates.push_back(0);
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_features & FEATURE_PACKED_LAYOUT)
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		layoutFlagCandidates.push_back(LAYOUT_SHARED);
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_features & FEATURE_SHARED_LAYOUT) && ((layoutFlags & DECLARE_BOTH) != DECLARE_BOTH))
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		layoutFlagCandidates.push_back(LAYOUT_PACKED); // \note packed layout can only be used in a single shader stage.
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_features & FEATURE_STD140_LAYOUT)
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		layoutFlagCandidates.push_back(LAYOUT_STD140);
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	layoutFlags |= rnd.choose<deUint32>(layoutFlagCandidates.begin(), layoutFlagCandidates.end());
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_features & FEATURE_MATRIX_LAYOUT)
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const deUint32 matrixCandidates[] = { 0, LAYOUT_ROW_MAJOR, LAYOUT_COLUMN_MAJOR };
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		layoutFlags |= rnd.choose<deUint32>(&matrixCandidates[0], &matrixCandidates[DE_LENGTH_OF_ARRAY(matrixCandidates)]);
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	block.setFlags(layoutFlags);
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < numUniforms; ndx++)
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		generateUniform(rnd, block);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_blockNdx += 1;
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic std::string genName (char first, char last, int ndx)
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string	str			= "";
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			alphabetLen	= last - first + 1;
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	while (ndx > alphabetLen)
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		str.insert(str.begin(), (char)(first + ((ndx-1)%alphabetLen)));
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ndx = ((ndx-1) / alphabetLen);
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	str.insert(str.begin(), (char)(first + (ndx%(alphabetLen+1)) - 1));
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return str;
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomUniformBlockCase::generateUniform (de::Random& rnd, UniformBlock& block)
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float		unusedVtxWeight		= 0.15f;
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float		unusedFragWeight	= 0.15f;
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool			unusedOk			= (m_features & FEATURE_UNUSED_UNIFORMS) != 0;
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		flags				= 0;
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string		name				= genName('a', 'z', m_uniformNdx);
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VarType			type				= generateType(rnd, 0, true);
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	flags |= (unusedOk && rnd.getFloat() < unusedVtxWeight)		? UNUSED_VERTEX		: 0;
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	flags |= (unusedOk && rnd.getFloat() < unusedFragWeight)	? UNUSED_FRAGMENT	: 0;
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	block.addUniform(Uniform(name.c_str(), type, flags));
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_uniformNdx += 1;
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVarType RandomUniformBlockCase::generateType (de::Random& rnd, int typeDepth, bool arrayOk)
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float structWeight	= 0.1f;
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float arrayWeight		= 0.1f;
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (typeDepth < m_maxStructDepth && rnd.getFloat() < structWeight)
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float		unusedVtxWeight		= 0.15f;
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float		unusedFragWeight	= 0.15f;
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool			unusedOk			= (m_features & FEATURE_UNUSED_MEMBERS) != 0;
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<VarType>	memberTypes;
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				numMembers = rnd.getInt(1, m_maxStructMembers);
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Generate members first so nested struct declarations are in correct order.
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numMembers; ndx++)
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			memberTypes.push_back(generateType(rnd, typeDepth+1, true));
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StructType& structType = m_interface.allocStruct((string("s") + genName('A', 'Z', m_structNdx)).c_str());
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_structNdx += 1;
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(numMembers <= 'Z' - 'A');
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numMembers; ndx++)
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32 flags = 0;
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			flags |= (unusedOk && rnd.getFloat() < unusedVtxWeight)		? UNUSED_VERTEX		: 0;
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			flags |= (unusedOk && rnd.getFloat() < unusedFragWeight)	? UNUSED_FRAGMENT	: 0;
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			structType.addMember((string("m") + (char)('A' + ndx)).c_str(), memberTypes[ndx], flags);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return VarType(&structType);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (m_maxArrayLength > 0 && arrayOk && rnd.getFloat() < arrayWeight)
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const bool	arraysOfArraysOk	= (m_features & FEATURE_ARRAYS_OF_ARRAYS) != 0;
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	arrayLength			= rnd.getInt(1, m_maxArrayLength);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		VarType	elementType	= generateType(rnd, typeDepth, arraysOfArraysOk);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return VarType(elementType, arrayLength);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<glu::DataType> typeCandidates;
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeCandidates.push_back(glu::TYPE_FLOAT);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeCandidates.push_back(glu::TYPE_INT);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeCandidates.push_back(glu::TYPE_UINT);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		typeCandidates.push_back(glu::TYPE_BOOL);
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_features & FEATURE_VECTORS)
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_VEC2);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_VEC3);
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_VEC4);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_INT_VEC2);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_INT_VEC3);
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_INT_VEC4);
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_UINT_VEC2);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_UINT_VEC3);
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_UINT_VEC4);
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_BOOL_VEC2);
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_BOOL_VEC3);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_BOOL_VEC4);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_features & FEATURE_MATRICES)
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT2);
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT2X3);
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT3X2);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT3);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT3X4);
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT4X2);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT4X3);
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			typeCandidates.push_back(glu::TYPE_FLOAT_MAT4);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::DataType	type	= rnd.choose<glu::DataType>(typeCandidates.begin(), typeCandidates.end());
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		flags	= 0;
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!glu::isDataTypeBoolOrBVec(type))
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Precision.
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			static const deUint32 precisionCandidates[] = { PRECISION_LOW, PRECISION_MEDIUM, PRECISION_HIGH };
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			flags |= rnd.choose<deUint32>(&precisionCandidates[0], &precisionCandidates[DE_LENGTH_OF_ARRAY(precisionCandidates)]);
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return VarType(type, flags);
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
249