From 29f28a37c09650b382cff5afb53e3f88568bc036 Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Mon, 6 Jan 2025 14:20:48 -0500 Subject: [PATCH] MAYA-136105 - Optimize MaterialX 1.38.5 Recent changes from #4055 makes me believe the issues I had previously with MaterialX 1.38.5 are now fixed. Re-enabling lobe pruning across all MaterialX versions. --- .../render/vp2RenderDelegate/material.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/material.cpp b/lib/mayaUsd/render/vp2RenderDelegate/material.cpp index 90c0aa5bd..1e55ce209 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/material.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/material.cpp @@ -65,12 +65,10 @@ #ifdef WANT_MATERIALX_BUILD #include +#include #include #include #include -#if MX_COMBINED_VERSION >= 13808 -#include -#endif #include #include @@ -356,7 +354,6 @@ struct _MaterialXData static const std::string env = TfGetenv("USDMTLX_PRIMARY_UV_NAME"); _mainUvSetName = env.empty() ? UsdUtilsGetPrimaryUVSetName().GetString() : env; -#if MX_COMBINED_VERSION >= 13808 _lobePruner = MaterialXMaya::ShaderGenUtil::LobePruner::create(); _lobePruner->setLibrary(_mtlxLibrary); _lobePruner->optimizeLibrary(_mtlxLibrary); @@ -370,7 +367,6 @@ struct _MaterialXData // NodeGraph boundary, then no optimization will be found. This would require a change // in the LobePruner to detect transitive weights. Doable, but complex. We will wait // until there is sufficient demand. -#endif } catch (mx::Exception& e) { TF_RUNTIME_ERROR( "Caught exception '%s' while initializing MaterialX library", e.what()); @@ -379,9 +375,7 @@ struct _MaterialXData MaterialX::FileSearchPath _mtlxSearchPath; //!< MaterialX library search path MaterialX::DocumentPtr _mtlxLibrary; //!< MaterialX library std::string _mainUvSetName; //!< Main UV set name -#if MX_COMBINED_VERSION >= 13808 MaterialXMaya::ShaderGenUtil::LobePruner::Ptr _lobePruner; -#endif private: void _FixLibraryTangentInputs(MaterialX::DocumentPtr& mtlxLibrary); @@ -483,16 +477,12 @@ size_t _GenerateNetwork2TopoHash(const HdMaterialNetwork2& materialNetwork) MayaUsd::hash_combine(topoHash, hash_value(nodePair.first)); const auto& node = nodePair.second; -#if MX_COMBINED_VERSION >= 13808 - TfToken optimizedNodeId = _GetMaterialXData()._lobePruner->getOptimizedNodeId(node); + TfToken optimizedNodeId = _GetMaterialXData()._lobePruner->getOptimizedNodeId(node); if (optimizedNodeId.IsEmpty()) { MayaUsd::hash_combine(topoHash, hash_value(node.nodeTypeId)); } else { MayaUsd::hash_combine(topoHash, hash_value(optimizedNodeId)); } -#else - MayaUsd::hash_combine(topoHash, hash_value(node.nodeTypeId)); -#endif if (_IsTopologicalNode(node)) { // We need to capture values that affect topology: for (auto const& p : node.parameters) { @@ -2912,16 +2902,12 @@ void HdVP2Material::CompiledNetwork::_ApplyMtlxVP2Fixes( for (const auto& nodePair : inNet.nodes) { const HdMaterialNode2& inNode = nodePair.second; HdMaterialNode2 outNode; -#if MX_COMBINED_VERSION >= 13808 TfToken optimizedNodeId = _GetMaterialXData()._lobePruner->getOptimizedNodeId(inNode); if (optimizedNodeId.IsEmpty()) { outNode.nodeTypeId = inNode.nodeTypeId; } else { outNode.nodeTypeId = optimizedNodeId; } -#else - outNode.nodeTypeId = inNode.nodeTypeId; -#endif if (_IsTopologicalNode(inNode)) { // These parameters affect topology: outNode.parameters = inNode.parameters;