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>
36PXR_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);
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;
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<
184 SdfPath, _GeneratedPrimEntry, SdfPath::Hash>;
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;
257PXR_NAMESPACE_CLOSE_SCOPE
HdGpGenerativeProcedural is the base class for procedurals which have full access to an input scene i...
HdGpGenerativeProceduralResolvingSceneIndex is a scene index which evaluates prims representing gener...
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
SATISFYING HdSingleInputFilteringSceneIndexBase ///////////////////////.
HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
SATISFYING HdSceneIndexBase ///////////////////////////////////////////.
SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
void _SystemMessage(const TfToken &messageType, const HdDataSourceBaseHandle &args) override
Implement in order to react directly to system messages sent from downstream.
Abstract interface to scene data.
A path value used to locate objects in layers or scenegraphs.
This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when...
This is a space efficient container that mimics the TfHashSet API that uses a vector for storage when...
Token for efficient comparison, assignment, and hashing of known strings.
Enable a concrete base class for use with TfWeakPtr.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Small struct representing a 'prim' in the Hydra scene index.