Home | History | Annotate | Download | only in functional

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];
1501 const ProgramInterfaceDefinition::Shader* shader = program->getShaders()[shaderNdx];
1507 sourceBuf << glu::getGLSLVersionDeclaration(shader->getVersion()) << "\n"
1508 << getShaderExtensionDeclarations(shader)
1509 << getShaderTypeDeclarations(program, shader->getType())
1514 writeStructureDefinitions(sourceBuf, shader->getDefaultBlock());
1518 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1519 sourceBuf << shader->getDefaultBlock().variables[ndx] << ";\n";
1521 if (!shader->getDefaultBlock().variables.empty())
1526 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++ndx)
1527 writeInterfaceBlock(sourceBuf, shader->getDefaultBlock().interfaceBlocks[ndx]);
1538 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1540 if (shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_IN ||
1541 shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_PATCH_IN ||
1542 shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_UNIFORM)
1546 shader->getDefaultBlock().variables[ndx].name,
1547 shader->getType(),
1548 shader->getDefaultBlock().variables[ndx].storage,
1550 shader->getDefaultBlock().variables[ndx].varType);
1555 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1557 const glu::InterfaceBlock& interface = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1563 shader->getType(),
1571 switch (shader->getType())
1614 for (int ndx = 0; ndx < (int)shader->getDefaultBlock().variables.size(); ++ndx)
1616 if (shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_OUT ||
1617 shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_PATCH_OUT)
1621 shader->getDefaultBlock().variables[ndx].name,
1622 shader->getType(),
1623 shader->getDefaultBlock().variables[ndx].storage,
1625 shader->getDefaultBlock().variables[ndx].varType);
1630 for (int interfaceNdx = 0; interfaceNdx < (int)shader->getDefaultBlock().interfaceBlocks.size(); ++interfaceNdx)
1632 const glu::InterfaceBlock& interface = shader->getDefaultBlock().interfaceBlocks[interfaceNdx];
1635 writeInterfaceWriteExpression(usageBuf, "dummyValue", interface, shader->getType(), program);
1642 if (shader->getType() == glu::SHADERTYPE_VERTEX)
1644 else if (shader->getType() == glu::SHADERTYPE_GEOMETRY)
1647 else if (shader->getType() == glu::SHADERTYPE_TESSELLATION_CONTROL)
1655 else if (shader->getType() == glu::SHADERTYPE_TESSELLATION_EVALUATION)
1662 if (shader->getType() == glu::SHADERTYPE_FRAGMENT)
1664 else if (shader->getType() == glu::SHADERTYPE_COMPUTE)
1676 if (shader->getType() == glu::SHADERTYPE_COMPUTE && !containsUserDefinedOutputs)
1684 sources << glu::ShaderSource(shader->getType(), sourceBuf.str() + usageBuf.str());
1711 ProgramInterfaceDefinition::ShaderResourceUsage getShaderResourceUsage (const ProgramInterfaceDefinition::Program* program, const ProgramInterfaceDefinition::Shader* shader)
1715 retVal.numInputs = getNumTypeInstances(shader, glu::STORAGE_IN);
1716 retVal.numInputVectors = getNumVectors(shader, glu::STORAGE_IN);
1717 retVal.numInputComponents = getNumComponents(shader, glu::STORAGE_IN);
1719 retVal.numOutputs = getNumTypeInstances(shader, glu::STORAGE_OUT);
1720 retVal.numOutputVectors = getNumVectors(shader, glu::STORAGE_OUT);
1721 retVal.numOutputComponents = getNumComponents(shader, glu::STORAGE_OUT);
1723 retVal.numPatchInputComponents = getNumComponents(shader, glu::STORAGE_PATCH_IN);
1724 retVal.numPatchOutputComponents = getNumComponents(shader, glu::STORAGE_PATCH_OUT);
1726 retVal.numDefaultBlockUniformComponents = getNumDefaultBlockComponents(shader, glu::STORAGE_UNIFORM);
1727 retVal.numCombinedUniformComponents = getNumComponents(shader, glu::STORAGE_UNIFORM);
1728 retVal.numUniformVectors = getNumVectors(shader, glu::STORAGE_UNIFORM);
1730 retVal.numSamplers = getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeSampler);
1731 retVal.numImages = getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeImage);
1733 retVal.numAtomicCounterBuffers = getNumAtomicCounterBuffers(shader);
1734 retVal.numAtomicCounters = getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeAtomicCounter);
1736 retVal.numUniformBlocks = getNumShaderBlocks(shader, glu::STORAGE_UNIFORM);
1737 retVal.numShaderStorageBlocks = getNumShaderBlocks(shader, glu::STORAGE_BUFFER);
1740 switch (shader->getType())
1833 const ProgramInterfaceDefinition::Shader* const shader = program->getShaders()[shaderNdx];
1835 retVal.uniformBufferMaxBinding = de::max(retVal.uniformBufferMaxBinding, getMaxBufferBinding(shader, glu::STORAGE_UNIFORM));
1836 retVal.uniformBufferMaxSize = de::max(retVal.uniformBufferMaxSize, getBufferMaxSize(shader, glu::STORAGE_UNIFORM));
1837 retVal.numUniformBlocks += getNumShaderBlocks(shader, glu::STORAGE_UNIFORM);
1839 switch (shader->getType())
1841 case glu::SHADERTYPE_VERTEX: retVal.numCombinedVertexUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1842 case glu::SHADERTYPE_FRAGMENT: retVal.numCombinedFragmentUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1843 case glu::SHADERTYPE_GEOMETRY: retVal.numCombinedGeometryUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1844 case glu::SHADERTYPE_TESSELLATION_CONTROL: retVal.numCombinedTessControlUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1845 case glu::SHADERTYPE_TESSELLATION_EVALUATION: retVal.numCombinedTessEvalUniformComponents += getNumComponents(shader, glu::STORAGE_UNIFORM); break;
1849 retVal.shaderStorageBufferMaxBinding = de::max(retVal.shaderStorageBufferMaxBinding, getMaxBufferBinding(shader, glu::STORAGE_BUFFER));
1850 retVal.shaderStorageBufferMaxSize = de::max(retVal.shaderStorageBufferMaxSize, getBufferMaxSize(shader, glu::STORAGE_BUFFER));
1851 retVal.numShaderStorageBlocks += getNumShaderBlocks(shader, glu::STORAGE_BUFFER);
1853 if (shader->getType() == glu::SHADERTYPE_VERTEX)
1855 numVertexOutputComponents += getNumComponents(shader, glu::STORAGE_OUT);
1856 numVertexOutputVectors += getNumVectors(shader, glu::STORAGE_OUT);
1858 else if (shader->getType() == glu::SHADERTYPE_FRAGMENT)
1860 numFragmentInputComponents += getNumComponents(shader, glu::STORAGE_IN);
1861 numFragmentInputVectors += getNumVectors(shader, glu::STORAGE_IN);
1864 retVal.numCombinedSamplers += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeSampler);
1866 retVal.atomicCounterBufferMaxBinding = de::max(retVal.atomicCounterBufferMaxBinding, getAtomicCounterMaxBinding(shader));
1867 retVal.atomicCounterBufferMaxSize = de::max(retVal.atomicCounterBufferMaxSize, getAtomicCounterMaxBufferSize(shader));
1868 shader);
1869 retVal.numAtomicCounters += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeAtomicCounter);
1870 retVal.maxImageBinding = de::max(retVal.maxImageBinding, getUniformMaxBinding(shader, glu::isDataTypeImage));
1871 retVal.numCombinedImages += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeImage);
1873 retVal.numCombinedOutputResources += getNumTypeInstances(shader, glu::STORAGE_UNIFORM, glu::isDataTypeImage);
1874 retVal.numCombinedOutputResources += getNumShaderBlocks(shader, glu::STORAGE_BUFFER);
1876 if (shader->getType() == glu::SHADERTYPE_FRAGMENT)
1878 retVal.numCombinedOutputResources += getNumVectors(shader, glu::STORAGE_OUT);
1879 retVal.fragmentOutputMaxBinding = de::max(retVal.fragmentOutputMaxBinding, getFragmentOutputMaxLocation(shader));