MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / finalize

Method finalize

source/MaterialXGenShader/ShaderGraph.cpp:882–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

880}
881
882void ShaderGraph::finalize(GenContext& context)
883{
884 // Allow node implementations to update the classification
885 // on its node instances
886 for (ShaderNode* node : getNodes())
887 {
888 node->getImplementation().addClassification(*node);
889 }
890
891 // Add classification according to root node
892 ShaderGraphOutputSocket* outputSocket = getOutputSocket();
893 if (outputSocket->getConnection())
894 {
895 addClassification(outputSocket->getConnection()->getNode()->getClassification());
896 }
897
898 // Insert color transformation nodes where needed
899 if (context.getOptions().emitColorTransforms)
900 {
901 for (const auto& it : _inputColorTransformMap)
902 {
903 addColorTransformNode(it.first, it.second, context);
904 }
905 for (const auto& it : _outputColorTransformMap)
906 {
907 addColorTransformNode(it.first, it.second, context);
908 }
909 }
910 _inputColorTransformMap.clear();
911 _outputColorTransformMap.clear();
912
913 // Insert unit transformation nodes where needed
914 for (const auto& it : _inputUnitTransformMap)
915 {
916 addUnitTransformNode(it.first, it.second, context);
917 }
918 for (const auto& it : _outputUnitTransformMap)
919 {
920 addUnitTransformNode(it.first, it.second, context);
921 }
922 _inputUnitTransformMap.clear();
923 _outputUnitTransformMap.clear();
924
925 // Run registered graph refactoring passes.
926 size_t totalEdits = 0;
927 for (auto& refactor : context.getShaderGenerator().getRefactors())
928 {
929 totalEdits += refactor->execute(*this, context);
930 }
931
932 // Remove unused nodes if any refactoring pass made edits.
933 if (totalEdits > 0)
934 {
935 removeUnusedNodes();
936 }
937
938 // Sort the nodes in topological order.
939 topologicalSort();

Callers 1

createMethod · 0.45

Calls 15

getNodesFunction · 0.85
getOutputSocketFunction · 0.85
addClassificationFunction · 0.85
getInputSocketFunction · 0.85
addInputSocketFunction · 0.85
setColorSpaceMethod · 0.80
makeConnectionMethod · 0.80
addClassificationMethod · 0.45
getImplementationMethod · 0.45
getNodeMethod · 0.45
clearMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected