7 #ifndef PXR_IMAGING_HD_DEPENDENCY_FORWARDING_SCENE_INDEX_H
8 #define PXR_IMAGING_HD_DEPENDENCY_FORWARDING_SCENE_INDEX_H
15 #include <tbb/concurrent_unordered_map.h>
16 #include <tbb/concurrent_unordered_set.h>
17 #include <tbb/concurrent_vector.h>
32 static HdDependencyForwardingSceneIndexRefPtr
New(
33 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()) {}
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 _UpdateDependencies(
222 void _ResetDependencies();
242 inline bool operator==(_VisitedNode
const &rhs)
const noexcept
244 return primPath == rhs.primPath && locator == rhs.locator;
247 template <
class HashState>
248 friend void TfHashAppend(HashState &
h, _VisitedNode
const &myObj) {
249 h.Append(myObj.primPath);
250 h.Append(myObj.locator);
253 inline size_t Hash()
const;
261 using _VisitedNodeSet = tbb::concurrent_unordered_set<
263 _VisitedNode::HashFunctor>;
265 using _AdditionalDirtiedVector =
266 tbb::concurrent_vector<HdSceneIndexObserver::DirtiedPrimEntry>;
273 _VisitedNodeSet *visited,
274 _AdditionalDirtiedVector *moreDirtiedEntries,
275 _PathSet *rebuildDependencies);
281 mutable _PathSet _potentiallyDeletedDependedOnPaths;
288 mutable _PathSet _potentiallyDeletedAffectedPaths;
302 bool _manualGarbageCollect;
TfRefPtr< T > TfCreateRefPtr(T *ptr)
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
void TfHashAppend(HashState &h, const T &ptr)
HD_API void SetManualGarbageCollect(bool manualGarbageCollect)
STATIC_INLINE size_t Hash(const char *s, size_t len)
TfRefBase & operator=(TfRefBase const &)
#define PXR_NAMESPACE_OPEN_SCOPE
HD_API HdDependencyForwardingSceneIndex(HdSceneIndexBaseRefPtr inputScene)
Functor to use for hash maps from tokens to other things.
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
size_t operator()(_VisitedNode const &node) const
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
HD_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
std::vector< class SdfPath > SdfPathVector
HD_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
GLfloat GLfloat GLfloat GLfloat h
TF_DECLARE_REF_PTRS(HdDependencyForwardingSceneIndex)
#define PXR_NAMESPACE_CLOSE_SCOPE
HD_API void RemoveDeletedEntries(SdfPathVector *removedAffectedPrimPaths=nullptr, SdfPathVector *removedDependedOnPrimPaths=nullptr)
static HdDependencyForwardingSceneIndexRefPtr New(HdSceneIndexBaseRefPtr inputScene)
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override