Nameless Engine
Loading...
Searching...
No Matches
ne::ShaderResourceBindingBase Class Referenceabstract

#include <ShaderResourceBinding.h>

Inheritance diagram for ne::ShaderResourceBindingBase:
ne::ShaderCpuWriteResourceBinding ne::ShaderTextureResourceBinding ne::GlslShaderTextureResourceBinding ne::HlslShaderTextureResourceBinding

Public Member Functions

virtual std::optional< ErrorchangeUsedPipelines (const std::unordered_set< Pipeline * > &pipelinesToUse)=0
 
std::string getShaderResourceName () const
 

Protected Member Functions

 ShaderResourceBindingBase (const std::string &sShaderResourceName)
 
virtual std::optional< ErroronAfterAllPipelinesRefreshedResources ()=0
 

Private Attributes

const std::string sShaderResourceName
 

Friends

class PipelineManager
 

Detailed Description

Base class for shader resource bindings.

Remarks
A shader resource binding acts as a bridge between game/engine entities that want to set/bind some data (like buffer/texture) to some shader resource (defined in HLSL/GLSL) and the renderer that is able to set/bind the specified data to a binding that corresponds to the specified shader resources (defined in HLSL/GLSL) so that the specified data can be accessed in shaders.

Constructor & Destructor Documentation

◆ ShaderResourceBindingBase()

ne::ShaderResourceBindingBase::ShaderResourceBindingBase ( const std::string &  sShaderResourceName)
protected

Initializes the binding.

Parameters
sShaderResourceNameName of the resource we are referencing (should be exactly the same as the resource name written in the shader file we are referencing).

Member Function Documentation

◆ changeUsedPipelines()

virtual std::optional< Error > ne::ShaderResourceBindingBase::changeUsedPipelines ( const std::unordered_set< Pipeline * > &  pipelinesToUse)
pure virtual

Called to make the resource to discard currently used pipelines and bind/reference other pipelines.

Warning
Expects that the caller is using some mutex to protect this shader resource from being used in the draw function while this function is not finished (i.e. make sure the CPU will not queue a new frame while this function is not finished).
Remarks
For example, for this function can be called from a mesh node that changed its geometry and thus added/removed some material slots, or if some material that mesh node is using changed its pipeline.
Parameters
pipelinesToUsePipelines to use instead of the current ones.
Returns
Error if something went wrong.

Implemented in ne::ShaderCpuWriteResourceBinding, ne::GlslShaderTextureResourceBinding, and ne::HlslShaderTextureResourceBinding.

◆ getShaderResourceName()

std::string ne::ShaderResourceBindingBase::getShaderResourceName ( ) const

Returns name of the resource (from the shader code) that this binding references.

Returns
Resource name.

◆ onAfterAllPipelinesRefreshedResources()

virtual std::optional< Error > ne::ShaderResourceBindingBase::onAfterAllPipelinesRefreshedResources ( )
protectedpure virtual

Called from the pipeline manager to notify that all pipelines released their internal resources and now restored them so their internal resources (for example push constants) might be different now and shader resource now needs to check that everything that it needs is still there and possibly re-bind to pipeline's descriptors since these might have been also re-created.

Returns
Error if something went wrong.

Implemented in ne::ShaderCpuWriteResourceBinding, ne::GlslShaderTextureResourceBinding, and ne::HlslShaderTextureResourceBinding.

Member Data Documentation

◆ sShaderResourceName

const std::string ne::ShaderResourceBindingBase::sShaderResourceName
private

Name of the resource we are referencing (name in the shader code).


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