Loading...
Searching...
No Matches
HdRenderIndex Class Referencefinal

The Hydra render index is a flattened representation of the client scene graph, which may be composed of several self-contained scene graphs, each of which provides a HdSceneDelegate adapter for data access. More...

#include <renderIndex.h>

Public Types

typedef std::vector< HdDrawItem const * > HdDrawItemPtrVector
 

Public Member Functions

HD_API void Clear ()
 Clear all r (render), s (state) and b (buffer) prims.
 
HD_API void RemoveSubtree (const SdfPath &root, HdSceneDelegate *sceneDelegate)
 Clear all entries in the render index under the given root and belong to a specified delegate.
 
HD_API SdfPath GetRprimPathFromPrimId (int primId) const
 Given a prim id, returns the path of the corresponding rprim or an empty path if none is found.
 
Synchronization
HD_API void EnqueueCollectionToSync (HdRprimCollection const &collection)
 Hydra's core currently needs to know the collections used by tasks to aggregate the reprs that need to be synced for the dirty Rprims.
 
HD_API void SyncAll (HdTaskSharedPtrVector *tasks, HdTaskContext *taskContext)
 Syncs input tasks, B & S prims, (external) computations and updates the Rprim dirty list to then sync the Rprims.
 
Execution
HD_API HdDrawItemPtrVector GetDrawItems (HdRprimCollection const &collection, TfTokenVector const &renderTags)
 Returns a list of relevant draw items that match the criteria specified.
 
Change Tracker
HdChangeTrackerGetChangeTracker ()
 
HdChangeTracker const & GetChangeTracker () const
 
Renderable prims (e.g. meshes, basis curves)
HD_API bool IsRprimTypeSupported (TfToken const &typeId) const
 Returns whether the rprim type is supported by this render index.
 
HD_API void InsertRprim (TfToken const &typeId, HdSceneDelegate *sceneDelegate, SdfPath const &rprimId)
 Insert a rprim into index.
 
HD_API void RemoveRprim (SdfPath const &id)
 Remove a rprim from index.
 
bool HasRprim (SdfPath const &id)
 Returns true if rprim id exists in index.
 
HD_API HdRprim const * GetRprim (SdfPath const &id) const
 Returns the rprim of id.
 
HD_API HdSceneDelegateGetSceneDelegateForRprim (SdfPath const &id) const
 Returns the scene delegate for the given rprim.
 
HD_API bool GetSceneDelegateAndInstancerIds (SdfPath const &id, SdfPath *sceneDelegateId, SdfPath *instancerId) const
 Query function to return the id's of the scene delegate and instancer associated with the Rprim at the given path.
 
HD_API TfToken GetRenderTag (SdfPath const &id) const
 Returns the render tag for the given rprim.
 
TfToken UpdateRenderTag (SdfPath const &id, HdDirtyBits bits)
 Like GetRenderTag, but updates the render tag if dirty.
 
HD_API const SdfPathVector & GetRprimIds ()
 Returns a sorted list of all Rprims in the render index.
 
HD_API SdfPathVector GetRprimSubtree (SdfPath const &root)
 Returns the subtree rooted under the given path.
 
Instancer Support
HD_API void InsertInstancer (HdSceneDelegate *delegate, SdfPath const &id)
 Insert an instancer into index.
 
HD_API void RemoveInstancer (SdfPath const &id)
 Remove an instancer from index.
 
bool HasInstancer (SdfPath const &id)
 Returns true if instancer id exists in index.
 
HD_API HdInstancerGetInstancer (SdfPath const &id) const
 Returns the instancer of id.
 
Task Support
template<typename T >
void InsertTask (HdSceneDelegate *delegate, SdfPath const &id)
 Inserts a new task into the render index with an identifier of id.
 
HD_API void RemoveTask (SdfPath const &id)
 Removes the given task from the RenderIndex.
 
bool HasTask (SdfPath const &id)
 Returns true if a task exists in the index with the given id.
 
HD_API HdTaskSharedPtr const & GetTask (SdfPath const &id) const
 Returns the task for the given id.
 
Scene state prims (e.g. camera, light)
HD_API bool IsSprimTypeSupported (TfToken const &typeId) const
 Returns whether the sprim type is supported by this render index.
 
HD_API void InsertSprim (TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &sprimId)
 Insert a sprim into index.
 
HD_API void RemoveSprim (TfToken const &typeId, SdfPath const &id)
 
HD_API HdSprimGetSprim (TfToken const &typeId, SdfPath const &id) const
 
