24 #ifndef PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H 25 #define PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H 27 #include "pxr/imaging/hdGp/generativeProcedural.h" 28 #include "pxr/imaging/hd/filteringSceneIndex.h" 31 #include <tbb/concurrent_unordered_map.h> 33 #include <unordered_map> 34 #include <unordered_set> 36 PXR_NAMESPACE_OPEN_SCOPE
67 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
68 const HdSceneIndexBaseRefPtr &inputScene) {
69 return TfCreateRefPtr(
73 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
74 const HdSceneIndexBaseRefPtr &inputScene,
75 const TfToken &targetPrimTypeName) {
76 return TfCreateRefPtr(
78 inputScene, targetPrimTypeName));
89 const HdSceneIndexBaseRefPtr &inputScene);
92 const HdSceneIndexBaseRefPtr &inputScene,
93 const TfToken &targetPrimTypeName);
121 static void _CombinePathArrays(
const _DensePathSet &s, SdfPathVector *v);
125 enum State :
unsigned char {
127 StateDependenciesCooking,
128 StateDependenciesCooked,
136 std::atomic<State> state;
138 std::shared_ptr<HdGpGenerativeProcedural> proc;
141 _PathSetMap childHierarchy;
142 std::mutex cookMutex;
146 : state(StateUncooked)
149 _ProcEntry(
const _ProcEntry &rhs)
151 state.store(rhs.state.load());
153 typeName = rhs.typeName;
154 childTypes = rhs.childTypes;
155 dependencies = rhs.dependencies;
156 childHierarchy = rhs.childHierarchy;
160 struct _GeneratedPrimEntry
162 _GeneratedPrimEntry()
163 : responsibleProc(
nullptr)
166 _GeneratedPrimEntry(_ProcEntry * p)
170 _GeneratedPrimEntry(
const _GeneratedPrimEntry &rhs)
172 responsibleProc.store(rhs.responsibleProc.load());
174 std::atomic<_ProcEntry *> responsibleProc;
177 using _GeneratedPrimsMap = tbb::concurrent_unordered_map<
178 SdfPath, _GeneratedPrimEntry, SdfPath::Hash>;
180 using _ProcEntryMap =
181 std::unordered_map<SdfPath, _ProcEntry, TfHash>;
183 using _PathSet = std::unordered_set<SdfPath, TfHash>;
185 using _DependencyMap =
186 std::unordered_map<SdfPath, _PathSet, SdfPath::Hash>;
197 _ProcEntry * _UpdateProceduralDependencies(
198 const SdfPath &proceduralPrimPath)
const;
200 _ProcEntry * _UpdateProcedural(
201 const SdfPath &proceduralPrimPath,
203 _Notices *outputNotices,
205 *dirtiedDependencies =
nullptr 208 void _RemoveProcedural(
209 const SdfPath &proceduralPrimPath,
210 _Notices *outputNotices=
nullptr)
const;
216 void _GarbageCollect();
220 mutable _ProcEntryMap _procedurals;
223 mutable _DependencyMap _dependencies;
225 mutable _GeneratedPrimsMap _generatedPrims;
228 using _MapMutex = std::mutex;
229 using _MapLock = std::lock_guard<_MapMutex>;
230 mutable _MapMutex _dependenciesMutex;
231 mutable _MapMutex _proceduralsMutex;
236 PXR_NAMESPACE_CLOSE_SCOPE
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.
This is a space efficient container that mimics the TfHashSet API that uses a vector for storage when...
HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
SATISFYING HdSceneIndexBase ///////////////////////////////////////////.
HdGpGenerativeProceduralResolvingSceneIndex is a scene index which evaluates prims representing gener...
SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.