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

A Computation that represents a GPU implementation of a ExtComputation. More...

+ Inheritance diagram for HdStExtCompGpuComputation:

Public Member Functions

 HdStExtCompGpuComputation (SdfPath const &id, HdStExtCompGpuComputationResourceSharedPtr const &resource, HdExtComputationPrimvarDescriptorVector const &compPrimvars, int dispatchCount, int elementCount)
 Constructs a new GPU ExtComputation computation. More...
 
virtual HDST_API void GetBufferSpecs (HdBufferSpecVector *specs) const override
 Adds the output buffer specs generated by this computation to the passed in vector of buffer specs. More...
 
virtual HDST_API void Execute (HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry) override
 Executes the computation on the GPU. More...
 
HDST_API int GetDispatchCount () const
 Gets the number of GPU kernel invocations to execute. More...
 
virtual HDST_API int GetNumOutputElements () const override
 Gets the number of elements in the output primvar. More...
 
virtual HDST_API
HdStExtCompGpuComputationResourceSharedPtr
const & 
GetResource () const
 Gets the shared GPU resource holder for the computation. More...
 
- Public Member Functions inherited from HdComputation
bool IsValid ()
 This function is needed as HdComputation shares a templatized interface with HdBufferSource. More...
 

Static Public Member Functions

static HDST_API
HdStExtCompGpuComputationSharedPtr 
CreateGpuComputation (HdSceneDelegate *sceneDelegate, HdExtComputation const *sourceComp, HdExtComputationPrimvarDescriptorVector const &compPrimvars)
 Creates a GPU computation implementing the given abstract computation. More...
 

Detailed Description

A Computation that represents a GPU implementation of a ExtComputation.

The computation implements the basic: input HdBufferArrayRange -> processing -> output HdBufferArrayRange model of HdComputations where processing happens in Execute during the Execute phase of HdResourceRegistry::Commit.

The computation is performed in three stages by three companion classes:

  1. HdStExtCompGpuComputationBufferSource is responsible for loading input HdBuffersources into the input HdBufferArrayRange during the Resolve phase of the HdResourceRegistry::Commit processing.
  2. HdStExtCompGpuComputationResource holds the committed GPU resident resources along with the compiled compute shading kernel to execute. The values of the HdBufferArrayRanges for the inputs are stored in this object. The resource can store heterogenous sources with differing number of elements as may be required by computations.
  3. HdStExtCompGpuComputation executes the kernel using the committed GPU resident resources and stores the results to the destination HdBufferArrayRange given in Execute. The destination HdBufferArrayRange is allocated by the owning HdRprim that registers the computation with the HdResourceRegistry by calling HdResourceRegistry::AddComputation.
See Also
HdStExtCompGpuComputationBufferSource
HdStExtCompGpuComputationResource
HdRprim
HdComputation
HdResourceRegistry
HdExtComputation
HdBufferArrayRange

Definition at line 85 of file extCompGpuComputation.h.

Constructor & Destructor Documentation

HdStExtCompGpuComputation ( SdfPath const &  id,
HdStExtCompGpuComputationResourceSharedPtr const &  resource,
HdExtComputationPrimvarDescriptorVector const &  compPrimvars,
int  dispatchCount,
int  elementCount 
)

Constructs a new GPU ExtComputation computation.

resource provides the set of input data and kernel to execute this computation. compPrimvars identifies the primvar data being computed

dispatchCount specifies the number of kernel invocations to execute. elementCount specifies the number of elements to allocate for output.

Member Function Documentation

static HDST_API HdStExtCompGpuComputationSharedPtr CreateGpuComputation ( HdSceneDelegate sceneDelegate,
HdExtComputation const *  sourceComp,
HdExtComputationPrimvarDescriptorVector const &  compPrimvars 
)
static

Creates a GPU computation implementing the given abstract computation.

When created this allocates HdStExtCompGpuComputationResource to be shared with the HdStExtCompGpuComputationBufferSource. Nothing is assigned GPU resources unless the source is subsequently added to the hdResourceRegistry and the registry is committed.

This delayed allocation allow Rprims to share computed primvar data and avoid duplicate allocations GPU resources for computation inputs and outputs.

Parameters
[in]sceneDelegatethe delegate to pull scene inputs from.
[in]sourceCompthe abstract computation in the HdRenderIndex this instance actually implements.
[in]compPrimvarsidentifies the primvar data being computed.
See Also
HdExtComputation
virtual HDST_API void Execute ( HdBufferArrayRangeSharedPtr const &  range,
HdResourceRegistry resourceRegistry 
)
overridevirtual

Executes the computation on the GPU.

Called by HdResourceRegistry::Commit with the HdBufferArrayRange given to the HdResourceRegistry when the computation was added to the registry.

Parameters
[in,out]rangethe buffer array range to save the computation result to.
[in]resourceRegistrythe registry that is current committing resources to the GPU.

Implements HdComputation.

virtual HDST_API void GetBufferSpecs ( HdBufferSpecVector *  specs) const
overridevirtual

Adds the output buffer specs generated by this computation to the passed in vector of buffer specs.

Parameters
[out]specsthe vector of HdBufferSpec to add this computation output buffer layout requirements to.

Implements HdComputation.

HDST_API int GetDispatchCount ( ) const

Gets the number of GPU kernel invocations to execute.

It can be useful for this to be different than the number of output elements, e.g. to run a per-curve kernel computing multiple points per-curve.

virtual HDST_API int GetNumOutputElements ( ) const
overridevirtual

Gets the number of elements in the output primvar.

The number of elements produced by the computation must be known before doing the computation. The allocation of GPU resources needs to know the size to allocate before the kernel can run.

Implements HdComputation.

virtual HDST_API HdStExtCompGpuComputationResourceSharedPtr const& GetResource ( ) const
virtual

Gets the shared GPU resource holder for the computation.

HdStExtCompGPUComputationBufferSource will copy its data into this if it had been added to the HdResourceRegistry.


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