13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLUVARTYPE_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLUVARTYPE_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES Utilities
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 Shader variable type.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <ostream>
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass StructType;
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Shader variable type.
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Variable type represents data type. No storage qualifiers are supported
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * since they are associated to a declaration, not to the variable type.
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \note Structs are handled using struct pointers since it is often desirable
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *		 to maintain unique list of struct declarations.
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VarType
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VarType			(void);
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VarType			(const VarType& other);
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VarType			(DataType basicType, Precision precision);		//!< Basic type constructor.
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VarType			(const VarType& elementType, int arraySize);	//!< Array type constructor.
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	explicit			VarType			(const StructType* structPtr);					//!< Struct type constructor.
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~VarType		(void);
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				isBasicType		(void) const	{ return m_type == TYPE_BASIC;	}
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				isArrayType		(void) const	{ return m_type == TYPE_ARRAY;	}
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				isStructType	(void) const	{ return m_type == TYPE_STRUCT;	}
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DataType			getBasicType	(void) const	{ DE_ASSERT(isBasicType()); return m_data.basic.type;			}
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Precision			getPrecision	(void) const	{ DE_ASSERT(isBasicType()); return m_data.basic.precision;		}
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const VarType&		getElementType	(void) const	{ DE_ASSERT(isArrayType()); return *m_data.array.elementType;	}
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					getArraySize	(void) const	{ DE_ASSERT(isArrayType()); return m_data.array.size;			}
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const StructType*	getStructPtr	(void) const	{ DE_ASSERT(isStructType()); return m_data.structPtr;			}
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					getScalarSize	(void) const;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VarType&			operator=		(const VarType& other);
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				operator==		(const VarType& other) const;
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				operator!=		(const VarType& other) const;
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIZED_ARRAY = -1 //!< Array length for unsized arrays.
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum Type
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_BASIC,
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_ARRAY,
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_STRUCT,
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_LAST
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Type				m_type;
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	union Data
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// TYPE_BASIC
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		struct
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DataType		type;
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Precision		precision;
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} basic;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// TYPE_ARRAY
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		struct
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			VarType*		elementType;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				size;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} array;
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// TYPE_STRUCT
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const StructType*	structPtr;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Data (void)
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			array.elementType	= DE_NULL;
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			array.size			= 0;
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} m_data;
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline VarType varTypeOf (Precision prec = PRECISION_LAST) { return VarType(dataTypeOf<T>(), prec); }
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass StructMember
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						StructMember	(const char* name, const VarType& type) : m_name(name), m_type(type) {}
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						StructMember	(void) {}
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*			getName			(void) const { return m_name.c_str();	}
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const VarType&		getType			(void) const { return m_type;			}
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				operator==		(const StructMember& other) const;
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				operator!=		(const StructMember& other) const;
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			m_name;
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VarType				m_type;
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass StructType
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef std::vector<StructMember>::iterator			Iterator;
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef std::vector<StructMember>::const_iterator	ConstIterator;
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								StructType		(const char* typeName) : m_typeName(typeName) {}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~StructType		(void) {}
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						hasTypeName		(void) const	{ return !m_typeName.empty();	}
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*					getTypeName		(void) const	{ return hasTypeName() ? m_typeName.c_str() : DE_NULL; }
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						addMember		(const char* name, const VarType& type);
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getNumMembers	(void) const	{ return (int)m_members.size();	}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const StructMember&			getMember		(int ndx) const	{ return m_members[ndx];		}
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline Iterator				begin			(void)			{ return m_members.begin();		}
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline ConstIterator		begin			(void) const	{ return m_members.begin();		}
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline Iterator				end				(void)			{ return m_members.end();		}
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline ConstIterator		end				(void) const	{ return m_members.end();		}
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						operator==		(const StructType& other) const;
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						operator!=		(const StructType& other) const;
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string					m_typeName;
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<StructMember>	m_members;
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum Storage
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1721bfa102df7c2678fa4ac421fa29780848c2c12f3Jarkko Pöyry	STORAGE_IN = 0,
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	STORAGE_OUT,
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	STORAGE_CONST,
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	STORAGE_UNIFORM,
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	STORAGE_BUFFER,
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	STORAGE_LAST
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getStorageName (Storage storage);
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum Interpolation
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1841bfa102df7c2678fa4ac421fa29780848c2c12f3Jarkko Pöyry	INTERPOLATION_SMOOTH = 0,
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INTERPOLATION_FLAT,
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INTERPOLATION_CENTROID,
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INTERPOLATION_LAST
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getInterpolationName (Interpolation interpolation);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum FormatLayout
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA32F = 0,
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA16F,
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_R32F,
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA8,
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA8_SNORM,
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA32I,
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA16I,
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA8I,
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_R32I,
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA32UI,
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA16UI,
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_RGBA8UI,
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_R32UI,
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FORMATLAYOUT_LAST
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getFormatLayoutName (FormatLayout layout);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum MemoryAccessQualifier
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MEMORYACCESSQUALIFIER_COHERENT_BIT	= 0x01,
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MEMORYACCESSQUALIFIER_VOLATILE_BIT	= 0x02,
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MEMORYACCESSQUALIFIER_RESTRICT_BIT	= 0x04,
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MEMORYACCESSQUALIFIER_READONLY_BIT	= 0x08,
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MEMORYACCESSQUALIFIER_WRITEONLY_BIT	= 0x10,
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MEMORYACCESSQUALIFIER_MASK = (MEMORYACCESSQUALIFIER_WRITEONLY_BIT << 1) - 1
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getMemoryAccessQualifierName (MemoryAccessQualifier qualifier);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum MatrixOrder
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MATRIXORDER_COLUMN_MAJOR = 0,
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MATRIXORDER_ROW_MAJOR,
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MATRIXORDER_LAST
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getMatrixOrderName (MatrixOrder qualifier);
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Declaration utilities.
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Layout
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					Layout			(int location_ = -1, int binding_ = -1, int offset_ = -1, FormatLayout format_ = FORMATLAYOUT_LAST, MatrixOrder matrixOrder_ = MATRIXORDER_LAST);
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool			operator==		(const Layout& other) const;
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool			operator!=		(const Layout& other) const;
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				location;
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				binding;
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				offset;
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FormatLayout	format;
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MatrixOrder		matrixOrder;
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VariableDeclaration
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VariableDeclaration	(const VarType& varType_, const std::string& name_, Storage storage_ = STORAGE_LAST, Interpolation interpolation_ = INTERPOLATION_LAST, const Layout& layout_ = Layout(), deUint32 memoryAccessQualifierBits_ = 0);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				operator==			(const VariableDeclaration& other) const;
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				operator!=			(const VariableDeclaration& other) const;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Layout				layout;
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Interpolation		interpolation;
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Storage				storage;
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VarType				varType;
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			memoryAccessQualifierBits;
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			name;
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct InterfaceBlock
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											InterfaceBlock	(void);
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::Layout								layout;
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Storage									storage;
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int										memoryAccessQualifierFlags;
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string								interfaceName;
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string								instanceName;
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<glu::VariableDeclaration>	variables;
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<int>						dimensions;
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Internals for declare() utilities.
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace decl
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Indent
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int level;
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Indent (int level_) : level(level_) {}
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DeclareStructTypePtr
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DeclareStructTypePtr (const StructType* structPtr_, int indentLevel_) : structPtr(structPtr_), indentLevel(indentLevel_) {}
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const StructType*	structPtr;
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					indentLevel;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DeclareStructType
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DeclareStructType (const StructType& structType_, int indentLevel_) : structType(structType_), indentLevel(indentLevel_) {}
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StructType			structType;
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					indentLevel;
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DeclareVariable
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DeclareVariable (const VarType& varType_, const std::string& name_, int indentLevel_) : varType(varType_), name(name_), indentLevel(indentLevel_) {}
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VarType				varType;
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			name;
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					indentLevel;
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, const Indent&				indent);
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, const DeclareStructTypePtr&	decl);
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, const DeclareStructType&	decl);
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, const DeclareVariable&		decl);
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // decl
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline decl::Indent					indent			(int indentLevel)														{ return decl::Indent(indentLevel);									}
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline decl::DeclareStructTypePtr	declare			(const StructType*	structPtr,	int indentLevel = 0)					{ return decl::DeclareStructTypePtr	(structPtr,		indentLevel);	}
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline decl::DeclareStructType		declare			(const StructType&	structType,	int indentLevel = 0)					{ return decl::DeclareStructType	(structType,	indentLevel);	}
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline decl::DeclareVariable		declare			(const VarType& varType, const std::string& name, int indentLevel = 0)	{ return decl::DeclareVariable		(varType, name, indentLevel);	}
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&						operator<<		(std::ostream& str, const Layout& decl);
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&						operator<<		(std::ostream& str, const VariableDeclaration& decl);
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // glu
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLUVARTYPE_HPP
335