• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GLUPROGRAMINTERFACEQUERY_HPP
2 #define _GLUPROGRAMINTERFACEQUERY_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program OpenGL Utilities
5  * ---------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Program interface query utilities
24  *//*--------------------------------------------------------------------*/
25 
26 #include "gluDefs.hpp"
27 
28 #include <vector>
29 #include <string>
30 
31 namespace glw
32 {
33 class Functions;
34 }
35 
36 namespace glu
37 {
38 
39 //! Interface block info.
40 struct InterfaceBlockInfo
41 {
42 	std::string			name;
43 	deUint32			index;
44 	deUint32			bufferBinding;		//!< GL_BUFFER_BINDING
45 	deUint32			dataSize;			//!< GL_BUFFER_DATA_SIZE
46 	std::vector<int>	activeVariables;	//!< GL_ACTIVE_VARIABLES
47 
InterfaceBlockInfoglu::InterfaceBlockInfo48 	InterfaceBlockInfo (void)
49 		: index				(~0u /* GL_INVALID_INDEX */)
50 		, bufferBinding		(0)
51 		, dataSize			(0)
52 	{
53 	}
54 };
55 
56 //! Interface variable (uniform in uniform block, buffer variable) info.
57 struct InterfaceVariableInfo
58 {
59 	std::string			name;
60 	deUint32			index;
61 	deUint32			blockIndex;					//!< GL_BLOCK_INDEX
62 	deUint32			atomicCounterBufferIndex;	//!< GL_ATOMIC_COUNTER_BUFFER_INDEX
63 	deUint32			type;						//!< GL_TYPE
64 	deUint32			arraySize;					//!< GL_ARRAY_SIZE
65 	deUint32			offset;						//!< GL_OFFSET
66 	deInt32				arrayStride;				//!< GL_ARRAY_STRIDE
67 	deInt32				matrixStride;				//!< GL_MATRIX_STRIDE
68 	deUint32			topLevelArraySize;			//!< GL_TOP_LEVEL_ARRAY_SIZE	- set only for GL_BUFFER_VARIABLEs
69 	deInt32				topLevelArrayStride;		//!< GL_TOP_LEVEL_ARRAY_STRIDE	- set only for GL_BUFFER_VARIABLEs
70 	bool				isRowMajor;					//!< GL_IS_ROW_MAJOR
71 
InterfaceVariableInfoglu::InterfaceVariableInfo72 	InterfaceVariableInfo (void)
73 		: index						(~0u /* GL_INVALID_INDEX */)
74 		, blockIndex				(~0u /* GL_INVALID_INDEX */)
75 		, atomicCounterBufferIndex	(~0u /* GL_INVALID_INDEX */)
76 		, type						(0)
77 		, arraySize					(0)
78 		, offset					(0)
79 		, arrayStride				(0)
80 		, matrixStride				(0)
81 		, topLevelArraySize			(0)
82 		, topLevelArrayStride		(0)
83 		, isRowMajor				(0)
84 	{
85 	}
86 };
87 
88 
89 int						getProgramResourceInt			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam);
90 deUint32				getProgramResourceUint			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam);
91 
92 void					getProgramResourceName			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, std::string& dst);
93 std::string				getProgramResourceName			(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index);
94 
95 void					getProgramInterfaceBlockInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, InterfaceBlockInfo& info);
96 InterfaceBlockInfo		getProgramInterfaceBlockInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index);
97 
98 void					getProgramInterfaceVariableInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, InterfaceVariableInfo& info);
99 InterfaceVariableInfo	getProgramInterfaceVariableInfo	(const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index);
100 
101 // Inline implementations for optimization (RVO in most cases).
102 
getProgramResourceInt(const glw::Functions & gl,deUint32 program,deUint32 programInterface,deUint32 index,deUint32 queryParam)103 inline int getProgramResourceInt (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam)
104 {
105 	return (int)getProgramResourceUint(gl, program, programInterface, index, queryParam);
106 }
107 
getProgramResourceName(const glw::Functions & gl,deUint32 program,deUint32 programInterface,deUint32 index)108 inline std::string getProgramResourceName (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
109 {
110 	std::string name;
111 	getProgramResourceName(gl, program, programInterface, index, name);
112 	return name;
113 }
114 
getProgramInterfaceBlockInfo(const glw::Functions & gl,deUint32 program,deUint32 programInterface,deUint32 index)115 inline InterfaceBlockInfo getProgramInterfaceBlockInfo (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
116 {
117 	InterfaceBlockInfo info;
118 	getProgramInterfaceBlockInfo(gl, program, programInterface, index, info);
119 	return info;
120 }
121 
getProgramInterfaceVariableInfo(const glw::Functions & gl,deUint32 program,deUint32 programInterface,deUint32 index)122 inline InterfaceVariableInfo getProgramInterfaceVariableInfo (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
123 {
124 	InterfaceVariableInfo info;
125 	getProgramInterfaceVariableInfo(gl, program, programInterface, index, info);
126 	return info;
127 }
128 
129 } // glu
130 
131 #endif // _GLUPROGRAMINTERFACEQUERY_HPP
132