7 #ifndef PXR_IMAGING_HD_RENDER_INDEX_H
8 #define PXR_IMAGING_HD_RENDER_INDEX_H
34 #include <tbb/enumerable_thread_specific.h>
37 #include <unordered_map>
130 const std::string &instanceName=std::string(),
131 const std::string &appName=std::string());
146 HdSceneIndexBaseRefPtr
const &terminalSceneIndex);
239 return _rprimMap.find(
id) != _rprimMap.
end();
295 return _instancerMap.find(
id) != _instancerMap.
end();
312 template <
typename T>
331 return _taskMap.find(
id) != _taskMap.end();
404 const HdSceneIndexBaseRefPtr &inputScene,
405 SdfPath const& scenePathPrefix,
406 bool needsPrefixing =
true);
410 const HdSceneIndexBaseRefPtr &inputScene);
488 const std::string &instanceName,
489 const std::string &appName,
490 HdSceneIndexBaseRefPtr
const &terminalSceneIndex =
nullptr,
491 bool createFrontEndEmulationOnly =
false);
499 void _CompactPrimIds();
502 void _AllocatePrimId(
HdRprim* prim);
504 using HdTaskCreateFnc =
505 std::function<HdTaskSharedPtr(HdSceneDelegate*, SdfPath const&)>;
510 void _InsertSceneDelegateTask(
515 template <
typename T>
516 static inline const TfToken & _GetTypeId();
538 void _InsertRprim(
TfToken const& typeId,
541 void _InsertSprim(
TfToken const& typeId,
544 void _InsertBprim(
TfToken const& typeId,
553 void _RemoveRprim(
SdfPath const&
id);
556 void _RemoveInstancer(
SdfPath const&
id);
558 void _RemoveRprimSubtree(
const SdfPath &root,
560 void _RemoveInstancerSubtree(
const SdfPath &root,
562 void _RemoveExtComputationSubtree(
const SdfPath &root,
564 void _RemoveTaskSubtree(
const SdfPath &root,
566 void _RemoveTask(
SdfPath const &
id);
577 class _NoticeBatchingContext;
579 HdLegacyPrimSceneIndexRefPtr _emulationSceneIndex;
580 std::unique_ptr<_NoticeBatchingContext> _emulationBatchingCtx;
582 std::unique_ptr<class HdSceneIndexAdapterSceneDelegate> _siSd;
584 HdMergingSceneIndexRefPtr _mergingSceneIndex;
585 std::unique_ptr<_NoticeBatchingContext> _mergingBatchingCtx;
587 HdSceneIndexBaseRefPtr _terminalSceneIndex;
594 typedef std::unordered_map<SdfPath, _TaskInfo, SdfPath::Hash> _TaskMap;
596 typedef std::vector<SdfPath> _RprimPrimIDVector;
604 _RprimPrimIDVector _rprimPrimIdMap;
608 _SprimIndex _sprimIndex;
609 _BprimIndex _bprimIndex;
614 _InstancerMap _instancerMap;
619 HdSceneIndexBaseRefPtr _finalEmulationSceneIndex;
621 std::string _instanceName;
630 std::atomic<int> _syncAllDepth;
635 void _InitPrimTypes();
638 bool _CreateFallbackPrims();
641 void _DestroyFallbackPrims();
643 typedef tbb::enumerable_thread_specific<HdDrawItemPtrVector>
644 _ConcurrentDrawItems;
650 _ConcurrentDrawItems*
result);
655 static void _ConfigureReprs();
666 template <
typename T>
670 _InsertSceneDelegateTask(
671 delegate,
id, HdMakeLegacyTaskFactory<T>());
676 #endif //PXR_IMAGING_HD_RENDER_INDEX_H
HD_API void InsertBprim(TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &bprimId)
Insert a bprim into index.
void InsertTask(HdSceneDelegate *delegate, SdfPath const &id)
TfToken UpdateRenderTag(SdfPath const &id, HdDirtyBits bits)
Like GetRenderTag, but updates the render tag if dirty.
HD_API bool IsSyncAllInProgress() const
Returns true while a thread is invoking SyncAll().
HD_API void RemoveInstancer(SdfPath const &id)
Remove an instancer from index.
std::shared_ptr< class HdResourceRegistry > HdResourceRegistrySharedPtr
HD_API void InsertSprim(TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &sprimId)
Insert a sprim into index.
std::vector< HdDrawItem const * > HdDrawItemPtrVector
#define PXR_NAMESPACE_OPEN_SCOPE
HD_API void Clear()
Clear all r (render), s (state) and b (buffer) prims.
HD_API HdSprim * GetSprim(TfToken const &typeId, SdfPath const &id) const
Returns whether the sprim type is supported by this render index.
HD_API HdRenderDelegate * GetRenderDelegate() const
HD_API void RemoveSubtree(const SdfPath &root, HdSceneDelegate *sceneDelegate)
HD_API void InsertSceneIndex(const HdSceneIndexBaseRefPtr &inputScene, SdfPath const &scenePathPrefix, bool needsPrefixing=true)
HD_API SdfPathVector GetRprimSubtree(SdfPath const &root)
Returns the subtree rooted under the given path.
bool HasTask(SdfPath const &id)
HD_API HdDrawItemPtrVector GetDrawItems(HdRprimCollection const &collection, TfTokenVector const &renderTags)
Returns a list of relevant draw items that match the criteria specified.
HD_API HdSceneIndexBaseRefPtr GetEmulationSceneIndex() const
Functor to use for hash maps from tokens to other things.
HD_API SdfPathVector GetBprimSubtree(TfToken const &typeId, SdfPath const &root)
HD_API bool IsSprimTypeSupported(TfToken const &typeId) const
Returns whether the sprim type is supported by this render index.
**But if you need a result
std::vector< HdTaskSharedPtr > HdTaskSharedPtrVector
HD_API HdRprim const * GetRprim(SdfPath const &id) const
Returns the rprim of id.
HdChangeTracker const & GetChangeTracker() const
HD_API TfToken GetRenderTag(SdfPath const &id) const
Returns the render tag for the given rprim.
bool HasRprim(SdfPath const &id)
Returns true if rprim id exists in index.
std::shared_ptr< class HdTask > HdTaskSharedPtr
static HD_API bool IsSceneIndexEmulationEnabled()
static HD_API HdRenderIndex * New(HdRenderDelegate *renderDelegate, HdDriverVector const &drivers, const std::string &instanceName=std::string(), const std::string &appName=std::string())
HD_API SdfPathVector GetSprimSubtree(TfToken const &typeId, SdfPath const &root)
HD_API HdSceneIndexBaseRefPtr GetTerminalSceneIndex() const
std::vector< HdDriver * > HdDriverVector
HD_API HdResourceRegistrySharedPtr GetResourceRegistry() const
HD_API void SyncAll(HdTaskSharedPtrVector *tasks, HdTaskContext *taskContext)
HD_API void RemoveSceneIndex(const HdSceneIndexBaseRefPtr &inputScene)
std::vector< class SdfPath > SdfPathVector
HD_API void RemoveBprim(TfToken const &typeId, SdfPath const &id)
Returns whether the bprim type is supported by this render index.
HD_API void InsertInstancer(HdSceneDelegate *delegate, SdfPath const &id)
Insert an instancer into index.
HD_API void SceneIndexEmulationNoticeBatchBegin()
std::vector< TfToken > TfTokenVector
Convenience types.
HD_API void EnqueueCollectionToSync(HdRprimCollection const &collection)
HD_API HdSprim * GetFallbackSprim(TfToken const &typeId) const
Returns the fullback prim for the Sprim of the given type.
HD_API HdBprim * GetBprim(TfToken const &typeId, SdfPath const &id) const
Returns whether the bprim type is supported by this render index.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
std::vector< HdRprimCollection > HdRprimCollectionVector
HD_API std::string GetInstanceName() const
HD_API bool GetSceneDelegateAndInstancerIds(SdfPath const &id, SdfPath *sceneDelegateId, SdfPath *instancerId) const
HdChangeTracker & GetChangeTracker()
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
HD_API const SdfPathVector & GetRprimIds()
#define PXR_NAMESPACE_CLOSE_SCOPE
HD_API SdfPath GetRprimPathFromPrimId(int primId) const
HD_API bool IsRprimTypeSupported(TfToken const &typeId) const
Returns whether the rprim type is supported by this render index.
HD_API void RemoveSprim(TfToken const &typeId, SdfPath const &id)
Returns whether the sprim type is supported by this render index.
HD_API HdDriverVector const & GetDrivers() const
HD_API void MergingSceneIndexNoticeBatchEnd()
HD_API HdInstancer * GetInstancer(SdfPath const &id) const
Returns the instancer of id.
HD_API bool IsBprimTypeSupported(TfToken const &typeId) const
Returns whether the bprim type is supported by this render index.
HD_API const SdfPathVector & GetIds()
Sorts the ids if needed and returns the sorted list of ids.
HD_API void RemoveTask(SdfPath const &id)
HD_API void RemoveRprim(SdfPath const &id)
Remove a rprim from index.
HD_API void MergingSceneIndexNoticeBatchBegin()
std::shared_ptr< class HdLegacyTaskFactory > HdLegacyTaskFactorySharedPtr
HD_API void SceneIndexEmulationNoticeBatchEnd()
HD_API void InsertRprim(TfToken const &typeId, HdSceneDelegate *sceneDelegate, SdfPath const &rprimId)
Insert a rprim into index.
HD_API HdBprim * GetFallbackBprim(TfToken const &typeId) const
Returns the fallback prim for the Bprim of the given type.
HD_API HdSceneDelegate * GetSceneDelegateForRprim(SdfPath const &id) const
Returns the scene delegate for the given rprim.
HD_API HdTaskSharedPtr const & GetTask(SdfPath const &id) const
Returns the task for the given id.
bool HasInstancer(SdfPath const &id)
Returns true if instancer id exists in index.