Nameless Engine
|
#include <GlslShaderTextureResourceBinding.h>
Classes | |
struct | PushConstantIndices |
Public Member Functions | |
std::string | getPathToTextureResource () |
void | copyResourceIndexToPushConstants (PipelineShaderConstantsManager *pPushConstantsManager, VulkanPipeline *pUsedPipeline) |
virtual std::optional< Error > | useNewTexture (std::unique_ptr< TextureHandle > pTextureToUse) override |
virtual std::optional< Error > | changeUsedPipelines (const std::unordered_set< Pipeline * > &pipelinesToUse) override |
virtual std::optional< Error > | useNewTexture (std::unique_ptr< TextureHandle > pTextureToUse)=0 |
Public Member Functions inherited from ne::ShaderResourceBindingBase | |
virtual std::optional< Error > | changeUsedPipelines (const std::unordered_set< Pipeline * > &pipelinesToUse)=0 |
std::string | getShaderResourceName () const |
Protected Member Functions | |
GlslShaderTextureResourceBinding (const std::string &sResourceName, std::unique_ptr< TextureHandle > pTextureToUse, std::unordered_map< VulkanPipeline *, PushConstantIndices > pushConstantIndices) | |
virtual std::optional< Error > | onAfterAllPipelinesRefreshedResources () override |
Protected Member Functions inherited from ne::ShaderTextureResourceBinding | |
ShaderTextureResourceBinding (const std::string &sShaderResourceName) | |
Protected Member Functions inherited from ne::ShaderResourceBindingBase | |
ShaderResourceBindingBase (const std::string &sShaderResourceName) | |
virtual std::optional< Error > | onAfterAllPipelinesRefreshedResources ()=0 |
Static Private Member Functions | |
static std::variant< std::unique_ptr< ShaderTextureResourceBinding >, Error > | create (const std::string &sShaderResourceName, const std::unordered_set< Pipeline * > &pipelinesToUse, std::unique_ptr< TextureHandle > pTextureToUse) |
static std::variant< std::unique_ptr< ShaderArrayIndex >, Error > | getTextureIndexInShaderArray (const std::string &sShaderResourceName, VulkanPipeline *pPipelineToLookIn) |
static std::optional< Error > | bindTextureToShaderDescriptorArray (const std::string &sShaderResourceName, VulkanPipeline *pPipelineWithDescriptors, VkImageView pTextureView, unsigned int iIndexIntoShaderArray) |
Private Attributes | |
std::pair< std::mutex, std::unique_ptr< TextureHandle > > | mtxUsedTexture |
std::pair< std::recursive_mutex, std::unordered_map< VulkanPipeline *, PushConstantIndices > > | mtxPushConstantIndices |
Friends | |
class | ShaderTextureResourceBindingManager |
References some texture from shader code.
|
protected |
Initializes the resource.
sResourceName | Name of the resource we are referencing (should be exactly the same as the resource name written in the shader file we are referencing). |
pTextureToUse | Texture that should be binded to a descriptor in shader array. |
pushConstantIndices | Indices of push constants (per-pipeline) to copy texture index to. |
|
staticprivate |
Binds the specified image view to the sampler descriptor of the specified pipeline for binding that corresponds to the specified shader resource name.
sShaderResourceName | Name of the shader resource to get binding index in descriptor set. |
pPipelineWithDescriptors | Pipeline which descriptors to use. |
pTextureView | Texture view to bind. |
iIndexIntoShaderArray | Index to a descriptor (in the shader texture array) to bind. |
|
overridevirtual |
Called to make the resource to discard currently used pipelines and bind/reference other pipelines.
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).pipelinesToUse | Pipelines to use instead of the current ones. |
Implements ne::ShaderResourceBindingBase.
|
inline |
Copies resource index (into shader arrays) to a push constant.
pPushConstantsManager | Push constants manager. |
pUsedPipeline | Current pipeline. |
|
staticprivate |
Creates a GLSL shader resource for referencing texture in shader array.
sShaderResourceName | Name of the resource we are referencing (should be exactly the same as the resource name written in the shader file we are referencing). |
pipelinesToUse | Pipelines that use shader/parameters we are referencing. |
pTextureToUse | Texture that should be binded to a descriptor in shader array. |
std::string ne::GlslShaderTextureResourceBinding::getPathToTextureResource | ( | ) |
Returns path to a file/directory that stores used texture resource.
res
directory.
|
staticprivate |
Asks the index manager for an index into the requested shader array resource.
sShaderResourceName | Name of the shader array resource defined in GLSL. |
pPipelineToLookIn | Pipeline to look for an index manager that will provide the index into shader array. |
|
overrideprotectedvirtual |
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.
Implements ne::ShaderResourceBindingBase.
|
overridevirtual |
Makes the shader resource to reference the new (specified) texture.
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).pTextureToUse | Texture to reference. |
Implements ne::ShaderTextureResourceBinding.
|
private |
Index of push constant (per-pipeline) to copy index into shader array.
|
private |
Texture that we bind to descriptor.