1 #ifndef _GLUPROGRAMINTERFACEQUERY_HPP
2 #define _GLUPROGRAMINTERFACEQUERY_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL Utilities
5 * ---------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief Program interface query utilities
24 *//*--------------------------------------------------------------------*/
26 #include "gluDefs.hpp"
39 //! Interface block info.
40 struct InterfaceBlockInfo
44 deUint32 bufferBinding; //!< GL_BUFFER_BINDING
45 deUint32 dataSize; //!< GL_BUFFER_DATA_SIZE
46 std::vector<int> activeVariables; //!< GL_ACTIVE_VARIABLES
48 InterfaceBlockInfo (void)
49 : index (~0u /* GL_INVALID_INDEX */)
56 //! Interface variable (uniform in uniform block, buffer variable) info.
57 struct InterfaceVariableInfo
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
72 InterfaceVariableInfo (void)
73 : index (~0u /* GL_INVALID_INDEX */)
74 , blockIndex (~0u /* GL_INVALID_INDEX */)
75 , atomicCounterBufferIndex (~0u /* GL_INVALID_INDEX */)
81 , topLevelArraySize (0)
82 , topLevelArrayStride (0)
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);
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);
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);
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);
101 // Inline implementations for optimization (RVO in most cases).
103 inline int getProgramResourceInt (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index, deUint32 queryParam)
105 return (int)getProgramResourceUint(gl, program, programInterface, index, queryParam);
108 inline std::string getProgramResourceName (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
111 getProgramResourceName(gl, program, programInterface, index, name);
115 inline InterfaceBlockInfo getProgramInterfaceBlockInfo (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
117 InterfaceBlockInfo info;
118 getProgramInterfaceBlockInfo(gl, program, programInterface, index, info);
122 inline InterfaceVariableInfo getProgramInterfaceVariableInfo (const glw::Functions& gl, deUint32 program, deUint32 programInterface, deUint32 index)
124 InterfaceVariableInfo info;
125 getProgramInterfaceVariableInfo(gl, program, programInterface, index, info);
131 #endif // _GLUPROGRAMINTERFACEQUERY_HPP