diff --git a/pxr/imaging/hd/dataSourceLegacyPrim.cpp b/pxr/imaging/hd/dataSourceLegacyPrim.cpp index 9bbffac763..1c0905a2fb 100644 --- a/pxr/imaging/hd/dataSourceLegacyPrim.cpp +++ b/pxr/imaging/hd/dataSourceLegacyPrim.cpp @@ -2534,16 +2534,21 @@ _ConvertHdMaterialNetworkToHdDataSources( } template -static bool -_ConvertRenderTerminalOutputNodeToHdDataSources( - const HdMaterialNode2 &hdNode, - HdContainerDataSourceHandle *result) +static HdContainerDataSourceHandle +_ConvertRenderTerminalOutputToHdDataSource(const VtValue &outputNodeValue) { HD_TRACE_FUNCTION(); + if (!outputNodeValue.IsHolding()) { + return nullptr; + } + + const HdMaterialNode2 outputNode = + outputNodeValue.UncheckedGet(); + std::vector paramsNames; std::vector paramsValues; - for (const auto &p : hdNode.parameters) { + for (const auto &p : outputNode.parameters) { paramsNames.push_back(p.first); paramsValues.push_back( HdRetainedTypedSampledDataSource::New(p.second) @@ -2557,12 +2562,10 @@ _ConvertRenderTerminalOutputNodeToHdDataSources( paramsValues.data()), HdRetainedContainerDataSource::New(), HdRetainedTypedSampledDataSource::New( - hdNode.nodeTypeId), + outputNode.nodeTypeId), nullptr /*renderContextNodeIdentifiers*/); - *result = SchemaType::BuildRetained(nodeDS); - - return true; + return SchemaType::BuildRetained(nodeDS); } HdDataSourceBaseHandle @@ -2696,18 +2699,8 @@ HdDataSourceLegacyPrim::_GetIntegratorDataSource() VtValue integratorValue = _sceneDelegate->Get( _id, HdIntegratorSchemaTokens->integratorResource); - if (!integratorValue.IsHolding()) { - return nullptr; - } - - HdMaterialNode2 integratorNode = - integratorValue.UncheckedGet(); - HdContainerDataSourceHandle integratorDS = nullptr; - if (!_ConvertRenderTerminalOutputNodeToHdDataSources( - integratorNode, &integratorDS)) { - return nullptr; - } - return integratorDS; + return _ConvertRenderTerminalOutputToHdDataSource( + integratorValue); } HdDataSourceBaseHandle @@ -2716,18 +2709,8 @@ HdDataSourceLegacyPrim::_GetSampleFilterDataSource() VtValue sampleFilterValue = _sceneDelegate->Get( _id, HdSampleFilterSchemaTokens->sampleFilterResource); - if (!sampleFilterValue.IsHolding()) { - return nullptr; - } - - HdMaterialNode2 sampleFilterNode = - sampleFilterValue.UncheckedGet(); - HdContainerDataSourceHandle sampleFilterDS = nullptr; - if (!_ConvertRenderTerminalOutputNodeToHdDataSources( - sampleFilterNode, &sampleFilterDS)) { - return nullptr; - } - return sampleFilterDS; + return _ConvertRenderTerminalOutputToHdDataSource( + sampleFilterValue); } HdDataSourceBaseHandle @@ -2736,18 +2719,8 @@ HdDataSourceLegacyPrim::_GetDisplayFilterDataSource() VtValue displayFilterValue = _sceneDelegate->Get( _id, HdDisplayFilterSchemaTokens->displayFilterResource); - if (!displayFilterValue.IsHolding()) { - return nullptr; - } - - HdMaterialNode2 displayFilterNode = - displayFilterValue.UncheckedGet(); - HdContainerDataSourceHandle displayFilterDS = nullptr; - if (!_ConvertRenderTerminalOutputNodeToHdDataSources( - displayFilterNode, &displayFilterDS)) { - return nullptr; - } - return displayFilterDS; + return _ConvertRenderTerminalOutputToHdDataSource( + displayFilterValue); } HdDataSourceBaseHandle