Redraw of HdStVolume when volume hasn't changed doesn't trigger HdSt_RenderPass::_Execute()

Hello all,

I’m seeing a bug in storm when viewing a volume from a Katana node, switching to another node and re-switching back to the first volume node, the volume isn’t rendered.

I’ve attached a debugger and breakpoints to narrow down the issue, so here’s a report of what I have found:

HdSt_RenderPass stops drawing a volume after its HdStVolume Rprim is destroyed and recreated at the same SdfPath, because the material-tag reference count never gets
re-incremented.

HdxRenderTask::Execute() in pxr/imaging/hdx/renderTask.cpp contains an optimization
that skips calling into the render pass when there is believed to be no rendering
work to do:

if (HdStRenderPassState* extendedState =
dynamic_cast<HdStRenderPassState*>(renderPassState.get())) {
// Bail out early for Storm tasks that have no rendering work to submit
// and don't need to clear AOVs.
if (!_HasDrawItems() && !_NeedToClearAovs(renderPassState)) {
return;
}
_SetHdStRenderPassState(ctx, extendedState);
}
if (_pass) {
_pass->Execute(renderPassState, GetRenderTags());
}

_HasDrawItems() (same file) delegates to HdSt_RenderPass::HasDrawItems()
(pxr/imaging/hdSt/renderPass.cpp):

bool
HdSt_RenderPass::HasDrawItems(TfTokenVector const &renderTags) const
{
const HdStRenderParam * const renderParam = ...;
return renderParam->HasMaterialTag(GetRprimCollection().GetMaterialTag()) &&
(renderTags.empty() || renderParam->HasAnyRenderTag(renderTags));
}

HdStRenderParam::HasMaterialTag()/HasAnyRenderTag() (pxr/imaging/hdSt/renderParam.cpp)
are backed by a reference count per material tag / render tag (_materialTagToCount / _renderTagToCount), NOT by actually querying the render index for matching Rprims. The count is:

  • incremented in HdStSetMaterialTag() (pxr/imaging/hdSt/primUtils.cpp), called from
    HdStVolume::Sync() (pxr/imaging/hdSt/volume.cpp) only when DirtyMaterialId is set
    on the Rprim.

  • decremented in HdStVolume::Finalize() (pxr/imaging/hdSt/volume.cpp), called when
    the Rprim is destroyed:

    void HdStVolume::Finalize(HdRenderParam *renderParam) {
    HdStMarkGarbageCollectionNeeded(renderParam);
    HdStRenderParam * const stRenderParam = ...;
    stRenderParam->DecreaseMaterialTagCount(HdStMaterialTagTokens->volume);
    stRenderParam->DecreaseRenderTagCount(GetRenderTag());
    }

In the reproduced scenario, the full remove-then-re-add cycle destroys the old HdStVolume
(Finalize() decrements the count) and constructs a new HdStVolume at the same SdfPath.
The new instance’s Sync() was observed to run with DirtyMaterialId set and HdStSetMaterialTag() is reached but after this point,
HasMaterialTag()/ HasAnyRenderTag() still appear to report false for the render pass’s
collection/render-tags, since HdSt_RenderPass::_Execute() is never invoked again afterward.

How can we solve this from our end ?

Fanny

Forgot to mention we’re on openusd 25.08.