13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLUPROGRAMINTERFACEQUERY_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLUPROGRAMINTERFACEQUERY_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL 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 Program interface query utilities
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glw
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Functions;
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Interface block info.
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct InterfaceBlockInfo
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			name;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			index;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			bufferBinding;		//!< GL_BUFFER_BINDING
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			dataSize;			//!< GL_BUFFER_DATA_SIZE
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<int>	activeVariables;	//!< GL_ACTIVE_VARIABLES
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	InterfaceBlockInfo (void)
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: index				(~0u /* GL_INVALID_INDEX */)
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, bufferBinding		(0)
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, dataSize			(0)
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Interface variable (uniform in uniform block, buffer variable) info.
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct InterfaceVariableInfo
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			name;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			index;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			blockIndex;					//!< GL_BLOCK_INDEX
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			atomicCounterBufferIndex;	//!< GL_ATOMIC_COUNTER_BUFFER_INDEX
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			type;						//!< GL_TYPE
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			arraySize;					//!< GL_ARRAY_SIZE
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			offset;						//!< GL_OFFSET
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32				arrayStride;				//!< GL_ARRAY_STRIDE
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32				matrixStride;				//!< GL_MATRIX_STRIDE
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			topLevelArraySize;			//!< GL_TOP_LEVEL_ARRAY_SIZE	- set only for GL_BUFFER_VARIABLEs
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32				topLevelArrayStride;		//!< GL_TOP_LEVEL_ARRAY_STRIDE	- set only for GL_BUFFER_VARIABLEs
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				isRowMajor;					//!< GL_IS_ROW_MAJOR
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	InterfaceVariableInfo (void)
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: index						(~0u /* GL_INVALID_INDEX */)
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, blockIndex				(~0u /* GL_INVALID_INDEX */)
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, atomicCounterBufferIndex	(~0u /* GL_INVALID_INDEX */)
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, type						(0)
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, arraySize					(0)
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, offset					(0)
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, arrayStride				(0)
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, matrixStride				(0)
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, topLevelArraySize			(0)
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, topLevelArrayStride		(0)
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, isRowMajor				(0)
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint						getProgramResourceInt			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam);
903c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32				getProgramResourceUint			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam);
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid					getProgramResourceName			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, std::string& dst);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string				getProgramResourceName			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index);
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid					getProgramInterfaceBlockInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, InterfaceBlockInfo& info);
963c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInterfaceBlockInfo		getProgramInterfaceBlockInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index);
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid					getProgramInterfaceVariableInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, InterfaceVariableInfo& info);
993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInterfaceVariableInfo	getProgramInterfaceVariableInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index);
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Inline implementations for optimization (RVO in most cases).
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline int getProgramResourceInt (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam)
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (int)getProgramResourceUint(gl, program, programInterface, index, queryParam);
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline std::string getProgramResourceName (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string name;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	getProgramResourceName(gl, program, programInterface, index, name);
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return name;
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline InterfaceBlockInfo getProgramInterfaceBlockInfo (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	InterfaceBlockInfo info;
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	getProgramInterfaceBlockInfo(gl, program, programInterface, index, info);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return info;
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline InterfaceVariableInfo getProgramInterfaceVariableInfo (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	InterfaceVariableInfo info;
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	getProgramInterfaceVariableInfo(gl, program, programInterface, index, info);
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return info;
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // glu
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLUPROGRAMINTERFACEQUERY_HPP
132