7#ifndef PXR_IMAGING_HD_DEPENDENCY_FORWARDING_SCENE_INDEX_H
8#define PXR_IMAGING_HD_DEPENDENCY_FORWARDING_SCENE_INDEX_H
12#include "pxr/imaging/hd/api.h"
13#include "pxr/imaging/hd/filteringSceneIndex.h"
15#include <tbb/concurrent_unordered_map.h>
16#include <tbb/concurrent_unordered_set.h>
17#include <tbb/concurrent_vector.h>
21PXR_NAMESPACE_OPEN_SCOPE
23class HdDependencyForwardingSceneIndex;
27class HdDependencyForwardingSceneIndex
32 static HdDependencyForwardingSceneIndexRefPtr New(
33 HdSceneIndexBaseRefPtr inputScene) {
34 return TfCreateRefPtr(
35 new HdDependencyForwardingSceneIndex(inputScene));
50 void SetManualGarbageCollect(
bool manualGarbageCollect);
54 HdDependencyForwardingSceneIndex(HdSceneIndexBaseRefPtr inputScene);
102 using _LocatorsEntryMap = tbb::concurrent_unordered_map<
108 struct _AffectedPrimDependencyEntry
115 _AffectedPrimDependencyEntry()
116 : locatorsEntryMap(), flaggedForDeletion(false) {}
117 _AffectedPrimDependencyEntry(
const _AffectedPrimDependencyEntry &rhs)
118 : locatorsEntryMap(rhs.locatorsEntryMap)
119 , flaggedForDeletion(rhs.flaggedForDeletion.load()) {}
120 _AffectedPrimDependencyEntry(_AffectedPrimDependencyEntry &&rhs)
121 : locatorsEntryMap(
std::move(rhs.locatorsEntryMap))
122 , flaggedForDeletion(rhs.flaggedForDeletion.load()) {}
123 _AffectedPrimDependencyEntry& operator=(
124 const _AffectedPrimDependencyEntry& rhs) {
126 locatorsEntryMap = rhs.locatorsEntryMap;
127 flaggedForDeletion = rhs.flaggedForDeletion.load();
132 _LocatorsEntryMap locatorsEntryMap;
133 std::atomic_bool flaggedForDeletion;
138 using _AffectedPrimsDependencyMap = tbb::concurrent_unordered_map<
140 _AffectedPrimDependencyEntry,
145 using _DependedOnPrimsAffectedPrimsMap = tbb::concurrent_unordered_map<
147 _AffectedPrimsDependencyMap,
165 mutable _DependedOnPrimsAffectedPrimsMap _dependedOnPrimToDependentsMap;
170 using _PathSet = tbb::concurrent_unordered_set<SdfPath, SdfPath::Hash>;
172 struct _AffectedPrimToDependsOnPathsEntry
177 _AffectedPrimToDependsOnPathsEntry()
178 : dependsOnPaths(), flaggedForDeletion(false) {}
179 _AffectedPrimToDependsOnPathsEntry(
180 const _AffectedPrimToDependsOnPathsEntry &rhs)
181 : dependsOnPaths(rhs.dependsOnPaths)
182 , flaggedForDeletion(rhs.flaggedForDeletion.load()) {}
183 _AffectedPrimToDependsOnPathsEntry(
184 _AffectedPrimToDependsOnPathsEntry &&rhs)
185 : dependsOnPaths(
std::move(rhs.dependsOnPaths))
186 , flaggedForDeletion(rhs.flaggedForDeletion.load()) {}
187 _AffectedPrimToDependsOnPathsEntry& operator=(
188 const _AffectedPrimToDependsOnPathsEntry& rhs) {
190 dependsOnPaths = rhs.dependsOnPaths;
191 flaggedForDeletion = rhs.flaggedForDeletion.load();
196 _PathSet dependsOnPaths;
197 std::atomic_bool flaggedForDeletion;
201 using _AffectedPrimToDependsOnPathsEntryMap = tbb::concurrent_unordered_map<
203 _AffectedPrimToDependsOnPathsEntry,
212 mutable _AffectedPrimToDependsOnPathsEntryMap
213 _affectedPrimToDependsOnPathsMap;
217 void _ClearDependencies(
const SdfPath &primPath);
218 void _UpdateDependencies(
const SdfPath &primPath)
const;
219 void _ResetDependencies();
239 inline bool operator==(_VisitedNode
const &rhs)
const noexcept
241 return primPath == rhs.primPath && locator == rhs.locator;
244 template <
class HashState>
245 friend void TfHashAppend(HashState &h, _VisitedNode
const &myObj) {
246 h.Append(myObj.primPath);
247 h.Append(myObj.locator);
250 inline size_t Hash()
const;
252 size_t operator()(_VisitedNode
const &node)
const {
258 using _VisitedNodeSet = tbb::concurrent_unordered_set<
260 _VisitedNode::HashFunctor>;
262 using _AdditionalDirtiedVector =
263 tbb::concurrent_vector<HdSceneIndexObserver::DirtiedPrimEntry>;
270 _VisitedNodeSet *visited,
271 _AdditionalDirtiedVector *moreDirtiedEntries,
272 _PathSet *rebuildDependencies);
278 mutable _PathSet _potentiallyDeletedDependedOnPaths;
285 mutable _PathSet _potentiallyDeletedAffectedPaths;
294 void RemoveDeletedEntries(
295 SdfPathVector *removedAffectedPrimPaths =
nullptr,
296 SdfPathVector *removedDependedOnPrimPaths =
nullptr);
299 bool _manualGarbageCollect;
304HdDependencyForwardingSceneIndex::_VisitedNode::Hash()
const
309PXR_NAMESPACE_CLOSE_SCOPE
Represents an object that can identify the location of a data source.
Represents a set of data source locators closed under descendancy.
Abstract interface to scene data.
virtual SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const =0
Returns the paths of all scene index prims located immediately below primPath.
virtual HdSceneIndexPrim GetPrim(const SdfPath &primPath) const =0
Returns a pair of (prim type, datasource).
A path value used to locate objects in layers or scenegraphs.
A user-extensible hashing mechanism for use with runtime hash tables.
Token for efficient comparison, assignment, and hashing of known strings.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Small struct representing a 'prim' in the Hydra scene index.
Functor to use for hash maps from tokens to other things.