7#ifndef PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H
8#define PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_RESOLVING_SCENE_INDEX_H
10#include "pxr/imaging/hdGp/generativeProcedural.h"
11#include "pxr/imaging/hd/filteringSceneIndex.h"
14#include <tbb/concurrent_unordered_map.h>
16#include <unordered_map>
17#include <unordered_set>
19PXR_NAMESPACE_OPEN_SCOPE
50 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
51 const HdSceneIndexBaseRefPtr &inputScene) {
52 return TfCreateRefPtr(
56 static HdGpGenerativeProceduralResolvingSceneIndexRefPtr New(
57 const HdSceneIndexBaseRefPtr &inputScene,
58 const TfToken &targetPrimTypeName) {
59 return TfCreateRefPtr(
61 inputScene, targetPrimTypeName));
72 const HdSceneIndexBaseRefPtr &inputScene);
75 const HdSceneIndexBaseRefPtr &inputScene,
76 const TfToken &targetPrimTypeName);
96 const HdDataSourceBaseHandle &args)
override;
108 static void _CombinePathArrays(
const _DensePathSet &s, SdfPathVector *v);
113 enum State :
unsigned char {
115 StateDependenciesCooking,
116 StateDependenciesCooked,
124 std::atomic<State> state;
126 std::shared_ptr<HdGpGenerativeProcedural> proc;
129 _PathSetMap childHierarchy;
130 std::mutex cookMutex;
134 : state(StateUncooked)
137 _ProcEntry(
const _ProcEntry &rhs)
139 state.store(rhs.state.load());
141 typeName = rhs.typeName;
142 childTypes = rhs.childTypes;
143 dependencies = rhs.dependencies;
144 childHierarchy = rhs.childHierarchy;
150 struct _GeneratedPrimEntry
152 _GeneratedPrimEntry()
153 : responsibleProc(nullptr)
156 _GeneratedPrimEntry(_ProcEntry * p)
160 _GeneratedPrimEntry(
const _GeneratedPrimEntry &rhs)
162 responsibleProc.store(rhs.responsibleProc.load());
164 std::atomic<_ProcEntry *> responsibleProc;
167 using _GeneratedPrimsMap = tbb::concurrent_unordered_map<
168 SdfPath, _GeneratedPrimEntry, SdfPath::Hash>;
170 using _ProcEntryMap =
171 std::unordered_map<SdfPath, _ProcEntry, TfHash>;
173 using _WeakProcEntryMap =
174 tbb::concurrent_unordered_map<SdfPath, _ProcEntryPtr, TfHash>;
176 using _PathSet = std::unordered_set<SdfPath, TfHash>;
178 using _DependencyMap =
179 std::unordered_map<SdfPath, _PathSet, SdfPath::Hash>;
190 _ProcEntry * _UpdateProceduralDependencies(
191 const SdfPath &proceduralPrimPath)
const;
193 _ProcEntry * _UpdateProcedural(
194 const SdfPath &proceduralPrimPath,
196 _Notices *outputNotices,
198 *dirtiedDependencies =
nullptr
202 void _UpdateProceduralResult(
203 _ProcEntry *procEntry,
204 const SdfPath &proceduralPrimPath,
206 _Notices *outputNotices)
const;
209 void _RemoveProcedural(
210 const SdfPath &proceduralPrimPath,
211 _Notices *outputNotices=
nullptr)
const;
217 void _GarbageCollect();
221 mutable _ProcEntryMap _procedurals;
223 mutable _WeakProcEntryMap _activeSyncProcedurals;
226 mutable _DependencyMap _dependencies;
228 mutable _GeneratedPrimsMap _generatedPrims;
231 using _MapMutex = std::mutex;
232 using _MapLock = std::lock_guard<_MapMutex>;
233 mutable _MapMutex _dependenciesMutex;
234 mutable _MapMutex _proceduralsMutex;
241PXR_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.