24 #ifndef PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H
25 #define PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H
31 #include <tbb/concurrent_unordered_map.h>
33 #include <unordered_map>
34 #include <unordered_set>
67 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr
New(
68 const HdSceneIndexBaseRefPtr &inputScene) {
73 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr
New(
74 const HdSceneIndexBaseRefPtr &inputScene,
75 const TfToken &targetPrimTypeName) {
78 inputScene, targetPrimTypeName));
89 const HdSceneIndexBaseRefPtr &inputScene);
92 const HdSceneIndexBaseRefPtr &inputScene,
93 const TfToken &targetPrimTypeName);
113 const HdDataSourceBaseHandle &
args)
override;
125 static void _CombinePathArrays(
const _DensePathSet &
s,
SdfPathVector *
v);
129 enum State :
unsigned char {
131 StateDependenciesCooking,
132 StateDependenciesCooked,
140 std::atomic<State> state;
142 std::shared_ptr<HdGpGenerativeProcedural> proc;
145 _PathSetMap childHierarchy;
146 std::mutex cookMutex;
150 : state(StateUncooked)
153 _ProcEntry(
const _ProcEntry &rhs)
155 state.store(rhs.state.load());
157 typeName = rhs.typeName;
158 childTypes = rhs.childTypes;
159 dependencies = rhs.dependencies;
160 childHierarchy = rhs.childHierarchy;
164 TF_DECLARE_WEAK_PTRS(_ProcEntry);
166 struct _GeneratedPrimEntry
168 _GeneratedPrimEntry()
169 : responsibleProc(nullptr)
172 _GeneratedPrimEntry(_ProcEntry * p)
176 _GeneratedPrimEntry(
const _GeneratedPrimEntry &rhs)
178 responsibleProc.store(rhs.responsibleProc.load());
180 std::atomic<_ProcEntry *> responsibleProc;
183 using _GeneratedPrimsMap = tbb::concurrent_unordered_map<
186 using _ProcEntryMap =
187 std::unordered_map<SdfPath, _ProcEntry, TfHash>;
189 using _WeakProcEntryMap =
190 tbb::concurrent_unordered_map<SdfPath, _ProcEntryPtr, TfHash>;
192 using _PathSet = std::unordered_set<SdfPath, TfHash>;
194 using _DependencyMap =
195 std::unordered_map<SdfPath, _PathSet, SdfPath::Hash>;
206 _ProcEntry * _UpdateProceduralDependencies(
207 const SdfPath &proceduralPrimPath)
const;
209 _ProcEntry * _UpdateProcedural(
210 const SdfPath &proceduralPrimPath,
212 _Notices *outputNotices,
214 *dirtiedDependencies =
nullptr
218 void _UpdateProceduralResult(
219 _ProcEntry *procEntry,
220 const SdfPath &proceduralPrimPath,
222 _Notices *outputNotices)
const;
225 void _RemoveProcedural(
226 const SdfPath &proceduralPrimPath,
227 _Notices *outputNotices=
nullptr)
const;
233 void _GarbageCollect();
237 mutable _ProcEntryMap _procedurals;
239 mutable _WeakProcEntryMap _activeSyncProcedurals;
242 mutable _DependencyMap _dependencies;
244 mutable _GeneratedPrimsMap _generatedPrims;
247 using _MapMutex = std::mutex;
248 using _MapLock = std::lock_guard<_MapMutex>;
249 mutable _MapMutex _dependenciesMutex;
250 mutable _MapMutex _proceduralsMutex;
HdGpGenerativeProceduralResolvingSceneIndex(const HdSceneIndexBaseRefPtr &inputScene)
TfRefPtr< T > TfCreateRefPtr(T *ptr)
TF_DECLARE_REF_PTRS(HdGpGenerativeProceduralResolvingSceneIndex)
static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputScene, const TfToken &targetPrimTypeName)
SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputScene)
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
SATISFYING HdSceneIndexBase ///////////////////////////////////////////.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
**If you just want to fire and args
void _SystemMessage(const TfToken &messageType, const HdDataSourceBaseHandle &args) override
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
SATISFYING HdSingleInputFilteringSceneIndexBase ///////////////////////.