Skip to content

Commit

Permalink
HdFlatteningSceneIndex: fixing a correctness issue where we re-fetch …
Browse files Browse the repository at this point in the history
…the prim data source when we get the empty data source locator. Also using Work's swap and destroy call for potential performance improvement.

(Internal change: 2281853)
  • Loading branch information
unhyperbolic authored and pixar-oss committed Jun 20, 2023
1 parent 1669509 commit 9222cec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 15 additions & 10 deletions pxr/imaging/hd/flatteningSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ HdFlatteningSceneIndex::GetPrim(const SdfPath &primPath) const
{
// Check the hierarchy cache
{
_PrimTable::const_iterator i = _prims.find(primPath);
const _PrimTable::const_iterator i = _prims.find(primPath);
// SdfPathTable will default-construct entries for ancestors
// as needed to represent hierarchy, so double-check the
// dataSource to confirm presence of a cached prim
Expand Down Expand Up @@ -300,9 +300,9 @@ HdFlatteningSceneIndex::_PrimsAdded(
// Clear out any cached dataSources for prims that have been re-added.
// They will get updated dataSources in the next call to GetPrim().
for (const HdSceneIndexObserver::AddedPrimEntry &entry : entries) {
_PrimTable::iterator i = _prims.find(entry.primPath);
const _PrimTable::iterator i = _prims.find(entry.primPath);
if (i != _prims.end()) {
i->second.dataSource.reset();
WorkSwapDestroyAsync(i->second.dataSource);
}
}

Expand Down Expand Up @@ -383,6 +383,18 @@ HdFlatteningSceneIndex::_PrimsDirtied(
if (!locators.IsEmpty()) {
_DirtyHierarchy(entry.primPath, locators, &dirtyEntries);
}

// Empty locator indicates that we need to pull the input data source
// again - which we achieve by destroying the data source wrapping the
// input data source.
// Note that we destroy it after calling _DirtyHierarchy to not prevent
// _DirtyHierarchy propagating the invalidation to the ancestors.
if (entry.dirtyLocators.Contains(HdDataSourceLocator::EmptyLocator())) {
const _PrimTable::iterator it = _prims.find(entry.primPath);
if (it != _prims.end() && it->second.dataSource) {
WorkSwapDestroyAsync(it->second.dataSource);
}
}
}

_SendPrimsDirtied(entries);
Expand Down Expand Up @@ -449,13 +461,6 @@ _PrimLevelWrappingDataSource::_PrimLevelWrappingDataSource(
{
}

void
HdFlatteningSceneIndex::_PrimLevelWrappingDataSource::UpdateInputDataSource(
HdContainerDataSourceHandle inputDataSource)
{
_inputDataSource = inputDataSource;
}

bool
HdFlatteningSceneIndex::_PrimLevelWrappingDataSource::PrimDirtied(
const HdDataSourceLocatorSet &set)
Expand Down
2 changes: 0 additions & 2 deletions pxr/imaging/hd/flatteningSceneIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ class HdFlatteningSceneIndex : public HdSingleInputFilteringSceneIndexBase
const SdfPath &primPath,
HdContainerDataSourceHandle inputDataSource);

void UpdateInputDataSource(HdContainerDataSourceHandle inputDataSource);

bool PrimDirtied(const HdDataSourceLocatorSet &locators);

TfTokenVector GetNames() override;
Expand Down

0 comments on commit 9222cec

Please sign in to comment.