Nameless Engine
Loading...
Searching...
No Matches
ne::HlslComputeShaderInterface Class Reference

#include <HlslComputeShaderInterface.h>

Inheritance diagram for ne::HlslComputeShaderInterface:
ne::ComputeShaderInterface

Public Member Functions

 HlslComputeShaderInterface (const HlslComputeShaderInterface &)=delete
 
HlslComputeShaderInterfaceoperator= (const HlslComputeShaderInterface &)=delete
 
virtual std::optional< ErrorbindResource (GpuResource *pResource, const std::string &sShaderResourceName, ComputeResourceUsage usage, bool bUpdateOnlyCurrentFrameResourceDescriptors=false) override
 
void dispatchOnGraphicsQueue (ID3D12GraphicsCommandList *pCommandList)
 
- Public Member Functions inherited from ne::ComputeShaderInterface
 ComputeShaderInterface (const ComputeShaderInterface &)=delete
 
ComputeShaderInterfaceoperator= (const ComputeShaderInterface &)=delete
 
virtual std::optional< ErrorbindResource (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
 
PipelinegetUsedPipeline () const
 

Protected Member Functions

 HlslComputeShaderInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup)
 
- Protected Member Functions inherited from ne::ComputeShaderInterface
 ComputeShaderInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup)
 
RenderergetRenderer ()
 
PipelinegetPipeline () const
 
unsigned int getThreadGroupCountX () const
 
unsigned int getThreadGroupCountY () const
 
unsigned int getThreadGroupCountZ () const
 

Protected Attributes

std::unordered_map< UINT, DirectXResource * > cbvResources
 
std::unordered_map< UINT, DirectXResource * > uavResources
 
std::unordered_map< UINT, DirectXResource * > srvResources
 
std::unordered_map< UINT, DirectXDescriptor * > tableResources
 
DirectXDescriptorHeappCbvSrvUavHeap = nullptr
 
UINT iCbvSrvUavDescriptorSize = 0
 

Friends

class ComputeShaderInterface
 

Additional Inherited Members

- Static Public Member Functions inherited from ne::ComputeShaderInterface
static std::variant< std::unique_ptr< ComputeShaderInterface >, ErrorcreateUsingGraphicsQueue (Renderer *pRenderer, const std::string &sCompiledComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup=ComputeExecutionGroup::FIRST)
 
- Static Protected Member Functions inherited from ne::ComputeShaderInterface
static std::variant< std::unique_ptr< ComputeShaderInterface >, ErrorcreateRenderSpecificInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup)
 
static std::unique_ptr< ComputeShaderInterfacecreatePartiallyInitializedRenderSpecificInterface (Renderer *pRenderer, const std::string &sComputeShaderName, ComputeExecutionStage executionStage, ComputeExecutionGroup executionGroup)
 

Detailed Description

Interface to configure and run an HLSL compute shader.

Constructor & Destructor Documentation

◆ HlslComputeShaderInterface()

ne::HlslComputeShaderInterface::HlslComputeShaderInterface ( Renderer pRenderer,
const std::string &  sComputeShaderName,
ComputeExecutionStage  executionStage,
ComputeExecutionGroup  executionGroup 
)
protected

Initializes the interface.

Parameters
pRendererUsed renderer.
sComputeShaderNameName of the compiled compute shader to use.
executionStageDetermines when the shader will be executed.
executionGroupDetermines execution group of this shader where shaders of the first group will be executed before shaders from the second group and so on.

Member Function Documentation

◆ bindResource()

std::optional< Error > ne::HlslComputeShaderInterface::bindResource ( GpuResource pResource,
const std::string &  sShaderResourceName,
ComputeResourceUsage  usage,
bool  bUpdateOnlyCurrentFrameResourceDescriptors = false 
)
overridevirtual

Binds the specified resource to be available in compute shaders.

Warning
This overload is used in cases where you cannot transfer resource ownership to the compute shader interface. In this case you must guarantee that the resource will not be deleted while this compute shader interface exists and while the GPU is processing this compute shader.
Parameters
pResourceResource to bind to compute shader.
sShaderResourceNameResource name from shader.
usageResource usage.
bUpdateOnlyCurrentFrameResourceDescriptorsSpecify 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.
Returns
Error if something went wrong.

Implements ne::ComputeShaderInterface.

◆ dispatchOnGraphicsQueue()

void ne::HlslComputeShaderInterface::dispatchOnGraphicsQueue ( ID3D12GraphicsCommandList *  pCommandList)
inline

Adds a dispatch command to the specified command list to execute this compute shader.

Warning
Expects that PSO and root signature are set.
Parameters
pCommandListGraphics command list.

Member Data Documentation

◆ cbvResources

std::unordered_map<UINT, DirectXResource*> ne::HlslComputeShaderInterface::cbvResources
protected

Stores pairs of "root parameter index" - "resource to bind as CBV".

◆ iCbvSrvUavDescriptorSize

UINT ne::HlslComputeShaderInterface::iCbvSrvUavDescriptorSize = 0
protected

Size of one CBV/SRV/UAV descriptor.

◆ pCbvSrvUavHeap

DirectXDescriptorHeap* ne::HlslComputeShaderInterface::pCbvSrvUavHeap = nullptr
protected

Descriptor heap for CBV/SRV/UAV descriptors.

◆ srvResources

std::unordered_map<UINT, DirectXResource*> ne::HlslComputeShaderInterface::srvResources
protected

Stores pairs of "root parameter index" - "resource to bind as SRV".

◆ tableResources

std::unordered_map<UINT, DirectXDescriptor*> ne::HlslComputeShaderInterface::tableResources
protected

Stores pairs of "root parameter index" - "descriptor to bind as a table.

◆ uavResources

std::unordered_map<UINT, DirectXResource*> ne::HlslComputeShaderInterface::uavResources
protected

Stores pairs of "root parameter index" - "resource to bind as UAV".


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