Nameless Engine
|
#include <ComputeShaderInterface.h>
Public Member Functions | |
ComputeShaderInterface (const ComputeShaderInterface &)=delete | |
ComputeShaderInterface & | operator= (const ComputeShaderInterface &)=delete |
virtual std::optional< Error > | bindResource (GpuResource *pResource, const std::string &sShaderResourceName, ComputeResourceUsage usage, bool bUpdateOnlyCurrentFrameResourceDescriptors=false)=0 |
void | submitForExecution (unsigned int iThreadGroupCountX, unsigned int iThreadGroupCountY, unsigned int iThreadGroupCountZ) |
ComputeExecutionGroup | getExecutionGroup () const |
ComputeExecutionStage | getExecutionStage () const |
std::string | getComputeShaderName () const |
Pipeline * | getUsedPipeline () const |
Static Public Member Functions | |
static std::variant< std::unique_ptr< ComputeShaderInterface >, Error > | createUsingGraphicsQueue (Renderer *pRenderer, const std::string &sCompiledComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup=ComputeExecutionGroup::FIRST) |
Protected Member Functions | |
ComputeShaderInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup) | |
Renderer * | getRenderer () |
Pipeline * | getPipeline () const |
unsigned int | getThreadGroupCountX () const |
unsigned int | getThreadGroupCountY () const |
unsigned int | getThreadGroupCountZ () const |
Static Protected Member Functions | |
static std::variant< std::unique_ptr< ComputeShaderInterface >, Error > | createRenderSpecificInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup) |
static std::unique_ptr< ComputeShaderInterface > | createPartiallyInitializedRenderSpecificInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup) |
Private Attributes | |
Renderer * | pRenderer = nullptr |
PipelineSharedPtr | pPipeline |
unsigned int | iThreadGroupCountX = 0 |
unsigned int | iThreadGroupCountY = 0 |
unsigned int | iThreadGroupCountZ = 0 |
const ComputeExecutionStage | executionStage = ComputeExecutionStage::AFTER_DEPTH_PREPASS |
const ComputeExecutionGroup | executionGroup = ComputeExecutionGroup::FIRST |
const std::string | sComputeShaderName |
Interface to configure and run a compute shader.
|
protected |
Initializes everything except for pPipeline which is expected to be initialized right after object creation.
pRenderer | Used renderer. |
sComputeShaderName | Name of the compiled compute shader to use. |
executionStage | Determines when the shader will be executed. |
executionGroup | Execution order. |
|
pure virtual |
Binds the specified resource to be available in compute shaders.
pResource | Resource to bind to compute shader. |
sShaderResourceName | Resource name from shader. |
usage | Resource usage. |
bUpdateOnlyCurrentFrameResourceDescriptors | Specify true if you guarantee that you will bind a different GPU resource on the next frame, specify false if you are not sure if you will rebind the resource on the next frame or not. When true is specified only descriptors of the current frame resource will be updated (because descriptors of other frame resources might be in use and it's invalid to update them), when false descriptors of all frame resources will be updated. |
Implemented in ne::GlslComputeShaderInterface, and ne::HlslComputeShaderInterface.
|
staticprotected |
Creates a new interface and initializes everything except for pPipeline which is expected to be initialized right after object creation.
pRenderer | Used renderer. |
sComputeShaderName | Name of the compiled compute shader to use. |
executionStage | Determines when the shader will be executed. |
executionGroup | Determines execution group of this shader where shaders of the first group will be executed before shaders from the second group and so on. |
|
staticprotected |
Creates a new fully initialized render-specific compute shader interface.
pRenderer | Used renderer. |
sComputeShaderName | Name of the compiled compute shader to use. |
executionStage | Determines when the shader will be executed. |
executionGroup | Determines execution group of this shader where shaders of the first group will be executed before shaders from the second group and so on. |
|
static |
Creates a new render-specific interface to a compute shader that will be run in the graphics queue (the same queue that the rendering uses), this compute shader will run synchronously to the rendering operations (on the GPU).
pRenderer | Used renderer. |
sCompiledComputeShaderName | Name of the compiled compute shader to later run. |
executionStage | Determines when the shader will be executed. |
executionGroup | Determines execution group of this shader where shaders of the first group will be executed before shaders from the second group and so on. |
std::string ne::ComputeShaderInterface::getComputeShaderName | ( | ) | const |
Returns name of the compiled compute shader that this interface uses.
ComputeExecutionGroup ne::ComputeShaderInterface::getExecutionGroup | ( | ) | const |
Returns execution group of this shader where shaders of the first group will be executed before shaders from the second group and so on.
ComputeExecutionStage ne::ComputeShaderInterface::getExecutionStage | ( | ) | const |
Returns execution stage of this shader.
|
protected |
Returns used compute pipeline.
|
protected |
Returns used renderer.
|
inlineprotected |
Returns the number of thread groups dispatched in the X direction.
|
inlineprotected |
Returns the number of thread groups dispatched in the Y direction.
|
inlineprotected |
Returns the number of thread groups dispatched in the Z direction.
Pipeline * ne::ComputeShaderInterface::getUsedPipeline | ( | ) | const |
Returns compute pipeline that this shader is referencing.
void ne::ComputeShaderInterface::submitForExecution | ( | unsigned int | iThreadGroupCountX, |
unsigned int | iThreadGroupCountY, | ||
unsigned int | iThreadGroupCountZ | ||
) |
Adds this compute shader to the GPU queue to be executed.
iThreadGroupCountX | The number of thread groups dispatched in the X direction. |
iThreadGroupCountY | The number of thread groups dispatched in the Y direction. |
iThreadGroupCountZ | The number of thread groups dispatched in the Z direction. |
|
private |
Describes order of execution.
|
private |
Describes when shader should be executed.
|
private |
The number of thread groups dispatched in the X direction.
|
private |
The number of thread groups dispatched in the Y direction.
|
private |
The number of thread groups dispatched in the Z direction.
|
private |
Compute pipeline that this interface is using.
|
private |
Do not delete (free) this pointer. A non-owning pointer to the renderer.
|
private |
Name of the compiled compute shader to run.