1*35238bceSAndroid Build Coastguard Worker #ifndef _ES31FPROGRAMINTERFACEDEFINITIONUTIL_HPP 2*35238bceSAndroid Build Coastguard Worker #define _ES31FPROGRAMINTERFACEDEFINITIONUTIL_HPP 3*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.1 Module 5*35238bceSAndroid Build Coastguard Worker * ------------------------------------------------- 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker * 9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker * 15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker * limitations under the License. 20*35238bceSAndroid Build Coastguard Worker * 21*35238bceSAndroid Build Coastguard Worker *//*! 22*35238bceSAndroid Build Coastguard Worker * \file 23*35238bceSAndroid Build Coastguard Worker * \brief Program interface utilities 24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp" 27*35238bceSAndroid Build Coastguard Worker #include "tes31TestCase.hpp" 28*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp" 29*35238bceSAndroid Build Coastguard Worker #include "es31fProgramInterfaceDefinition.hpp" 30*35238bceSAndroid Build Coastguard Worker 31*35238bceSAndroid Build Coastguard Worker namespace deqp 32*35238bceSAndroid Build Coastguard Worker { 33*35238bceSAndroid Build Coastguard Worker namespace gles31 34*35238bceSAndroid Build Coastguard Worker { 35*35238bceSAndroid Build Coastguard Worker namespace Functional 36*35238bceSAndroid Build Coastguard Worker { 37*35238bceSAndroid Build Coastguard Worker namespace ProgramInterfaceDefinition 38*35238bceSAndroid Build Coastguard Worker { 39*35238bceSAndroid Build Coastguard Worker 40*35238bceSAndroid Build Coastguard Worker class Program; 41*35238bceSAndroid Build Coastguard Worker 42*35238bceSAndroid Build Coastguard Worker class VariablePathComponent 43*35238bceSAndroid Build Coastguard Worker { 44*35238bceSAndroid Build Coastguard Worker public: VariablePathComponent(void)45*35238bceSAndroid Build Coastguard Worker VariablePathComponent(void) : m_type(TYPE_LAST) 46*35238bceSAndroid Build Coastguard Worker { 47*35238bceSAndroid Build Coastguard Worker } VariablePathComponent(const glu::VarType * type)48*35238bceSAndroid Build Coastguard Worker VariablePathComponent(const glu::VarType *type) : m_type(TYPE_TYPE) 49*35238bceSAndroid Build Coastguard Worker { 50*35238bceSAndroid Build Coastguard Worker m_data.type = type; 51*35238bceSAndroid Build Coastguard Worker } VariablePathComponent(const glu::InterfaceBlock * block)52*35238bceSAndroid Build Coastguard Worker VariablePathComponent(const glu::InterfaceBlock *block) : m_type(TYPE_INTERFACEBLOCK) 53*35238bceSAndroid Build Coastguard Worker { 54*35238bceSAndroid Build Coastguard Worker m_data.block = block; 55*35238bceSAndroid Build Coastguard Worker } VariablePathComponent(const glu::VariableDeclaration * decl)56*35238bceSAndroid Build Coastguard Worker VariablePathComponent(const glu::VariableDeclaration *decl) : m_type(TYPE_DECLARATION) 57*35238bceSAndroid Build Coastguard Worker { 58*35238bceSAndroid Build Coastguard Worker m_data.declaration = decl; 59*35238bceSAndroid Build Coastguard Worker } 60*35238bceSAndroid Build Coastguard Worker VariablePathComponent(const VariablePathComponent & other)61*35238bceSAndroid Build Coastguard Worker VariablePathComponent(const VariablePathComponent &other) : m_data(other.m_data), m_type(other.m_type) 62*35238bceSAndroid Build Coastguard Worker { 63*35238bceSAndroid Build Coastguard Worker } operator =(const VariablePathComponent & other)64*35238bceSAndroid Build Coastguard Worker VariablePathComponent &operator=(const VariablePathComponent &other) 65*35238bceSAndroid Build Coastguard Worker { 66*35238bceSAndroid Build Coastguard Worker m_type = other.m_type; 67*35238bceSAndroid Build Coastguard Worker m_data = other.m_data; 68*35238bceSAndroid Build Coastguard Worker return *this; 69*35238bceSAndroid Build Coastguard Worker } 70*35238bceSAndroid Build Coastguard Worker isVariableType(void) const71*35238bceSAndroid Build Coastguard Worker bool isVariableType(void) const 72*35238bceSAndroid Build Coastguard Worker { 73*35238bceSAndroid Build Coastguard Worker return m_type == TYPE_TYPE; 74*35238bceSAndroid Build Coastguard Worker } isInterfaceBlock(void) const75*35238bceSAndroid Build Coastguard Worker bool isInterfaceBlock(void) const 76*35238bceSAndroid Build Coastguard Worker { 77*35238bceSAndroid Build Coastguard Worker return m_type == TYPE_INTERFACEBLOCK; 78*35238bceSAndroid Build Coastguard Worker } isDeclaration(void) const79*35238bceSAndroid Build Coastguard Worker bool isDeclaration(void) const 80*35238bceSAndroid Build Coastguard Worker { 81*35238bceSAndroid Build Coastguard Worker return m_type == TYPE_DECLARATION; 82*35238bceSAndroid Build Coastguard Worker } 83*35238bceSAndroid Build Coastguard Worker getVariableType(void) const84*35238bceSAndroid Build Coastguard Worker const glu::VarType *getVariableType(void) const 85*35238bceSAndroid Build Coastguard Worker { 86*35238bceSAndroid Build Coastguard Worker DE_ASSERT(isVariableType()); 87*35238bceSAndroid Build Coastguard Worker return m_data.type; 88*35238bceSAndroid Build Coastguard Worker } getInterfaceBlock(void) const89*35238bceSAndroid Build Coastguard Worker const glu::InterfaceBlock *getInterfaceBlock(void) const 90*35238bceSAndroid Build Coastguard Worker { 91*35238bceSAndroid Build Coastguard Worker DE_ASSERT(isInterfaceBlock()); 92*35238bceSAndroid Build Coastguard Worker return m_data.block; 93*35238bceSAndroid Build Coastguard Worker } getDeclaration(void) const94*35238bceSAndroid Build Coastguard Worker const glu::VariableDeclaration *getDeclaration(void) const 95*35238bceSAndroid Build Coastguard Worker { 96*35238bceSAndroid Build Coastguard Worker DE_ASSERT(isDeclaration()); 97*35238bceSAndroid Build Coastguard Worker return m_data.declaration; 98*35238bceSAndroid Build Coastguard Worker } 99*35238bceSAndroid Build Coastguard Worker 100*35238bceSAndroid Build Coastguard Worker private: 101*35238bceSAndroid Build Coastguard Worker enum Type 102*35238bceSAndroid Build Coastguard Worker { 103*35238bceSAndroid Build Coastguard Worker TYPE_TYPE, 104*35238bceSAndroid Build Coastguard Worker TYPE_INTERFACEBLOCK, 105*35238bceSAndroid Build Coastguard Worker TYPE_DECLARATION, 106*35238bceSAndroid Build Coastguard Worker 107*35238bceSAndroid Build Coastguard Worker TYPE_LAST 108*35238bceSAndroid Build Coastguard Worker }; 109*35238bceSAndroid Build Coastguard Worker 110*35238bceSAndroid Build Coastguard Worker union Data 111*35238bceSAndroid Build Coastguard Worker { 112*35238bceSAndroid Build Coastguard Worker const glu::VarType *type; 113*35238bceSAndroid Build Coastguard Worker const glu::InterfaceBlock *block; 114*35238bceSAndroid Build Coastguard Worker const glu::VariableDeclaration *declaration; 115*35238bceSAndroid Build Coastguard Worker Data(void)116*35238bceSAndroid Build Coastguard Worker Data(void) : type(DE_NULL) 117*35238bceSAndroid Build Coastguard Worker { 118*35238bceSAndroid Build Coastguard Worker } 119*35238bceSAndroid Build Coastguard Worker } m_data; 120*35238bceSAndroid Build Coastguard Worker 121*35238bceSAndroid Build Coastguard Worker Type m_type; 122*35238bceSAndroid Build Coastguard Worker }; 123*35238bceSAndroid Build Coastguard Worker 124*35238bceSAndroid Build Coastguard Worker struct VariableSearchFilter 125*35238bceSAndroid Build Coastguard Worker { 126*35238bceSAndroid Build Coastguard Worker private: 127*35238bceSAndroid Build Coastguard Worker VariableSearchFilter(void); 128*35238bceSAndroid Build Coastguard Worker 129*35238bceSAndroid Build Coastguard Worker public: 130*35238bceSAndroid Build Coastguard Worker static VariableSearchFilter createShaderTypeFilter(glu::ShaderType); 131*35238bceSAndroid Build Coastguard Worker static VariableSearchFilter createStorageFilter(glu::Storage); 132*35238bceSAndroid Build Coastguard Worker static VariableSearchFilter createShaderTypeStorageFilter(glu::ShaderType, glu::Storage); 133*35238bceSAndroid Build Coastguard Worker 134*35238bceSAndroid Build Coastguard Worker static VariableSearchFilter logicalOr(const VariableSearchFilter &a, const VariableSearchFilter &b); 135*35238bceSAndroid Build Coastguard Worker static VariableSearchFilter logicalAnd(const VariableSearchFilter &a, const VariableSearchFilter &b); 136*35238bceSAndroid Build Coastguard Worker 137*35238bceSAndroid Build Coastguard Worker bool matchesFilter(const ProgramInterfaceDefinition::Shader *shader) const; 138*35238bceSAndroid Build Coastguard Worker bool matchesFilter(const glu::VariableDeclaration &variable) const; 139*35238bceSAndroid Build Coastguard Worker bool matchesFilter(const glu::InterfaceBlock &block) const; 140*35238bceSAndroid Build Coastguard Worker getShaderTypeBitsdeqp::gles31::Functional::ProgramInterfaceDefinition::VariableSearchFilter141*35238bceSAndroid Build Coastguard Worker uint32_t getShaderTypeBits(void) const 142*35238bceSAndroid Build Coastguard Worker { 143*35238bceSAndroid Build Coastguard Worker return m_shaderTypeBits; 144*35238bceSAndroid Build Coastguard Worker } getStorageBitsdeqp::gles31::Functional::ProgramInterfaceDefinition::VariableSearchFilter145*35238bceSAndroid Build Coastguard Worker uint32_t getStorageBits(void) const 146*35238bceSAndroid Build Coastguard Worker { 147*35238bceSAndroid Build Coastguard Worker return m_storageBits; 148*35238bceSAndroid Build Coastguard Worker } 149*35238bceSAndroid Build Coastguard Worker 150*35238bceSAndroid Build Coastguard Worker private: 151*35238bceSAndroid Build Coastguard Worker uint32_t m_shaderTypeBits; 152*35238bceSAndroid Build Coastguard Worker uint32_t m_storageBits; 153*35238bceSAndroid Build Coastguard Worker }; 154*35238bceSAndroid Build Coastguard Worker 155*35238bceSAndroid Build Coastguard Worker struct ShaderResourceUsage 156*35238bceSAndroid Build Coastguard Worker { 157*35238bceSAndroid Build Coastguard Worker int numInputs; 158*35238bceSAndroid Build Coastguard Worker int numInputVectors; 159*35238bceSAndroid Build Coastguard Worker int numInputComponents; 160*35238bceSAndroid Build Coastguard Worker int numOutputs; 161*35238bceSAndroid Build Coastguard Worker int numOutputVectors; 162*35238bceSAndroid Build Coastguard Worker int numOutputComponents; 163*35238bceSAndroid Build Coastguard Worker int numPatchInputComponents; 164*35238bceSAndroid Build Coastguard Worker int numPatchOutputComponents; 165*35238bceSAndroid Build Coastguard Worker 166*35238bceSAndroid Build Coastguard Worker int numDefaultBlockUniformComponents; 167*35238bceSAndroid Build Coastguard Worker int numCombinedUniformComponents; 168*35238bceSAndroid Build Coastguard Worker int numUniformVectors; 169*35238bceSAndroid Build Coastguard Worker 170*35238bceSAndroid Build Coastguard Worker int numSamplers; 171*35238bceSAndroid Build Coastguard Worker int numImages; 172*35238bceSAndroid Build Coastguard Worker 173*35238bceSAndroid Build Coastguard Worker int numAtomicCounterBuffers; 174*35238bceSAndroid Build Coastguard Worker int numAtomicCounters; 175*35238bceSAndroid Build Coastguard Worker 176*35238bceSAndroid Build Coastguard Worker int numUniformBlocks; 177*35238bceSAndroid Build Coastguard Worker int numShaderStorageBlocks; 178*35238bceSAndroid Build Coastguard Worker }; 179*35238bceSAndroid Build Coastguard Worker 180*35238bceSAndroid Build Coastguard Worker struct ProgramResourceUsage 181*35238bceSAndroid Build Coastguard Worker { 182*35238bceSAndroid Build Coastguard Worker int uniformBufferMaxBinding; 183*35238bceSAndroid Build Coastguard Worker int uniformBufferMaxSize; 184*35238bceSAndroid Build Coastguard Worker int numUniformBlocks; 185*35238bceSAndroid Build Coastguard Worker int numCombinedVertexUniformComponents; 186*35238bceSAndroid Build Coastguard Worker int numCombinedFragmentUniformComponents; 187*35238bceSAndroid Build Coastguard Worker int numCombinedGeometryUniformComponents; 188*35238bceSAndroid Build Coastguard Worker int numCombinedTessControlUniformComponents; 189*35238bceSAndroid Build Coastguard Worker int numCombinedTessEvalUniformComponents; 190*35238bceSAndroid Build Coastguard Worker int shaderStorageBufferMaxBinding; 191*35238bceSAndroid Build Coastguard Worker int shaderStorageBufferMaxSize; 192*35238bceSAndroid Build Coastguard Worker int numShaderStorageBlocks; 193*35238bceSAndroid Build Coastguard Worker int numVaryingComponents; 194*35238bceSAndroid Build Coastguard Worker int numVaryingVectors; 195*35238bceSAndroid Build Coastguard Worker int numCombinedSamplers; 196*35238bceSAndroid Build Coastguard Worker int atomicCounterBufferMaxBinding; 197*35238bceSAndroid Build Coastguard Worker int atomicCounterBufferMaxSize; 198*35238bceSAndroid Build Coastguard Worker int numAtomicCounterBuffers; 199*35238bceSAndroid Build Coastguard Worker int numAtomicCounters; 200*35238bceSAndroid Build Coastguard Worker int maxImageBinding; 201*35238bceSAndroid Build Coastguard Worker int numCombinedImages; 202*35238bceSAndroid Build Coastguard Worker int numCombinedOutputResources; 203*35238bceSAndroid Build Coastguard Worker int numXFBInterleavedComponents; 204*35238bceSAndroid Build Coastguard Worker int numXFBSeparateAttribs; 205*35238bceSAndroid Build Coastguard Worker int numXFBSeparateComponents; 206*35238bceSAndroid Build Coastguard Worker int fragmentOutputMaxBinding; 207*35238bceSAndroid Build Coastguard Worker }; 208*35238bceSAndroid Build Coastguard Worker 209*35238bceSAndroid Build Coastguard Worker } // namespace ProgramInterfaceDefinition 210*35238bceSAndroid Build Coastguard Worker 211*35238bceSAndroid Build Coastguard Worker enum ResourceNameGenerationFlag 212*35238bceSAndroid Build Coastguard Worker { 213*35238bceSAndroid Build Coastguard Worker RESOURCE_NAME_GENERATION_FLAG_DEFAULT = 0x0, 214*35238bceSAndroid Build Coastguard Worker RESOURCE_NAME_GENERATION_FLAG_TOP_LEVEL_BUFFER_VARIABLE = 0x1, 215*35238bceSAndroid Build Coastguard Worker RESOURCE_NAME_GENERATION_FLAG_TRANSFORM_FEEDBACK_VARIABLE = 0x2, 216*35238bceSAndroid Build Coastguard Worker 217*35238bceSAndroid Build Coastguard Worker RESOURCE_NAME_GENERATION_FLAG_MASK = 0x3 218*35238bceSAndroid Build Coastguard Worker }; 219*35238bceSAndroid Build Coastguard Worker 220*35238bceSAndroid Build Coastguard Worker bool programContainsIOBlocks(const ProgramInterfaceDefinition::Program *program); 221*35238bceSAndroid Build Coastguard Worker bool shaderContainsIOBlocks(const ProgramInterfaceDefinition::Shader *shader); 222*35238bceSAndroid Build Coastguard Worker glu::ShaderType getProgramTransformFeedbackStage(const ProgramInterfaceDefinition::Program *program); 223*35238bceSAndroid Build Coastguard Worker std::vector<std::string> getProgramInterfaceResourceList(const ProgramInterfaceDefinition::Program *program, 224*35238bceSAndroid Build Coastguard Worker ProgramInterface interface); 225*35238bceSAndroid Build Coastguard Worker std::vector<std::string> getProgramInterfaceBlockMemberResourceList(const glu::InterfaceBlock &interfaceBlock); 226*35238bceSAndroid Build Coastguard Worker const char *getUnusedZeroUniformName(); 227*35238bceSAndroid Build Coastguard Worker glu::ProgramSources generateProgramInterfaceProgramSources(const ProgramInterfaceDefinition::Program *program); 228*35238bceSAndroid Build Coastguard Worker bool findProgramVariablePathByPathName(std::vector<ProgramInterfaceDefinition::VariablePathComponent> &typePath, 229*35238bceSAndroid Build Coastguard Worker const ProgramInterfaceDefinition::Program *program, const std::string &pathName, 230*35238bceSAndroid Build Coastguard Worker const ProgramInterfaceDefinition::VariableSearchFilter &filter); 231*35238bceSAndroid Build Coastguard Worker void generateVariableTypeResourceNames(std::vector<std::string> &resources, const std::string &name, 232*35238bceSAndroid Build Coastguard Worker const glu::VarType &type, uint32_t resourceNameGenerationFlags); 233*35238bceSAndroid Build Coastguard Worker ProgramInterfaceDefinition::ShaderResourceUsage getShaderResourceUsage( 234*35238bceSAndroid Build Coastguard Worker const ProgramInterfaceDefinition::Program *program, const ProgramInterfaceDefinition::Shader *shader); 235*35238bceSAndroid Build Coastguard Worker ProgramInterfaceDefinition::ProgramResourceUsage getCombinedProgramResourceUsage( 236*35238bceSAndroid Build Coastguard Worker const ProgramInterfaceDefinition::Program *program); 237*35238bceSAndroid Build Coastguard Worker 238*35238bceSAndroid Build Coastguard Worker } // namespace Functional 239*35238bceSAndroid Build Coastguard Worker } // namespace gles31 240*35238bceSAndroid Build Coastguard Worker } // namespace deqp 241*35238bceSAndroid Build Coastguard Worker 242*35238bceSAndroid Build Coastguard Worker #endif // _ES31FPROGRAMINTERFACEDEFINITIONUTIL_HPP 243