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

#include <ShaderResource.h>

Inheritance diagram for ne::ShaderResourceBase:
ne::ShaderCpuWriteResource ne::ShaderTextureResource ne::GlslShaderCpuWriteResource ne::HlslShaderCpuWriteResource ne::GlslShaderTextureResource ne::HlslShaderTextureResource

Public Member Functions

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

Protected Member Functions

 ShaderResourceBase (const std::string &sResourceName)
 
virtual std::optional< ErroronAfterAllPipelinesRefreshedResources ()=0
 

Private Attributes

std::string sResourceName
 

Friends

class PipelineManager
 

Detailed Description

Base class for shader resources.

Remarks
A shader resource 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

◆ ShaderResourceBase()

ne::ShaderResourceBase::ShaderResourceBase ( const std::string &  sResourceName)
protected

Initializes the resource.

Parameters
sResourceNameName 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::ShaderResourceBase::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::GlslShaderCpuWriteResource, ne::GlslShaderTextureResource, ne::HlslShaderCpuWriteResource, and ne::HlslShaderTextureResource.

◆ getResourceName()

std::string ne::ShaderResourceBase::getResourceName ( ) const

Returns name of this resource.

Returns
Resource name.

◆ onAfterAllPipelinesRefreshedResources()

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

Called from 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::GlslShaderCpuWriteResource, ne::GlslShaderTextureResource, ne::HlslShaderCpuWriteResource, and ne::HlslShaderTextureResource.

Member Data Documentation

◆ sResourceName

std::string ne::ShaderResourceBase::sResourceName
private

Name of the resource we are referencing.


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