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;
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;