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> 32 #include <unordered_map> 33 #include <unordered_set> 35 PXR_NAMESPACE_OPEN_SCOPE
66 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
67 const HdSceneIndexBaseRefPtr &inputScene) {
68 return TfCreateRefPtr(
72 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
73 const HdSceneIndexBaseRefPtr &inputScene,
74 const TfToken &targetPrimTypeName) {
75 return TfCreateRefPtr(
77 inputScene, targetPrimTypeName));
88 const HdSceneIndexBaseRefPtr &inputScene);
91 const HdSceneIndexBaseRefPtr &inputScene,
92 const TfToken &targetPrimTypeName);
120 enum State :
unsigned char {
122 StateDependenciesCooking,
123 StateDependenciesCooked,
131 std::atomic<State> state;
133 std::shared_ptr<HdGpGenerativeProcedural> proc;
136 _PathSetMap childHierarchy;
137 std::mutex cookMutex;
141 : state(StateUncooked)
144 _ProcEntry(
const _ProcEntry &rhs)
146 state.store(rhs.state.load());
148 typeName = rhs.typeName;
149 childTypes = rhs.childTypes;
150 dependencies = rhs.dependencies;
151 childHierarchy = rhs.childHierarchy;
155 struct _GeneratedPrimEntry
157 _GeneratedPrimEntry()
158 : responsibleProc(
nullptr)
161 _GeneratedPrimEntry(_ProcEntry * p)
165 _GeneratedPrimEntry(
const _GeneratedPrimEntry &rhs)
167 responsibleProc.store(rhs.responsibleProc.load());
169 std::atomic<_ProcEntry *> responsibleProc;
172 using _GeneratedPrimsMap = tbb::concurrent_unordered_map<
173 SdfPath, _GeneratedPrimEntry, SdfPath::Hash>;
175 using _ProcEntryMap =
176 std::unordered_map<SdfPath, _ProcEntry, TfHash>;
178 using _PathSet = std::unordered_set<SdfPath, TfHash>;
180 using _DependencyMap =
181 std::unordered_map<SdfPath, _PathSet, SdfPath::Hash>;
192 _ProcEntry * _UpdateProceduralDependencies(
193 const SdfPath &proceduralPrimPath)
const;
195 _ProcEntry * _UpdateProcedural(
196 const SdfPath &proceduralPrimPath,
198 _Notices *outputNotices,
200 *dirtiedDependencies =
nullptr 203 void _RemoveProcedural(
204 const SdfPath &proceduralPrimPath,
205 _Notices *outputNotices=
nullptr)
const;
211 void _GarbageCollect();
215 mutable _ProcEntryMap _procedurals;
218 mutable _DependencyMap _dependencies;
220 mutable _GeneratedPrimsMap _generatedPrims;
223 using _MapMutex = std::mutex;
224 using _MapLock = std::lock_guard<_MapMutex>;
225 mutable _MapMutex _dependenciesMutex;
226 mutable _MapMutex _proceduralsMutex;
231 PXR_NAMESPACE_CLOSE_SCOPE
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
SATISFYING HdSingleInputFilteringSceneIndexBase ///////////////////////.
A user-extensible hashing mechanism for use with runtime hash tables.
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.
This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when...
A path value used to locate objects in layers or scenegraphs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
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.