es31fProgramInterfaceDefinitionUtil.hpp revision c423ce6164cdd88c8c3e47bec4ec34476743042a
13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _ES31FPROGRAMINTERFACEDEFINITIONUTIL_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _ES31FPROGRAMINTERFACEDEFINITIONUTIL_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module 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 utilities 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tes31TestCase.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fProgramInterfaceDefinition.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace ProgramInterfaceDefinition 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Program; 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VariablePathComponent 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VariablePathComponent (void) :m_type(TYPE_LAST) { } 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VariablePathComponent (const glu::VarType* type) :m_type(TYPE_TYPE) { m_data.type = type; } 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VariablePathComponent (const glu::InterfaceBlock* block) :m_type(TYPE_INTERFACEBLOCK) { m_data.block = block; } 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VariablePathComponent (const glu::VariableDeclaration* decl) :m_type(TYPE_DECLARATION) { m_data.declaration = decl; } 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VariablePathComponent (const VariablePathComponent& other) : m_data(other.m_data), m_type(other.m_type) { } 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VariablePathComponent& operator= (const VariablePathComponent& other) { m_type = other.m_type; m_data = other.m_data; return *this; } 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isVariableType (void) const { return m_type == TYPE_TYPE; } 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isInterfaceBlock (void) const { return m_type == TYPE_INTERFACEBLOCK; } 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isDeclaration (void) const { return m_type == TYPE_DECLARATION; } 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::VarType* getVariableType (void) const { DE_ASSERT(isVariableType()); return m_data.type; } 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::InterfaceBlock* getInterfaceBlock (void) const { DE_ASSERT(isInterfaceBlock()); return m_data.block; } 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::VariableDeclaration* getDeclaration (void) const { DE_ASSERT(isDeclaration()); return m_data.declaration; } 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Type 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_TYPE, 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_INTERFACEBLOCK, 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_DECLARATION, 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_LAST 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry union Data 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::VarType* type; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::InterfaceBlock* block; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::VariableDeclaration* declaration; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Data (void) : type(DE_NULL) { } 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } m_data; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Type m_type; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VariableSearchFilter 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 85c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyryprivate: 86c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry VariableSearchFilter (void); 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 88c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyrypublic: 89c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry static VariableSearchFilter createShaderTypeFilter (glu::ShaderType); 90c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry static VariableSearchFilter createStorageFilter (glu::Storage); 91c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry static VariableSearchFilter createShaderTypeStorageFilter (glu::ShaderType, glu::Storage); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 93c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry static VariableSearchFilter logicalOr (const VariableSearchFilter& a, const VariableSearchFilter& b); 94c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry static VariableSearchFilter logicalAnd (const VariableSearchFilter& a, const VariableSearchFilter& b); 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 96c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry bool matchesFilter (const ProgramInterfaceDefinition::Shader* shader) const; 97c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry bool matchesFilter (const glu::VariableDeclaration& variable) const; 98c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry bool matchesFilter (const glu::InterfaceBlock& block) const; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 100c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry deUint32 getShaderTypeBits (void) const { return m_shaderTypeBits; }; 101c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry deUint32 getStorageBits (void) const { return m_storageBits; }; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 103c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry deUint32 m_shaderTypeBits; 104c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry deUint32 m_storageBits; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ShaderResourceUsage 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numInputs; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numInputVectors; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numInputComponents; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numOutputs; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numOutputVectors; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numOutputComponents; 115c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry int numPatchInputComponents; 116c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry int numPatchOutputComponents; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numDefaultBlockUniformComponents; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numCombinedUniformComponents; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numUniformVectors; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numSamplers; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numImages; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numAtomicCounterBuffers; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numAtomicCounters; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numUniformBlocks; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numShaderStorageBlocks; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ProgramResourceUsage 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int uniformBufferMaxBinding; 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int uniformBufferMaxSize; 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numUniformBlocks; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numCombinedVertexUniformComponents; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numCombinedFragmentUniformComponents; 139c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry int numCombinedGeometryUniformComponents; 140c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry int numCombinedTessControlUniformComponents; 141c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyry int numCombinedTessEvalUniformComponents; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int shaderStorageBufferMaxBinding; 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int shaderStorageBufferMaxSize; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numShaderStorageBlocks; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numVaryingComponents; 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numVaryingVectors; 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numCombinedSamplers; 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int atomicCounterBufferMaxBinding; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int atomicCounterBufferMaxSize; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numAtomicCounterBuffers; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numAtomicCounters; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int maxImageBinding; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numCombinedImages; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numCombinedOutputResources; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numXFBInterleavedComponents; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numXFBSeparateAttribs; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numXFBSeparateComponents; 1589fa944ae1829441ef58596701ddc9c3d07b50f04Jarkko Pöyry int fragmentOutputMaxBinding; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // ProgramInterfaceDefinition 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16379ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyryenum ResourceNameGenerationFlag 16479ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry{ 16579ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry RESOURCE_NAME_GENERATION_FLAG_DEFAULT = 0x0, 16679ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry RESOURCE_NAME_GENERATION_FLAG_TOP_LEVEL_BUFFER_VARIABLE = 0x1, 16779ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry RESOURCE_NAME_GENERATION_FLAG_TRANSFORM_FEEDBACK_VARIABLE = 0x2, 16879ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry 16979ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry RESOURCE_NAME_GENERATION_FLAG_MASK = 0x3 17079ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry}; 17179ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyry 172c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyrybool programContainsIOBlocks (const ProgramInterfaceDefinition::Program* program); 173c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyrybool shaderContainsIOBlocks (const ProgramInterfaceDefinition::Shader* shader); 174c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko Pöyryglu::ShaderType getProgramTransformFeedbackStage (const ProgramInterfaceDefinition::Program* program); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<std::string> getProgramInterfaceResourceList (const ProgramInterfaceDefinition::Program* program, ProgramInterface interface); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<std::string> getProgramInterfaceBlockMemberResourceList (const glu::InterfaceBlock& interfaceBlock); 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryglu::ProgramSources generateProgramInterfaceProgramSources (const ProgramInterfaceDefinition::Program* program); 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool findProgramVariablePathByPathName (std::vector<ProgramInterfaceDefinition::VariablePathComponent>& typePath, const ProgramInterfaceDefinition::Program* program, const std::string& pathName, const ProgramInterfaceDefinition::VariableSearchFilter& filter); 17979ec52223daa917719d5d0555e7d8020d6514951Jarkko Pöyryvoid generateVariableTypeResourceNames (std::vector<std::string>& resources, const std::string& name, const glu::VarType& type, deUint32 resourceNameGenerationFlags); 180c423ce6164cdd88c8c3e47bec4ec34476743042aJarkko PöyryProgramInterfaceDefinition::ShaderResourceUsage getShaderResourceUsage (const ProgramInterfaceDefinition::Program* program, const ProgramInterfaceDefinition::Shader* shader); 1813c827367444ee418f129b2c238299f49d3264554Jarkko PoyryProgramInterfaceDefinition::ProgramResourceUsage getCombinedProgramResourceUsage (const ProgramInterfaceDefinition::Program* program); 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _ES31FPROGRAMINTERFACEDEFINITIONUTIL_HPP 188