HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdRenderIndex Class Referencefinal

#include <renderIndex.h>

Public Types

typedef std::vector
< HdDrawItem const * > 
HdDrawItemPtrVector
 

Public Member Functions

HD_API ~HdRenderIndex ()
 
HD_API void Clear ()
 Clear all r (render), s (state) and b (buffer) prims. More...
 
HD_API void RemoveSubtree (const SdfPath &root, HdSceneDelegate *sceneDelegate)
 
HD_API SdfPath GetRprimPathFromPrimId (int primId) const
 
Synchronization
HD_API void EnqueuePrimsToSync (HdDirtyListSharedPtr const &dirtyList, HdRprimCollection const &collection)
 
HD_API void SyncAll (HdTaskSharedPtrVector *tasks, HdTaskContext *taskContext)
 
Execution
HD_API HdDrawItemPtrVector GetDrawItems (HdRprimCollection const &collection, TfTokenVector const &renderTags)
 Returns a list of relevant draw items that match the criteria specified. More...
 
Change Tracker
HdChangeTrackerGetChangeTracker ()
 
HdChangeTracker constGetChangeTracker () 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. More...
 
HD_API void InsertRprim (TfToken const &typeId, HdSceneDelegate *sceneDelegate, SdfPath const &rprimId, SdfPath const &instancerId=SdfPath())
 Insert a rprim into index. More...
 
HD_API void RemoveRprim (SdfPath const &id)
 Remove a rprim from index. More...
 
bool HasRprim (SdfPath const &id)
 Returns true if rprim id exists in index. More...
 
HD_API HdRprim constGetRprim (SdfPath const &id) const
 Returns the rprim of id. More...
 
HD_API HdSceneDelegateGetSceneDelegateForRprim (SdfPath const &id) const
 Returns the scene delegate for the given rprim. More...
 
HD_API bool GetSceneDelegateAndInstancerIds (SdfPath const &id, SdfPath *sceneDelegateId, SdfPath *instancerId) const
 
HD_API TfToken GetRenderTag (SdfPath const &id) const
 Returns the render tag for the given rprim. More...
 
HD_API TfToken GetMaterialTag (SdfPath const &id) const
 Return the material tag for the given rprim. More...
 
HD_API const SdfPathVectorGetRprimIds ()
 
HD_API SdfPathVector GetRprimSubtree (SdfPath const &root)
 Returns the subtree rooted under the given path. More...
 
Instancer Support
HD_API void InsertInstancer (HdSceneDelegate *delegate, SdfPath const &id, SdfPath const &parentId=SdfPath())
 Insert an instancer into index. More...
 
HD_API void RemoveInstancer (SdfPath const &id)
 Remove an instancer from index. More...
 
bool HasInstancer (SdfPath const &id)
 Returns true if instancer id exists in index. More...
 
HD_API HdInstancerGetInstancer (SdfPath const &id) const
 Returns the instancer of id. More...
 
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. More...
 
HD_API void RemoveTask (SdfPath const &id)
 Removes the given task from the RenderIndex. More...
 
bool HasTask (SdfPath const &id)
 Returns true if a task exists in the index with the given id. More...
 
HD_API HdTaskSharedPtr constGetTask (SdfPath const &id) const
 Returns the task for the given id. More...
 
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. More...
 
HD_API void InsertSprim (TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &sprimId)
 Insert a sprim into index. More...
 
HD_API void RemoveSprim (TfToken const &typeId, SdfPath const &id)
 Returns whether the sprim type is supported by this render index. More...
 
HD_API HdSprimGetSprim (TfToken const &typeId, SdfPath const &id) const
 Returns whether the sprim type is supported by this render index. More...
 
HD_API SdfPathVector GetSprimSubtree (TfToken const &typeId, SdfPath const &root)
 
HD_API HdSprimGetFallbackSprim (TfToken const &typeId) const
 Returns the fullback prim for the Sprim of the given type. More...
 
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. More...
 
HD_API void InsertBprim (TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &bprimId)
 Insert a bprim into index. More...
 
HD_API void RemoveBprim (TfToken const &typeId, SdfPath const &id)
 Returns whether the bprim type is supported by this render index. More...
 
