Lines Matching full:shader
93 bool VariableSearchFilter::matchesFilter (const ProgramInterfaceDefinition::Shader* shader) const
95 DE_ASSERT(shader->getType() < glu::SHADERTYPE_LAST);
96 return (m_shaderTypeBits & (1u << shader->getType())) != 0;
139 bool shaderContainsIOBlocks (const ProgramInterfaceDefinition::Shader* shader)
141 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
143 const glu::Storage storage = shader->getDefaultBlock().interfaceBlocks[ndx].storage;
219 static std::string getShaderExtensionDeclarations (const ProgramInterfaceDefinition::Shader* shader)
224 if (shader->getType() == glu::SHADERTYPE_GEOMETRY)
228 else if (shader->getType() == glu::SHADERTYPE_TESSELLATION_CONTROL ||
229 shader->getType() == glu::SHADERTYPE_TESSELLATION_EVALUATION)
234 if (shaderContainsIOBlocks(shader))
742 static bool traverseShaderVariablePath (std::vector<VariablePathComponent>& typePath, const ProgramInterfaceDefinition::Shader* shader, const std::string& path, const VariableSearchFilter& filter)
745 for (int varNdx = 0; varNdx < (int)shader->getDefaultBlock().variables.size(); ++varNdx)
746 if (filter.matchesFilter(shader->getDefaultBlock().variables[varNdx]))
747 if (traverseVariablePath(typePath, path, shader->getDefaultBlock().variables[varNdx]))
754 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
756 if (!filter.matchesFilter(shader->getDefaultBlock().interfaceBlocks[interfaceNdx]))
759 if (shader->getDefaultBlock().interfaceBlocks[interfaceNdx].interfaceName == blockName)
766 for (int varNdx = 0; varNdx < (int)shader->getDefaultBlock().interfaceBlocks[interfaceNdx].variables.size(); ++varNdx)
768 if (shader->getDefaultBlock().interfaceBlocks[interfaceNdx].variables[varNdx].name == blockMemeberName)
770 typePath.push_back(VariablePathComponent(&shader->getDefaultBlock().interfaceBlocks[interfaceNdx]));
771 return traverseVariablePath(typePath, blockMemberPath, shader->getDefaultBlock().interfaceBlocks[interfaceNdx].variables[varNdx]);
778 else if (shader->getDefaultBlock().interfaceBlocks[interfaceNdx].instanceName.empty())
783 for (int varNdx = 0; varNdx < (int)shader->getDefaultBlock().interfaceBlocks[interfaceNdx].variables.size(); ++varNdx)
785 if (shader->getDefaultBlock().interfaceBlocks[interfaceNdx].variables[varNdx].name == blockMemeberName)
787 typePath.push_back(VariablePathComponent(&shader->getDefaultBlock().interfaceBlocks[interfaceNdx]));
788 return traverseVariablePath(typePath, path, shader->getDefaultBlock().interfaceBlocks[interfaceNdx].variables[varNdx]);
804 const ProgramInterfaceDefinition::Shader* shader = program->getShaders()[shaderNdx];
806 if (filter.matchesFilter(shader))
810 if (traverseShaderVariablePath(typePath, shader, path, filter))
842 static int getNumShaderBlocks (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage)
846 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
848 if (shader->getDefaultBlock().interfaceBlocks[ndx].storage == storage)
852 for (int dimensionNdx = 0; dimensionNdx < (int)shader->getDefaultBlock().interfaceBlocks[ndx].dimensions.size(); ++dimensionNdx)
853 numInstances *= shader->getDefaultBlock().interfaceBlocks[ndx].dimensions[dimensionNdx];
862 static int getNumAtomicCounterBuffers (const ProgramInterfaceDefinition::Shader* shader)
866 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
868 if (containsSubType(shader->getDefaultBlock().variables[ndx].varType, glu::TYPE_UINT_ATOMIC_COUNTER))
870 DE_ASSERT(shader->getDefaultBlock().variables[ndx].layout.binding != -1);
871 buffers.insert(shader->getDefaultBlock().variables[ndx].layout.binding);
903 static int accumulateShader (const ProgramInterfaceDefinition::Shader* shader,
910 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
912 if (ibFilter(shader->getDefaultBlock().interfaceBlocks[ndx]))
916 for (int dimensionNdx = 0; dimensionNdx < (int)shader->getDefaultBlock().interfaceBlocks[ndx].dimensions.size(); ++dimensionNdx)
917 numInstances *= shader->getDefaultBlock().interfaceBlocks[ndx].dimensions[dimensionNdx];
919 for (int varNdx = 0; varNdx < (int)shader->getDefaultBlock().interfaceBlocks[ndx].variables.size(); ++varNdx)
920 retVal += numInstances * accumulateComplexType(shader->getDefaultBlock().interfaceBlocks[ndx].variables[varNdx].varType, dMap);
924 for (int varNdx = 0; varNdx < (int)shader->getDefaultBlock().variables.size(); ++varNdx)
925 if (vdFilter(shader->getDefaultBlock().variables[varNdx]))
926 retVal += accumulateComplexType(shader->getDefaultBlock().variables[varNdx].varType, dMap);
993 static int getNumTypeInstances (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage, bool (*predicate)(glu::DataType))
995 return accumulateShader(shader, InterfaceBlockStorageFilter(storage), VariableDeclarationStorageFilter(storage), InstanceCounter(predicate));
998 static int getNumTypeInstances (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage)
1000 return getNumTypeInstances(shader, storage, dummyTrueConstantTypeFilter);
1003 static int accumulateShaderStorage (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage, int (*typeMap)(glu::DataType))
1005 return accumulateShader(shader, InterfaceBlockStorageFilter(storage), VariableDeclarationStorageFilter(storage), typeMap);
1028 static int getNumComponents (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage)
1030 return accumulateShaderStorage(shader, storage, getNumDataTypeComponents);
1033 Shader* shader, glu::Storage storage)
1035 return accumulateShaderStorage(shader, storage, getNumDataTypeVectors);
1038 static int getNumDefaultBlockComponents (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage)
1042 for (int varNdx = 0; varNdx < (int)shader->getDefaultBlock().variables.size(); ++varNdx)
1043 if (shader->getDefaultBlock().variables[varNdx].storage == storage)
1044 retVal += accumulateComplexType(shader->getDefaultBlock().variables[varNdx].varType, getNumDataTypeComponents);
1049 static int getMaxBufferBinding (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage)
1053 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
1055 if (shader->getDefaultBlock().interfaceBlocks[ndx].storage == storage)
1057 const int binding = (shader->getDefaultBlock().interfaceBlocks[ndx].layout.binding == -1) ? (0) : (shader->getDefaultBlock().interfaceBlocks[ndx].layout.binding);
1060 for (int dimensionNdx = 0; dimensionNdx < (int)shader->getDefaultBlock().interfaceBlocks[ndx].dimensions.size(); ++dimensionNdx)
1061 numInstances *= shader->getDefaultBlock().interfaceBlocks[ndx].dimensions[dimensionNdx];
1120 static int getBufferMaxSize (const ProgramInterfaceDefinition::Shader* shader, glu::Storage storage)
1124 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
1125 if (shader->getDefaultBlock().interfaceBlocks[ndx].storage == storage)
1126 maxSize = de::max(maxSize, getBufferSize(shader->getDefaultBlock().interfaceBlocks[ndx], shader->getDefaultBlock().interfaceBlocks[ndx].layout.matrixOrder));
1131 static int getAtomicCounterMaxBinding (const ProgramInterfaceDefinition::Shader* shader)
1135 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1137 if (containsSubType(shader->getDefaultBlock().variables[ndx].varType, glu::TYPE_UINT_ATOMIC_COUNTER))
1139 DE_ASSERT(shader->getDefaultBlock().variables[ndx].layout.binding != -1);
1140 maxBinding = de::max(maxBinding, shader->getDefaultBlock().variables[ndx].layout.binding);
1147 static int getUniformMaxBinding (const ProgramInterfaceDefinition::Shader* shader, bool (*predicate)(glu::DataType))
1151 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1153 const int binding = (shader->getDefaultBlock().variables[ndx].layout.binding == -1) ? (0) : (shader->getDefaultBlock().variables[ndx].layout.binding);
1154 const int numInstances = getNumTypeInstances(shader->getDefaultBlock().variables[ndx].varType, predicate);
1162 static int getAtomicCounterMaxBufferSize (const ProgramInterfaceDefinition::Shader* shader)
1167 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1169 if (containsSubType(shader->getDefaultBlock().variables[ndx].varType, glu::TYPE_UINT_ATOMIC_COUNTER))
1171 const int bufferBinding = shader->getDefaultBlock().variables[ndx].layout.binding;
1172 const int offset = (shader->getDefaultBlock().variables[ndx].layout.offset == -1) ? (0) : (shader->getDefaultBlock().variables[ndx].layout.offset);
1173 const int size = offset + 4 * getNumTypeInstances(shader->getDefaultBlock().variables[ndx].varType, glu::isDataTypeAtomicCounter);
1175 DE_ASSERT(shader->getDefaultBlock().variables[ndx].layout.binding != -1);
1225 static int getFragmentOutputMaxLocation (const ProgramInterfaceDefinition::Shader* shader)
1227 DE_ASSERT(shader->getType() == glu::SHADERTYPE_FRAGMENT);
1231 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1233 if (shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_OUT)
1236 const int outputLocation = (shader->getDefaultBlock().variables[ndx].layout.location == -1)
1238 : (shader->getDefaultBlock().variables[ndx].layout.location);
1241 DE_ASSERT(!shader->getDefaultBlock().variables[ndx].varType.isStructType());
1243 const int locationSlotsTaken = (shader->getDefaultBlock().variables[ndx].varType.isArrayType())
1244 ? (shader->getDefaultBlock().variables[ndx].varType.getArraySize())
1292 const ProgramInterfaceDefinition::Shader* shader = program->getShaders()[shaderNdx];
1294 for (int variableNdx = 0; variableNdx < (int)shader->getDefaultBlock().variables.size(); ++variableNdx)
1295 if (shader->getDefaultBlock().variables[variableNdx].storage == storage)
1297 shader->getDefaultBlock().variables[variableNdx].name,
1298 shader->getDefaultBlock().variables[variableNdx].varType,
1301 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1303 const glu::InterfaceBlock& interfaceBlock = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1321 const ProgramInterfaceDefinition::Shader* shader = program->getShaders()[shaderNdx];
1322 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1324 const glu::InterfaceBlock& interfaceBlock = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1361 const ProgramInterfaceDefinition::Shader* shader = program->getShaders()[shaderNdx];
1363 if (shader->getType() != shaderType)
1366 for (int variableNdx = 0; variableNdx < (int)shader->getDefaultBlock().variables.size(); ++variableNdx)
1368 const glu::Storage variableStorage = shader->getDefaultBlock().variables[variableNdx].storage;
1371 shader->getDefaultBlock().variables[variableNdx].name,
1372 shader->getDefaultBlock().variables[variableNdx].varType,
1376 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1378 const glu::InterfaceBlock& interfaceBlock = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1486 const ProgramInterfaceDefinition::Shader* shader = program->getShaders()[shaderNdx];
1492 sourceBuf << glu::getGLSLVersionDeclaration(shader->getVersion()) << "\n"
1493 << getShaderExtensionDeclarations(shader)
1494 << getShaderTypeDeclarations(program, shader->getType())
1499 writeStructureDefinitions(sourceBuf, shader->getDefaultBlock());
1503 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1504 sourceBuf << shader->getDefaultBlock().variables[ndx] << ";\n";
1506 if (!shader->getDefaultBlock().variables.empty())
1511 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
1512 writeInterfaceBlock(sourceBuf, shader->getDefaultBlock().interfaceBlocks[ndx]);
1522 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1524 if (shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_IN ||
1525 shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_PATCH_IN ||
1526 shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_UNIFORM)
1530 shader->getDefaultBlock().variables[ndx].name,
1531 shader->getType(),
1532 shader->getDefaultBlock().variables[ndx].storage,
1534 shader->getDefaultBlock().variables[ndx].varType);
1539 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1541 const glu::InterfaceBlock& interface = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1547 shader->getType(),
1555 switch (shader->getType())
1598 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1600 if (shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_OUT ||
1601 shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_PATCH_OUT)
1605 shader->getDefaultBlock().variables[ndx].name,
1606 shader->getType(),
1607 shader->getDefaultBlock().variables[ndx].storage,
1609 shader->getDefaultBlock().variables[ndx].varType);
1614 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1616 const glu::InterfaceBlock& interface = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1619 writeInterfaceWriteExpression(usageBuf, "dummyValue", interface, shader->getType(), program);
1626 if (shader->getType() == glu::SHADERTYPE_VERTEX)
1628 else if (shader->getType() == glu::SHADERTYPE_GEOMETRY)
1631 else if (shader->getType() == glu::SHADERTYPE_TESSELLATION_CONTROL)
1639 else if (shader->getType() == glu::SHADERTYPE_TESSELLATION_EVALUATION)
1646 if (shader->getType() == glu::SHADERTYPE_FRAGMENT)
1648 else if (shader->getType() == glu::SHADERTYPE_COMPUTE)
1660 if (shader->getType() == glu::SHADERTYPE_COMPUTE && !containsUserDefinedOutputs)
1668 sources << glu::ShaderSource(shader->getType(), sourceBuf.str() + usageBuf.str());
1695 ProgramInterfaceDefinition::ShaderResourceUsage getShaderResourceUsage (const ProgramInterfaceDefinition::Program* program, const ProgramInterfaceDefinition::Shader* shader)
1699 retVal.numInputs = getNumTypeInstances(shader, glu::STORAGE_IN);
1700 retVal.numInputVectors = getNumVectors(shader, glu::STORAGE_IN);
1701 retVal.numInputComponents = getNumComponents(shader, glu::STORAGE_IN);
1703 retVal.numOutputs = getNumTypeInstances(shader, glu::STORAGE_OUT);
1704 retVal.numOutputVectors = getNumVectors(shader, glu::STORAGE_OUT);
1705 retVal.numOutputComponents = getNumComponents(shader, glu::STORAGE_OUT);
1707 retVal.numPatchInputComponents = getNumComponents(shader, glu::STORAGE_PATCH_IN);
1708 retVal.numPatchOutputComponents = getNumComponents(shader, glu::STORAGE_PATCH_OUT);
1710 retVal.numDefaultBlockUniformComponents = getNumDefaultBlockComponents(shader, glu::STORAGE_UNIFORM);
1711 retVal.numCombinedUniformComponents = getNumComponents(shader, glu::STORAGE_UNIFORM);
1712 retVal.numUniformVectors = getNumVectors(shader, glu::STORAGE_UNIFORM);
1714 retVal.numSamplers = getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeSampler);
1715 retVal.numImages = getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeImage);
1717 retVal.numAtomicCounterBuffers = getNumAtomicCounterBuffers(shader);
1718 retVal.numAtomicCounters = getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeAtomicCounter);
1720 retVal.numUniformBlocks = getNumShaderBlocks(shader, glu::STORAGE_UNIFORM);
1721 retVal.numShaderStorageBlocks = getNumShaderBlocks(shader, glu::STORAGE_BUFFER);
1724 switch (shader->getType())
1817 const ProgramInterfaceDefinition::Shader* const shader = program->getShaders()[shaderNdx];
1819 retVal.uniformBufferMaxBinding = de::max(retVal.uniformBufferMaxBinding, getMaxBufferBinding(shader, glu::STORAGE_UNIFORM));
1820 retVal.uniformBufferMaxSize = de::max(retVal.uniformBufferMaxSize, getBufferMaxSize(shader, glu::STORAGE_UNIFORM));
1821 retVal.numUniformBlocks += getNumShaderBlocks(shader, glu::STORAGE_UNIFORM);
1823 switch (shader->getType())
1825 case glu::SHADERTYPE_VERTEX: retVal.numCombinedVertexUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1826 case glu::SHADERTYPE_FRAGMENT: retVal.numCombinedFragmentUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1827 case glu::SHADERTYPE_GEOMETRY: retVal.numCombinedGeometryUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1828 case glu::SHADERTYPE_TESSELLATION_CONTROL: retVal.numCombinedTessControlUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1829 case glu::SHADERTYPE_TESSELLATION_EVALUATION: retVal.numCombinedTessEvalUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1833 retVal.shaderStorageBufferMaxBinding = de::max(retVal.shaderStorageBufferMaxBinding, getMaxBufferBinding(shader, glu::STORAGE_BUFFER));
1834 retVal.shaderStorageBufferMaxSize = de::max(retVal.shaderStorageBufferMaxSize, getBufferMaxSize(shader, glu::STORAGE_BUFFER));
1835 retVal.numShaderStorageBlocks += getNumShaderBlocks(shader, glu::STORAGE_BUFFER);
1837 if (shader->getType() == glu::SHADERTYPE_VERTEX)
1839 numVertexOutputComponents += getNumComponents(shader, glu::STORAGE_OUT);
1840 numVertexOutputVectors += getNumVectors(shader, glu::STORAGE_OUT);
1842 else if (shader->getType() == glu::SHADERTYPE_FRAGMENT)
1844 numFragmentInputComponents += getNumComponents(shader, glu::STORAGE_IN);
1845 numFragmentInputVectors += getNumVectors(shader, glu::STORAGE_IN);
1848 retVal.numCombinedSamplers += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeSampler);
1850 retVal.atomicCounterBufferMaxBinding = de::max(retVal.atomicCounterBufferMaxBinding, getAtomicCounterMaxBinding(shader));
1851 retVal.atomicCounterBufferMaxSize = de::max(retVal.atomicCounterBufferMaxSize, getAtomicCounterMaxBufferSize(shader));
1852 retVal.numAtomicCounterBuffers += getNumAtomicCounterBuffers(shader);
1853 retVal.numAtomicCounters += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeAtomicCounter);
1854 retVal.maxImageBinding = de::max(retVal.maxImageBinding, getUniformMaxBinding(shader, glu::isDataTypeImage));
1855 retVal.numCombinedImages += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeImage);
1857 retVal.numCombinedOutputResources += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeImage);
1858 retVal.numCombinedOutputResources += getNumShaderBlocks(shader, glu::STORAGE_BUFFER);
1860 if (shader
1862 retVal.numCombinedOutputResources += getNumVectors(shader, glu::STORAGE_OUT);
1863 retVal.fragmentOutputMaxBinding = de::max(retVal.fragmentOutputMaxBinding, getFragmentOutputMaxLocation(shader));