HD_API SdfPathVector GetSprimSubtree (TfToken const &typeId, SdfPath const &root)
 Returns the subtree rooted under the given path for the given sprim type.
 
HD_API HdSprimGetFallbackSprim (TfToken const &typeId) const
 Returns the fullback prim for the Sprim of the given type.
 
Buffer prims (e.g. textures, buffers)
HD_API bool IsBprimTypeSupported (TfToken const &typeId) const
 Returns whether the bprim type is supported by this render index.
 
HD_API void InsertBprim (TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &bprimId)
 Insert a bprim into index.
 
HD_API void RemoveBprim (TfToken const &typeId, SdfPath const &id)
 
HD_API HdBprimGetBprim (TfToken const &typeId, SdfPath const &id) const
 
HD_API SdfPathVector GetBprimSubtree (TfToken const &typeId, SdfPath const &root)
 Returns the subtree rooted under the given path for the given bprim type.
 
HD_API HdBprimGetFallbackBprim (TfToken const &typeId) const
 Returns the fallback prim for the Bprim of the given type.
 
Scene indices
HD_API void InsertSceneIndex (const HdSceneIndexBaseRefPtr &inputScene, SdfPath const &scenePathPrefix, bool needsPrefixing=true)
 
HD_API void RemoveSceneIndex (const HdSceneIndexBaseRefPtr &inputScene)
 
HD_API HdSceneIndexBaseRefPtr GetTerminalSceneIndex () const
 The terminal scene index that is driving what is in the render index through emulation.
 

Static Public Member Functions

static HD_API HdRenderIndexNew (HdRenderDelegate *renderDelegate, HdDriverVector const &drivers, const std::string &instanceName=std::string())
 Create a render index with the given render delegate.
 

Render Delegate

class HdSceneIndexAdapterSceneDelegate
 
static HD_API bool IsSceneIndexEmulationEnabled ()
 Returns true if scene index features are available This is true by default but can be controlled via an HD_ENABLE_SCENE_INDEX_EMULATION environment variable.
 
HD_API HdRenderDelegate * GetRenderDelegate () const
 Currently, a render index only supports connection to one type of render delegate, due to the inserted information and change tracking being specific to that delegate type.
 
HD_API HdDriverVector const & GetDrivers () const
 
HD_API HdResourceRegistrySharedPtr GetResourceRegistry () const
 Returns a shared ptr to the resource registry of the current render delegate.
 
HD_API void SceneIndexEmulationNoticeBatchBegin ()
 An application or legacy scene delegate may prefer for the scene index observer notices generated from its prim insertions, removals, or invalidations to be consolidated into vectorized batches.
 
HD_API void SceneIndexEmulationNoticeBatchEnd ()
 Flushes any queued scene index observer notices and disables further queueing.
 
HD_API std::string GetInstanceName () const
 

Detailed Description

The Hydra render index is a flattened representation of the client scene graph, which may be composed of several self-contained scene graphs, each of which provides a HdSceneDelegate adapter for data access.

Thus, multiple HdSceneDelegate's may be tied to the same HdRenderIndex.

The render index, however, is tied to a single HdRenderDelegate, which handles the actual creation and deletion of Hydra scene primitives. These include geometry and non-drawable objects (such as the camera and texture buffers). The render index simply holds a handle to these primitives, and tracks any changes to them via the HdChangeTracker. It also tracks computations and tasks that may update resources and render a subset of the renderable primitives.

The render index orchestrates the "syncing" of scene primitives, by providing the relevant scene delegate for data access, and leaves resource management to the rendering backend (via HdResourceRegistry).

It also provides "execution" functionality for application facing Hydra concepts (such as HdTask/HdRenderPass) in computing the set of HdDrawItems for a given HdRprimCollection, for rendering.

See also
HdChangeTracker HdDrawItem HdRenderDelegate HdRprimCollection HdSceneDelegate
Note
The current design ties a HdRenderIndex to a HdRenderDelegate. However, the HdRenderIndex isn't tied to a viewer (viewport). It is common to have multiple viewers image the composed scene (for example, with different cameras), in which case the HdRenderIndex and HdRenderDelegate are shared by the viewers.

If two viewers use different HdRenderDelegate's, then it may unfortunately require populating two HdRenderIndex's.

Definition at line 120 of file renderIndex.h.

Member Typedef Documentation

◆ HdDrawItemPtrVector

typedef std::vector<HdDrawItem const*> HdDrawItemPtrVector

Definition at line 123 of file renderIndex.h.

