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

#include <GlobalShaderResourceBinding.h>

Inheritance diagram for ne::GlobalShaderResourceBinding:
ne::GlslGlobalShaderResourceBinding ne::HlslGlobalShaderResourceBinding

Public Member Functions

 GlobalShaderResourceBinding (const GlobalShaderResourceBinding &)=delete
 
GlobalShaderResourceBindingoperator= (const GlobalShaderResourceBinding &)=delete
 
 GlobalShaderResourceBinding (GlobalShaderResourceBinding &&)=delete
 
GlobalShaderResourceBindingoperator= (GlobalShaderResourceBinding &&)=delete
 

Protected Member Functions

 GlobalShaderResourceBinding (GlobalShaderResourceBindingManager *pManager, const std::string &sShaderResourceName, const std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> &vResourcesToBind)
 
virtual std::optional< ErrorbindToPipelines (Pipeline *pSpecificPipeline)=0
 
void unregisterBinding ()
 
const std::string & getShaderResourceName () const
 
std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> getBindedResources () const
 

Static Protected Member Functions

static std::optional< Errorcreate (Renderer *pRenderer, GlobalShaderResourceBindingManager *pManager, const std::string &sShaderResourceName, const std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> &vResourcesToBind)
 

Private Attributes

const std::string sShaderResourceName
 
const std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> vBindedResources
 
GlobalShaderResourceBindingManager *const pManager = nullptr
 

Friends

class GlobalShaderResourceBindingManager
 

Detailed Description

RAII-style type that:

  • during construction: binds a GPU resource to all graphics pipelines that use it and updates the binding if new pipelines are created or old ones are updated
  • during destruction: removes binding from all graphics pipelines that used it.

Used for binding GPU resources as "global" shader resources (that don't change on a per-object basis).

Constructor & Destructor Documentation

◆ GlobalShaderResourceBinding()

ne::GlobalShaderResourceBinding::GlobalShaderResourceBinding ( GlobalShaderResourceBindingManager pManager,
const std::string &  sShaderResourceName,
const std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> &  vResourcesToBind 
)
protected

Initializes base entity (derived types will do the binding logic).

Remarks
Used internally, instead prefer to use create.
Parameters
pManagerManager that creates this object.
sShaderResourceNameName of the shader resource (name from shader code) to bind the resources.
vResourcesToBindResources to bind to pipelines. This can be the same resource for all frame resources (for example a texture) or a separate resource per frame (can be used for some CPU-write resources).

Member Function Documentation

◆ bindToPipelines()

virtual std::optional< Error > ne::GlobalShaderResourceBinding::bindToPipelines ( Pipeline pSpecificPipeline)
protectedpure virtual

Binds the resource to a specific pipeline or all graphics pipelines that use it.

Parameters
pSpecificPipelinenullptr if need to bind to all graphics pipelines, otherwise a valid pointer to bind only to that pipeline.
Returns
Error if something went wrong.

Implemented in ne::GlslGlobalShaderResourceBinding, and ne::HlslGlobalShaderResourceBinding.

◆ create()

std::optional< Error > ne::GlobalShaderResourceBinding::create ( Renderer pRenderer,
GlobalShaderResourceBindingManager pManager,
const std::string &  sShaderResourceName,
const std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> &  vResourcesToBind 
)
staticprotected

Creates a new render-specific binding and registers it in the manager. Also assigs this new binding to the specified GPU resource so that the binding will be removed once the resources are destroyed.

Parameters
pRendererRenderer.
sShaderResourceNameName of the shader resource (name from shader code) to bind the resources.
pManagerManager that creates this object.
vResourcesToBindResources to bind to pipelines. This can be the same resource for all frame resources (for example a texture) or a separate resource per frame (can be used for some CPU-write resources).
Returns
Error if something went wrong.

◆ getBindedResources()

std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> ne::GlobalShaderResourceBinding::getBindedResources ( ) const
protected

Returns GPU resources that should be binded.

Returns
GPU resources.

◆ getShaderResourceName()

const std::string & ne::GlobalShaderResourceBinding::getShaderResourceName ( ) const
protected

Returns name of the shader resource (name from shader code) to bind to.

Returns
Resource name.

◆ unregisterBinding()

void ne::GlobalShaderResourceBinding::unregisterBinding ( )
protected

Should be called by derived types in their destructor to unregister the binding in the manager.

Member Data Documentation

◆ pManager

GlobalShaderResourceBindingManager* const ne::GlobalShaderResourceBinding::pManager = nullptr
private

Manager that created this object.

◆ sShaderResourceName

const std::string ne::GlobalShaderResourceBinding::sShaderResourceName
private

Name of the shader resource (name from shader code) to bind vBindedResources to.

◆ vBindedResources

const std::array<GpuResource*, FrameResourceManager::getFrameResourceCount()> ne::GlobalShaderResourceBinding::vBindedResources
private

Resources binded to pipelines.

Remarks
This can be the same resource for all frame resources (for example a texturee) or a separate resource per frame (usually used for CPU-write resources).

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