13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _ES31FSSBOLAYOUTCASE_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _ES31FSSBOLAYOUTCASE_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief SSBO layout tests.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestCase.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluVarType.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderContext;
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Buffer block details.
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace bb
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum BufferVarFlags
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_SHARED		= (1<<0),
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_PACKED		= (1<<1),
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_STD140		= (1<<2),
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_STD430		= (1<<3),
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_ROW_MAJOR	= (1<<4),
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_COLUMN_MAJOR	= (1<<5),	//!< \note Lack of both flags means column-major matrix.
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LAYOUT_MASK			= LAYOUT_SHARED|LAYOUT_PACKED|LAYOUT_STD140|LAYOUT_STD430|LAYOUT_ROW_MAJOR|LAYOUT_COLUMN_MAJOR,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2013-10-14 pyry] Investigate adding these.
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*	QUALIFIER_COHERENT	= (1<<6),
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QUALIFIER_VOLATILE	= (1<<7),
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QUALIFIER_RESTRICT	= (1<<8),
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QUALIFIER_READONLY	= (1<<9),
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QUALIFIER_WRITEONLY	= (1<<10),*/
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ACCESS_READ			= (1<<11),	//!< Buffer variable is read in the shader.
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ACCESS_WRITE		= (1<<12),	//!< Buffer variable is written in the shader.
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferVar
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						BufferVar		(const char* name, const glu::VarType& type, deUint32 flags);
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*			getName			(void) const { return m_name.c_str();	}
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VarType&	getType			(void) const { return m_type;			}
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			getFlags		(void) const { return m_flags;			}
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			m_name;
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::VarType		m_type;
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			m_flags;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferBlock
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef std::vector<BufferVar>::iterator		iterator;
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef std::vector<BufferVar>::const_iterator	const_iterator;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							BufferBlock				(const char* blockName);
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*				getBlockName			(void) const { return m_blockName.c_str();		}
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*				getInstanceName			(void) const { return m_instanceName.empty() ? DE_NULL : m_instanceName.c_str();	}
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool					isArray					(void) const { return m_arraySize > 0;			}
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getArraySize			(void) const { return m_arraySize;				}
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				getFlags				(void) const { return m_flags;					}
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setInstanceName			(const char* name)			{ m_instanceName = name;			}
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setFlags				(deUint32 flags)			{ m_flags = flags;					}
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					addMember				(const BufferVar& var)		{ m_variables.push_back(var);		}
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setArraySize			(int arraySize);
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getLastUnsizedArraySize	(int instanceNdx) const		{ return m_lastUnsizedArraySizes[instanceNdx];	}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setLastUnsizedArraySize	(int instanceNdx, int size)	{ m_lastUnsizedArraySizes[instanceNdx] = size;	}
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline iterator			begin					(void)			{ return m_variables.begin();	}
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline const_iterator	begin					(void) const	{ return m_variables.begin();	}
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline iterator			end						(void)			{ return m_variables.end();		}
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline const_iterator	end						(void) const	{ return m_variables.end();		}
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string				m_blockName;
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string				m_instanceName;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<BufferVar>	m_variables;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_arraySize;				//!< Array size or 0 if not interface block array.
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<int>		m_lastUnsizedArraySizes;	//!< Sizes of last unsized array element, can be different per instance.
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				m_flags;
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderInterface
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									ShaderInterface			(void);
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~ShaderInterface		(void);
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::StructType&				allocStruct				(const char* name);
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::StructType*			findStruct				(const char* name) const;
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							getNamedStructs			(std::vector<const glu::StructType*>& structs) const;
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BufferBlock&					allocBlock				(const char* name);
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumBlocks			(void) const	{ return (int)m_bufferBlocks.size();	}
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const BufferBlock&				getBlock				(int ndx) const	{ return *m_bufferBlocks[ndx];			}
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									ShaderInterface			(const ShaderInterface&);
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderInterface&				operator=				(const ShaderInterface&);
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<glu::StructType*>	m_structs;
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<BufferBlock*>		m_bufferBlocks;
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferLayout;
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // bb
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SSBOLayoutCase : public tcu::TestCase
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum BufferMode
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		BUFFERMODE_SINGLE = 0,	//!< Single buffer shared between uniform blocks.
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		BUFFERMODE_PER_BLOCK,	//!< Per-block buffers
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		BUFFERMODE_LAST
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								SSBOLayoutCase				(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, glu::GLSLVersion glslVersion, BufferMode bufferMode);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~SSBOLayoutCase				(void);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult				iterate						(void);
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						compareStdBlocks			(const bb::BufferLayout& refLayout, const bb::BufferLayout& cmpLayout) const;
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						compareSharedBlocks			(const bb::BufferLayout& refLayout, const bb::BufferLayout& cmpLayout) const;
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						compareTypes				(const bb::BufferLayout& refLayout, const bb::BufferLayout& cmpLayout) const;
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						checkLayoutIndices			(const bb::BufferLayout& layout) const;
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						checkLayoutBounds			(const bb::BufferLayout& layout) const;
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						checkIndexQueries			(deUint32 program, const bb::BufferLayout& layout) const;
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						execute						(deUint32 program);
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			m_renderCtx;
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::GLSLVersion			m_glslVersion;
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BufferMode					m_bufferMode;
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bb::ShaderInterface			m_interface;
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								SSBOLayoutCase				(const SSBOLayoutCase&);
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SSBOLayoutCase&				operator=					(const SSBOLayoutCase&);
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _ES31FSSBOLAYOUTCASE_HPP
184