Member Function Documentation

◆ Clear()

HD_API void Clear ( )

Clear all r (render), s (state) and b (buffer) prims.

◆ EnqueueCollectionToSync()

HD_API void EnqueueCollectionToSync ( HdRprimCollection const &  collection)

Hydra's core currently needs to know the collections used by tasks to aggregate the reprs that need to be synced for the dirty Rprims.

◆ GetBprimSubtree()

HD_API SdfPathVector GetBprimSubtree ( TfToken const &  typeId,
SdfPath const &  root 
)

Returns the subtree rooted under the given path for the given bprim type.

◆ GetChangeTracker() [1/2]

HdChangeTracker & GetChangeTracker ( )
inline

Definition at line 197 of file renderIndex.h.

◆ GetChangeTracker() [2/2]

HdChangeTracker const & GetChangeTracker ( ) const
inline

Definition at line 198 of file renderIndex.h.

◆ GetDrawItems()

HD_API HdDrawItemPtrVector GetDrawItems ( HdRprimCollection const &  collection,
TfTokenVector const &  renderTags 
)

Returns a list of relevant draw items that match the criteria specified.

The is typically called during render pass execution, which is the final phase in the Hydra's execution. See HdRenderPass::Execute

◆ GetFallbackBprim()

HD_API HdBprim * GetFallbackBprim ( TfToken const &  typeId) const

Returns the fallback prim for the Bprim of the given type.

◆ GetFallbackSprim()

HD_API HdSprim * GetFallbackSprim ( TfToken const &  typeId) const

Returns the fullback prim for the Sprim of the given type.

◆ GetInstancer()

HD_API HdInstancer * GetInstancer ( SdfPath const &  id) const

Returns the instancer of id.

◆ GetRenderDelegate()

HD_API HdRenderDelegate * GetRenderDelegate ( ) const

Currently, a render index only supports connection to one type of render delegate, due to the inserted information and change tracking being specific to that delegate type.

◆ GetRenderTag()

HD_API TfToken GetRenderTag ( SdfPath const &  id) const

Returns the render tag for the given rprim.

◆ GetResourceRegistry()

HD_API HdResourceRegistrySharedPtr GetResourceRegistry ( ) const

Returns a shared ptr to the resource registry of the current render delegate.

◆ GetRprim()

HD_API HdRprim const * GetRprim ( SdfPath const &  id) const

Returns the rprim of id.

◆ GetRprimIds()

HD_API const SdfPathVector & GetRprimIds ( )
inline

Returns a sorted list of all Rprims in the render index.

The list is sorted by std::less<SdfPath>

Definition at line 249 of file renderIndex.h.

◆ GetRprimPathFromPrimId()

HD_API SdfPath GetRprimPathFromPrimId ( int  primId) const

Given a prim id, returns the path of the corresponding rprim or an empty path if none is found.

◆ GetRprimSubtree()

HD_API SdfPathVector GetRprimSubtree ( SdfPath const &  root)

Returns the subtree rooted under the given path.

◆ GetSceneDelegateAndInstancerIds()

HD_API bool GetSceneDelegateAndInstancerIds ( SdfPath const &  id,
SdfPath sceneDelegateId,
SdfPath instancerId 
) const

Query function to return the id's of the scene delegate and instancer associated with the Rprim at the given path.

◆ GetSceneDelegateForRprim()

HD_API HdSceneDelegate * GetSceneDelegateForRprim ( SdfPath const &  id) const

Returns the scene delegate for the given rprim.

◆ GetSprimSubtree()

HD_API SdfPathVector GetSprimSubtree ( TfToken const &  typeId,
SdfPath const &  root 
)

Returns the subtree rooted under the given path for the given sprim type.

◆ GetTask()

HD_API HdTaskSharedPtr const & GetTask ( SdfPath const &  id) const

Returns the task for the given id.

◆ GetTerminalSceneIndex()

HD_API HdSceneIndexBaseRefPtr GetTerminalSceneIndex ( ) const

The terminal scene index that is driving what is in the render index through emulation.

◆ HasInstancer()

bool HasInstancer ( SdfPath const &  id)
inline

Returns true if instancer id exists in index.

Definition at line 271 of file renderIndex.h.

◆ HasRprim()

bool HasRprim ( SdfPath const &  id)
inline

Returns true if rprim id exists in index.

Definition at line 219 of file renderIndex.h.

◆ HasTask()

bool HasTask ( SdfPath const &  id)
inline

Returns true if a task exists in the index with the given id.

