7 #ifndef PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H 8 #define PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H 11 #include "pxr/imaging/hdGp/api.h" 12 #include "pxr/imaging/hdGp/generativeProcedural.h" 14 #include "pxr/imaging/hd/filteringSceneIndex.h" 16 #include <tbb/concurrent_unordered_map.h> 18 #include <unordered_map> 19 #include <unordered_set> 21 PXR_NAMESPACE_OPEN_SCOPE
51 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
52 const HdSceneIndexBaseRefPtr &inputScene) {
53 return TfCreateRefPtr(
57 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
58 const HdSceneIndexBaseRefPtr &inputScene,
59 const TfToken &targetPrimTypeName) {
60 return TfCreateRefPtr(
62 inputScene, targetPrimTypeName));
77 const HdSceneIndexBaseRefPtr &inputScene);
81 const HdSceneIndexBaseRefPtr &inputScene,
82 const TfToken &targetPrimTypeName);
102 const HdDataSourceBaseHandle &args)
override;
114 static void _CombinePathArrays(
const _DensePathSet &s, SdfPathVector *v);
119 enum State :
unsigned char {
121 StateDependenciesCooking,
122 StateDependenciesCooked,
130 std::atomic<State> state;
132 std::shared_ptr<HdGpGenerativeProcedural> proc;
135 _PathSetMap childHierarchy;
136 std::mutex cookMutex;
140 : state(StateUncooked)
143 _ProcEntry(
const _ProcEntry &rhs)
145 state.store(rhs.state.load());
147 typeName = rhs.typeName;
148 childTypes = rhs.childTypes;
149 dependencies = rhs.dependencies;
150 childHierarchy = rhs.childHierarchy;
154 TF_DECLARE_WEAK_PTRS(_ProcEntry);
156 struct _GeneratedPrimEntry
158 _GeneratedPrimEntry()
159 : responsibleProc(
nullptr)
162 _GeneratedPrimEntry(_ProcEntry * p)
166 _GeneratedPrimEntry(
const _GeneratedPrimEntry &rhs)
168 responsibleProc.store(rhs.responsibleProc.load());
170 std::atomic<_ProcEntry *> responsibleProc;
173 using _GeneratedPrimsMap = tbb::concurrent_unordered_map<
174 SdfPath, _GeneratedPrimEntry, SdfPath::Hash>;
176 using _ProcEntryMap =
177 std::unordered_map<SdfPath, _ProcEntry, TfHash>;
179 using _WeakProcEntryMap =
180 tbb::concurrent_unordered_map<SdfPath, _ProcEntryPtr, TfHash>;
182 using _PathSet = std::unordered_set<SdfPath, TfHash>;
184 using _DependencyMap =
185 std::unordered_map<SdfPath, _PathSet, SdfPath::Hash>;
196 _ProcEntry * _UpdateProceduralDependencies(
197 const SdfPath &proceduralPrimPath,
198 _Notices* outputNotices)
const;
200 _ProcEntry * _UpdateProcedural(
201 const SdfPath &proceduralPrimPath,
203 _Notices *outputNotices,
205 *dirtiedDependencies =
nullptr 209 void _UpdateProceduralResult(
210 _ProcEntry *procEntry,
211 const SdfPath &proceduralPrimPath,
213 _Notices *outputNotices)
const;
216 void _RemoveProcedural(
217 const SdfPath &proceduralPrimPath,
218 _Notices *outputNotices=
nullptr)
const;
224 void _GarbageCollect();
228 mutable _ProcEntryMap _procedurals;
230 mutable _WeakProcEntryMap _activeSyncProcedurals;
233 mutable _DependencyMap _dependencies;
235 mutable _GeneratedPrimsMap _generatedPrims;
238 using _MapMutex = std::mutex;
239 using _MapLock = std::lock_guard<_MapMutex>;
240 mutable _MapMutex _dependenciesMutex;
241 mutable _MapMutex _proceduralsMutex;
243 const TfToken _targetPrimTypeName;
248 PXR_NAMESPACE_CLOSE_SCOPE
void _SystemMessage(const TfToken &messageType, const HdDataSourceBaseHandle &args) override
Implement in order to react directly to system messages sent from downstream.
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
SATISFYING HdSingleInputFilteringSceneIndexBase ///////////////////////.
Small struct representing a 'prim' in the Hydra scene index.
Token for efficient comparison, assignment, and hashing of known strings.
HdGpGenerativeProcedural is the base class for procedurals which have full access to an input scene i...
Abstract interface to scene data.
A path value used to locate objects in layers or scenegraphs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
HDGP_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
A hash set with contiguous storage, suitable for use with TfSpan, e.g.
Enable a concrete base class for use with TfWeakPtr.
HdGpGenerativeProceduralResolvingSceneIndex is a scene index which evaluates prims representing gener...
HDGP_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
SATISFYING HdSceneIndexBase ///////////////////////////////////////////.