Loading...
Searching...
No Matches
HdStExtCompGpuComputation Class Referencefinal

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

#include <extCompGpuComputation.h>

+ 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.
 
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.
 
HDST_API void Execute (HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry) override
 Executes the computation on the GPU.
 
HDST_API int GetDispatchCount () const
 Gets the number of GPU kernel invocations to execute.
 
HDST_API int GetNumOutputElements () const override
 Gets the number of elements in the output primvar.
 
HDST_API HdStExtCompGpuComputationResourceSharedPtr const & GetResource () const
 Gets the shared GPU resource holder for the computation.
 
- Public Member Functions inherited from HdStComputation
virtual void Execute (HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry)=0
 Execute computation.
 
virtual int GetNumOutputElements () const =0
 Returns the size of its destination buffer (located by range argument of Execute()).
 
virtual void GetBufferSpecs (HdBufferSpecVector *specs) const =0
 Add the buffer spec for this computation into given bufferspec vector.
 
bool IsValid ()
 This function is needed as HdStComputation shares a templatized interface with HdBufferSource.
 

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.
 

Detailed Description

A Computation that represents a GPU implementation of a ExtComputation.

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

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

  1. Input HdBuffersources are committed 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
HdStExtCompGpuComputationResource
HdRprim
HdStComputation
HdResourceRegistry
HdExtComputation
HdBufferArrayRange

Definition at line 85 of file extCompGpuComputation.h.

Constructor & Destructor Documentation

◆ HdStExtCompGpuComputation()

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

◆ CreateGpuComputation()

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. 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

◆ Execute()

HDST_API void Execute ( HdBufferArrayRangeSharedPtr const &  range,
HdResourceRegistry resourceRegistry 
)
override

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.

◆ GetBufferSpecs()

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 HdStComputation.

◆ GetDispatchCount()

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.

◆ GetNumOutputElements()

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 HdStComputation.

◆ GetResource()

HDST_API HdStExtCompGpuComputationResourceSharedPtr const & GetResource ( ) const

Gets the shared GPU resource holder for the computation.


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