HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdTask Class Referenceabstract

#include <task.h>

+ Inheritance diagram for HdTask:

Public Member Functions

HD_API HdTask (SdfPath const &id)
 
virtual HD_API ~HdTask ()
 
virtual void Sync (HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits)=0
 
virtual void Prepare (HdTaskContext *ctx, HdRenderIndex *renderIndex)=0
 
virtual void Execute (HdTaskContext *ctx)=0
 
virtual HD_API const
TfTokenVector
GetRenderTags () const
 
SdfPath constGetId () const
 
virtual HD_API HdDirtyBits GetInitialDirtyBitsMask () const
 

Protected Member Functions

template<class T >
bool _GetTaskParams (HdSceneDelegate *delegate, T *outValue)
 
HD_API TfTokenVector _GetTaskRenderTags (HdSceneDelegate *delegate)
 

Static Protected Member Functions

static HD_API bool _HasTaskContextData (HdTaskContext const *ctx, TfToken const &id)
 Check if the shared context contains a value for the given id. More...
 
template<class T >
static bool _GetTaskContextData (HdTaskContext const *ctx, TfToken const &id, T *outValue)
 
template<class T >
static T _GetDriver (HdTaskContext const *ctx, TfToken const &driverName)
 

Detailed Description

Definition at line 54 of file task.h.

Constructor & Destructor Documentation

HD_API HdTask::HdTask ( SdfPath const id)

Construct a new task. If the task is going to be added to the render index, id should be an absolute scene path. If the task isn't going to be added to the render index an empty path should be used for id.

virtual HD_API HdTask::~HdTask ( )
virtual

Member Function Documentation

template<class T >
T HdTask::_GetDriver ( HdTaskContext const ctx,
TfToken const driverName 
)
staticprotected

Extract an object from a HdDriver inside the task context. Returns nullptr if driver was not found.

Definition at line 264 of file task.h.

template<class T >
bool HdTask::_GetTaskContextData ( HdTaskContext const ctx,
TfToken const id,
T outValue 
)
staticprotected

Extracts a typed value out of the task context at the given id. If the id is missing or of the wrong type, the code will throw a verify error, return false and outValue will be unmodified. in case of success, the return value is true and the value is copied into outValue.

outValue must not be null.

Definition at line 213 of file task.h.

template<class T >
bool HdTask::_GetTaskParams ( HdSceneDelegate delegate,
T outValue 
)
protected

Extracts a typed value out of the task context at the given id. If the id is missing or of the wrong type, the code will throw a verify error, return false and outValue will be unmodified. in case of success, the return value is true and the value is copied into outValue.

outValue must not be null.

Definition at line 243 of file task.h.

HD_API TfTokenVector HdTask::_GetTaskRenderTags ( HdSceneDelegate delegate)
protected
static HD_API bool HdTask::_HasTaskContextData ( HdTaskContext const ctx,
TfToken const id 
)
staticprotected

Check if the shared context contains a value for the given id.

virtual void HdTask::Execute ( HdTaskContext ctx)
pure virtual

Execute Phase: Runs the task.

The execution phase should trigger render delegate processing, such as issuing draw commands.

Task execution is non-parallel and ordered.

The task context is the same as used by the prepare step and is used for inter-task communication.

Implemented in HdxPickTask, HdxShadowTask, HdxRenderSetupTask, HdxColorizeSelectionTask, HdxPickFromRenderBufferTask, HdxOitResolveTask, HdxRenderTask, HdxSelectionTask, HdxSimpleLightTask, UsdImaging_TestTask, HdxDrawTargetTask, HdxColorCorrectionTask, HdxAovInputTask, HdxColorChannelTask, HdxOitRenderTask, HdxOitVolumeRenderTask, HdxPresentTask, and HdxDrawTargetResolveTask.

SdfPath const& HdTask::GetId ( ) const
inline

Definition at line 154 of file task.h.

virtual HD_API HdDirtyBits HdTask::GetInitialDirtyBitsMask ( ) const
virtual

Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of this prim. Typically this would be all dirty bits.

virtual HD_API const TfTokenVector& HdTask::GetRenderTags ( ) const
virtual

Render Tag Gather.

Is called during the Sync phase after the task has been sync'ed.

The task should return the render tags it wants to be appended to the active set.

Hydra prims are marked up with a render tag and only prims marked with the render tags in the current active set are Sync'ed.

Hydra's core will combine the sets from each task and deduplicated the result. So tasks don't need to co-ordinate with each other to Optimize the set.

For those tasks that use HdRenderPass, is the typically the set passed to HdRenderPass's Execute method.

The default implementation returns an empty set

Reimplemented in HdxPickTask, HdxShadowTask, HdxRenderTask, UsdImaging_TestTask, and HdxDrawTargetTask.

virtual void HdTask::Prepare ( HdTaskContext ctx,
HdRenderIndex renderIndex 
)
pure virtual

Prepare Phase: Resolve bindings and manage resources.

The Prepare phase happens before the Data Commit phase. All tasks in the task list get called for every execute. At this time all Tasks and other prims have completed the phase synced.

This is an opportunity for the task to pull data from other prims (such as a camera prim), but accessing the render index.

The task can also use the phase to create, register and update temporary resources with the resource registry or other render delegate specific mechanism.

Tasks are always "Prepared" in execution order.

Inter-task communication is achievable via the task context. The same task context is used for the prepare and execution phases. Data in the task context isn't guaranteed to persist across calls to HdEngine::Execute().

Implemented in HdxPickTask, HdxShadowTask, HdxRenderSetupTask, HdxColorizeSelectionTask, HdxPickFromRenderBufferTask, HdxRenderTask, HdxSelectionTask, HdxOitResolveTask, HdxSimpleLightTask, UsdImaging_TestTask, HdxDrawTargetTask, HdxColorCorrectionTask, HdxAovInputTask, HdxPresentTask, HdxColorChannelTask, HdxOitRenderTask, HdxOitVolumeRenderTask, and HdxDrawTargetResolveTask.

virtual void HdTask::Sync ( HdSceneDelegate delegate,
HdTaskContext ctx,
HdDirtyBits dirtyBits 
)
pure virtual

Sync Phase: Obtain task state from Scene delegate based on change processing.

This function might only be called if dirtyBits is not 0, so isn't guaranteed to be called every time HdEngine::Execute() is run with this task.

However, this is the only time when the task should communicate with with the scene delegate responsible for the task and should be used to pull all changed data. As outside the Sync phase, the scene delegate may not have the data available.

Tasks maybe synced in parallel and out of order.

The ctx parameter is present for legacy reason and shouldn't be used once the task has moved to using the 3-phase mechanism.

After a task has been synced, it is expected that it produces a collection identifying the prims that are important to the task. This collection is used to filter the prims in the scene so only the Relevant prims get synced.

Note about inter-prim dependencies: Quite often tasks need to access other prims, such as a camera prim for example. These other prims have not been synced yet when sync is called. Therefore, it is not recommended to access these prims during the sync phase. Instead a task should store the path to the prim to be resolved to an actual prim during the "prepare" phase.

Implemented in HdxPickTask, HdxShadowTask, HdxRenderSetupTask, HdxSelectionTask, HdxOitResolveTask, HdxTask, HdxSimpleLightTask, UsdImaging_TestTask, HdxDrawTargetTask, and HdxDrawTargetResolveTask.


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