HD_API HdBprimGetBprim (TfToken const &typeId, SdfPath const &id) const
 Returns whether the bprim type is supported by this render index. More...
 
HD_API SdfPathVector GetBprimSubtree (TfToken const &typeId, SdfPath const &root)
 
HD_API HdBprimGetFallbackBprim (TfToken const &typeId) const
 Returns the fallback prim for the Bprim of the given type. More...
 
HD_API
HdResourceRegistry::TextureKey 
GetTextureKey (HdTextureResource::ID id) const
 

Static Public Member Functions

static HD_API HdRenderIndexNew (HdRenderDelegate *renderDelegate, HdDriverVector const &drivers)
 

Render Delegate

class HdDirtyList
 
HD_API HdRenderDelegateGetRenderDelegate () const
 
HD_API HdDriverVector constGetDrivers () const
 
HD_API HdResourceRegistrySharedPtr GetResourceRegistry () 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 117 of file renderIndex.h.

Member Typedef Documentation

Definition at line 120 of file renderIndex.h.

Constructor & Destructor Documentation

HD_API HdRenderIndex::~HdRenderIndex ( )

Member Function Documentation

HD_API void HdRenderIndex::Clear ( )

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

HD_API void HdRenderIndex::EnqueuePrimsToSync ( HdDirtyListSharedPtr const dirtyList,
HdRprimCollection const collection 
)

Adds the dirty list to the sync queue. The actual processing of the dirty list happens later in SyncAll().

This is typically called from HdRenderPass::Sync. However, the current call chain ties it to SyncAll, i.e. HdRenderIndex::SyncAll > .... > HdRenderPass::Sync > HdRenderIndex::Sync

HD_API HdBprim* HdRenderIndex::GetBprim ( TfToken const typeId,
SdfPath const id 
) const

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

HD_API SdfPathVector HdRenderIndex::GetBprimSubtree ( TfToken const typeId,
SdfPath const root 
)

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

HdChangeTracker& HdRenderIndex::GetChangeTracker ( )
inline

Definition at line 194 of file renderIndex.h.

HdChangeTracker const& HdRenderIndex::GetChangeTracker ( ) const
inline

Definition at line 195 of file renderIndex.h.

HD_API HdDrawItemPtrVector HdRenderIndex::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

HD_API HdDriverVector const& HdRenderIndex::GetDrivers ( ) const

With the removal of task-based collection include/exclude path filtering, HdDirtyLists were generating their lists of dirty rprim IDs by looking through every rprim in the render index. When the number of tasks/render passes/dirty lists grew large, this resulted in significant overhead and lots of duplication of work. Instead, the render index itself now takes care of generating the complete list of dirty rprim IDs when requested by the HdDirtyList. During SyncAll(), the first HdDirtyList to request the list of dirty IDs for a given HdDirtyBits mask triggers the render index to produce that list and cache it in a map. Subsequent requests reuse the cached list. At the end of SyncAll(), the map is cleared in preparation for the next sync.

HD_API HdBprim* HdRenderIndex::GetFallbackBprim ( TfToken const typeId) const

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

HD_API HdSprim* HdRenderIndex::GetFallbackSprim ( TfToken const typeId) const

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

HD_API HdInstancer* HdRenderIndex::GetInstancer ( SdfPath const id) const

Returns the instancer of id.

HD_API TfToken HdRenderIndex::GetMaterialTag ( SdfPath const id) const

Return the material tag for the given rprim.

HD_API HdRenderDelegate* HdRenderIndex::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 TfToken HdRenderIndex::GetRenderTag ( SdfPath const id) const

Returns the render tag for the given rprim.

HD_API HdResourceRegistrySharedPtr HdRenderIndex::GetResourceRegistry ( ) const

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

HD_API HdRprim const* HdRenderIndex::GetRprim ( SdfPath const id) const

Returns the rprim of id.

HD_API const SdfPathVector& HdRenderIndex::GetRprimIds ( )
inline

Returns a sorted list of all Rprims in the render index. The list is sorted by std::less<SdfPath>

Definition at line 247 of file renderIndex.h.

