Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ComputeComponentInstance Class Reference

#include <computecomponent.h>

Public Member Functions

 ComputeComponentInstance (EntityInstance &entity, Component &resource)
virtual bool init (utility::ErrorState &errorState) override
void compute (VkCommandBuffer commandBuffer)
void compute (VkCommandBuffer commandBuffer, uint numInvocations)
ComputeMaterialInstancegetMaterialInstance ()
glm::u32vec3 getWorkGroupSize () const
void setInvocations (uint numInvocations)
uint getInvocations () const
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
virtual void update (double deltaTime)
nap::EntityInstancegetEntityInstance () const
nap::ComponentgetComponent () const
template<typename T >
T * getComponent () const
- Public Member Functions inherited from Object
 Object ()
virtual ~Object ()
virtual void onDestroy ()
 Object (Object &)=delete
Objectoperator= (const Object &)=delete
 Object (Object &&)=delete
Objectoperator= (Object &&)=delete

Protected Member Functions

virtual void onCompute (VkCommandBuffer commandBuffer, uint numInvocations)
void insertBarriers (VkCommandBuffer commandBuffer)

Protected Attributes

RenderServicemRenderService = nullptr
ComputeMaterialInstance mComputeMaterialInstance
uint mInvocations = 1

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...


Instance part of Compute Component

The compute component represents a general-purpose computation that mutates one or more storage buffers. Internally, a ComputeComponentInstance manages a ComputeMaterialInstance and can caches the desired invocation count for repeated use.

ComputeComponentInstance::compute() dispatches the compute shader with the given compute command buffer. Multiple compute calls may be stacked and are implicitly synchronized by the resource usage and access types bound to the compute material's descriptor sets.

This component can only be used when 'Compute' is available and enabled in the RenderService, otherwise initialization fails. To enable Compute, make sure 'Compute' is marked under the 'RequiredQueues' in the RenderServiceConfiguration.

Inheritance diagram for ComputeComponentInstance:
Collaboration diagram for ComputeComponentInstance:

Constructor & Destructor Documentation

◆ ComputeComponentInstance()

ComputeComponentInstance ( EntityInstance entity,
Component resource 

Member Function Documentation

◆ compute() [1/2]

void compute ( VkCommandBuffer  commandBuffer)

Called by the renderservice, calls onCompute() with the number of invocations set in this instance

commandBufferactive command buffer

◆ compute() [2/2]

void compute ( VkCommandBuffer  commandBuffer,
uint  numInvocations 

Called by the renderservice, calls onCompute() with the given number of invocations

commandBufferactive command buffer
numInvocationsthe number of compute shader invocations

◆ getInvocations()

uint getInvocations ( ) const

Returns the number of compute shader invocations for this instance

◆ getMaterialInstance()

ComputeMaterialInstance& getMaterialInstance ( )
compute program.

◆ getWorkGroupSize()

glm::u32vec3 getWorkGroupSize ( ) const
the local workgroup size

◆ init()

virtual bool init ( utility::ErrorState errorState)

Initializes the compute instance.

errorStatecontains the error if initialization fails
if initialization succeeded.

Reimplemented from ComponentInstance.

◆ insertBarriers()

void insertBarriers ( VkCommandBuffer  commandBuffer)

Inserts memory barriers based on usage properties of the bufferdata. Only does so for storage buffers which are, outside color and depth attachments in render passes, the only resources that can currently be written to. Makes the assumption that the data will be read in a subsequent render pass in the current frame.

◆ onCompute()

virtual void onCompute ( VkCommandBuffer  commandBuffer,
uint  numInvocations 

Dispatches the compute shader using the given command buffer, number of invocations and the bound computematerialinstance

commandBufferactive command buffer
numInvocationsthe number of compute shader invocations

◆ setInvocations()

void setInvocations ( uint  numInvocations)

Sets the number of compute shader invocations for this instance

numInvocationsthe number of compute shader invocations

Member Data Documentation

◆ mComputeMaterialInstance

ComputeMaterialInstance mComputeMaterialInstance

◆ mInvocations

uint mInvocations = 1

◆ mRenderService

RenderService* mRenderService = nullptr