#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) |
| void | enable (bool enable) |
| bool | isEnabled () const |
| ComputeMaterialInstance & | getMaterialInstance () |
| glm::uvec3 | 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::EntityInstance * | getEntityInstance () const |
| nap::Component * | getComponent () const |
| template<typename T > | |
| T * | getComponent () const |
| virtual bool | init (utility::ErrorState &errorState) |
Public Member Functions inherited from Object | |
| Object () | |
| virtual | ~Object () |
| virtual void | onDestroy () |
| Object (Object &)=delete | |
| Object & | operator= (const Object &)=delete |
| Object (Object &&)=delete | |
| Object & | operator= (Object &&)=delete |
Protected Member Functions | |
| virtual void | onCompute (VkCommandBuffer commandBuffer, uint numInvocations) |
| void | insertBarriers (VkCommandBuffer commandBuffer) |
Protected Attributes | |
| RenderService * | mRenderService = nullptr |
| ComputeMaterialInstance | mComputeMaterialInstance |
| uint | mInvocations = 1 |
| bool | mEnabled = true |
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.
| ComputeComponentInstance | ( | EntityInstance & | entity, |
| Component & | resource | ||
| ) |
| void compute | ( | VkCommandBuffer | commandBuffer | ) |
Called by the renderservice, calls onCompute() with the number of invocations set in this instance
| commandBuffer | active command buffer |
| void compute | ( | VkCommandBuffer | commandBuffer, |
| uint | numInvocations | ||
| ) |
Called by the renderservice, calls onCompute() with the given number of invocations
| commandBuffer | active command buffer |
| numInvocations | the number of compute shader invocations |
| void enable | ( | bool | enable | ) |
Toggles whether this component is enabled.
| enable | if this object should be enabled or not |
| uint getInvocations | ( | ) | const |
Returns the number of compute shader invocations for this instance
| ComputeMaterialInstance& getMaterialInstance | ( | ) |
| glm::uvec3 getWorkGroupSize | ( | ) | const |
|
overridevirtual |
Initializes the compute instance.
| errorState | contains the error if initialization fails |
Reimplemented from ComponentInstance.
|
protected |
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.
| bool isEnabled | ( | ) | const |
|
protectedvirtual |
Dispatches the compute shader using the given command buffer, number of invocations and the bound computematerialinstance
| commandBuffer | active command buffer |
| numInvocations | the number of compute shader invocations |
| void setInvocations | ( | uint | numInvocations | ) |
Sets the number of compute shader invocations for this instance
| numInvocations | the number of compute shader invocations |
|
protected |
|
protected |
|
protected |
|
protected |