HD_API SdfPath HdRenderIndex::GetRprimPathFromPrimId ( int  primId) const

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

HD_API SdfPathVector HdRenderIndex::GetRprimSubtree ( SdfPath const root)

Returns the subtree rooted under the given path.

HD_API bool HdRenderIndex::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 HdSceneDelegate* HdRenderIndex::GetSceneDelegateForRprim ( SdfPath const id) const

Returns the scene delegate for the given rprim.

HD_API HdSprim* HdRenderIndex::GetSprim ( TfToken const typeId,
SdfPath const id 
) const

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

HD_API SdfPathVector HdRenderIndex::GetSprimSubtree ( TfToken const typeId,
SdfPath const root 
)

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

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

Returns the task for the given id.

HD_API HdResourceRegistry::TextureKey HdRenderIndex::GetTextureKey ( HdTextureResource::ID  id) const

Helper utility to convert texture resource id's which are unique to this render index, into a globally unique texture key

bool HdRenderIndex::HasInstancer ( SdfPath const id)
inline

Returns true if instancer id exists in index.

Definition at line 270 of file renderIndex.h.

bool HdRenderIndex::HasRprim ( SdfPath const id)
inline

Returns true if rprim id exists in index.

Definition at line 217 of file renderIndex.h.

bool HdRenderIndex::HasTask ( SdfPath const id)
inline

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

Definition at line 291 of file renderIndex.h.

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

Insert a bprim into index.

HD_API void HdRenderIndex::InsertInstancer ( HdSceneDelegate delegate,
SdfPath const id,
SdfPath const parentId = SdfPath() 
)

Insert an instancer into index.

HD_API void HdRenderIndex::InsertRprim ( TfToken const typeId,
HdSceneDelegate sceneDelegate,
SdfPath const rprimId,
SdfPath const instancerId = SdfPath() 
)

Insert a rprim into index.

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

Insert a sprim into index.

template<typename T >
void HdRenderIndex::InsertTask ( HdSceneDelegate delegate,
SdfPath const id 
)

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

Definition at line 529 of file renderIndex.h.

HD_API bool HdRenderIndex::IsBprimTypeSupported ( TfToken const typeId) const

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

HD_API bool HdRenderIndex::IsRprimTypeSupported ( TfToken const typeId) const

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

HD_API bool HdRenderIndex::IsSprimTypeSupported ( TfToken const typeId) const

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

static HD_API HdRenderIndex* HdRenderIndex::New ( HdRenderDelegate renderDelegate,
HdDriverVector const drivers 
)
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.

HD_API void HdRenderIndex::RemoveBprim ( TfToken const typeId,
SdfPath const id 
)

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

HD_API void HdRenderIndex::RemoveInstancer ( SdfPath const id)

Remove an instancer from index.

HD_API void HdRenderIndex::RemoveRprim ( SdfPath const id)

Remove a rprim from index.

HD_API void HdRenderIndex::RemoveSprim ( TfToken const typeId,
SdfPath const id 
)

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

HD_API void HdRenderIndex::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.

HD_API void HdRenderIndex::RemoveTask ( SdfPath const id)

Removes the given task from the RenderIndex.

HD_API void HdRenderIndex::SyncAll ( HdTaskSharedPtrVector tasks,
HdTaskContext taskContext 
)

Syncs input tasks, B & S prims, (external) computations and processes all pending dirty lists (which syncs the R prims). 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

Friends And Related Function Documentation

friend class HdDirtyList
friend

With the removal of task-based collection include/exclude path filtering, HdDirtyLists were generating their lists of dirty rprim IDs by looking through every rprim in the render index. When the number of tasks/render passes/dirty lists grew large, this resulted in significant overhead and lots of duplication of work. Instead, the render index itself now takes care of generating the complete list of dirty rprim IDs when requested by the HdDirtyList. During SyncAll(), the first HdDirtyList to request the list of dirty IDs for a given HdDirtyBits mask triggers the render index to produce that list and cache it in a map. Subsequent requests reuse the cached list. At the end of SyncAll(), the map is cleared in preparation for the next sync.

Definition at line 481 of file renderIndex.h.


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