Definition at line 292 of file renderIndex.h.

◆ InsertBprim()

HD_API void InsertBprim ( TfToken const &  typeId,
HdSceneDelegate delegate,
SdfPath const &  bprimId 
)

Insert a bprim into index.

◆ InsertInstancer()

HD_API void InsertInstancer ( HdSceneDelegate delegate,
SdfPath const &  id 
)

Insert an instancer into index.

◆ InsertRprim()

HD_API void InsertRprim ( TfToken const &  typeId,
HdSceneDelegate sceneDelegate,
SdfPath const &  rprimId 
)

Insert a rprim into index.

◆ InsertSprim()

HD_API void InsertSprim ( TfToken const &  typeId,
HdSceneDelegate delegate,
SdfPath const &  sprimId 
)

Insert a sprim into index.

◆ InsertTask()

void InsertTask ( HdSceneDelegate delegate,
SdfPath const &  id 
)

Inserts a new task into the render index with an identifier of id.

Definition at line 594 of file renderIndex.h.

◆ IsBprimTypeSupported()

HD_API bool IsBprimTypeSupported ( TfToken const &  typeId) const

Returns whether the bprim type is supported by this render index.

◆ IsRprimTypeSupported()

HD_API bool IsRprimTypeSupported ( TfToken const &  typeId) const

Returns whether the rprim type is supported by this render index.

◆ IsSceneIndexEmulationEnabled()

static HD_API bool IsSceneIndexEmulationEnabled ( )
static

Returns true if scene index features are available This is true by default but can be controlled via an HD_ENABLE_SCENE_INDEX_EMULATION environment variable.

◆ IsSprimTypeSupported()

HD_API bool IsSprimTypeSupported ( TfToken const &  typeId) const

Returns whether the sprim type is supported by this render index.

◆ New()

static HD_API HdRenderIndex * New ( HdRenderDelegate *  renderDelegate,
HdDriverVector const &  drivers,
const std::string &  instanceName = std::string() 
)
static

Create a render index with the given render delegate.

Returns null if renderDelegate is null. The render delegate and render tasks may require access to a renderer's device provided by the application. The objects can be passed in as 'drivers'. Hgi is an example of a HdDriver. "instanceName" is an optional identifier useful for applications to associate this render index with related resources (such as the scene index instances).

◆ RemoveInstancer()

HD_API void RemoveInstancer ( SdfPath const &  id)

Remove an instancer from index.

◆ RemoveRprim()

HD_API void RemoveRprim ( SdfPath const &  id)

Remove a rprim from index.

◆ RemoveSubtree()

HD_API void RemoveSubtree ( const SdfPath root,
HdSceneDelegate sceneDelegate 
)

Clear all entries in the render index under the given root and belong to a specified delegate.

Used for example to unload a delegate.

◆ RemoveTask()

HD_API void RemoveTask ( SdfPath const &  id)

Removes the given task from the RenderIndex.

◆ SceneIndexEmulationNoticeBatchBegin()

HD_API void SceneIndexEmulationNoticeBatchBegin ( )

An application or legacy scene delegate may prefer for the scene index observer notices generated from its prim insertions, removals, or invalidations to be consolidated into vectorized batches.

Calling this will cause subsequent notices to be be queued.

NOTE: This tracks depth internally and is safe to call in nested contexts. It is not safe to call from multiple threads, though.

◆ SceneIndexEmulationNoticeBatchEnd()

HD_API void SceneIndexEmulationNoticeBatchEnd ( )

Flushes any queued scene index observer notices and disables further queueing.

NOTE: This tracks depth internally and is safe to call in nested contexts. It is not safe to call from multiple threads, though.

◆ SyncAll()

HD_API void SyncAll ( HdTaskSharedPtrVector *  tasks,
HdTaskContext *  taskContext 
)

Syncs input tasks, B & S prims, (external) computations and updates the Rprim dirty list to then sync the Rprims.

At the end of this step, all the resources that need to be updated have handles to their data sources. This is the first phase in Hydra's execution. See HdEngine::Execute

◆ UpdateRenderTag()

TfToken UpdateRenderTag ( SdfPath const &  id,
HdDirtyBits  bits 
)

Like GetRenderTag, but updates the render tag if dirty.

Friends And Related Function Documentation

◆ HdSceneIndexAdapterSceneDelegate

friend class HdSceneIndexAdapterSceneDelegate
friend

Definition at line 474 of file renderIndex.h.


The documentation for this class was generated from the following file: