Nameless Engine
|
#include <HlslShaderTextureResourceBinding.h>
Public Member Functions | |
void | copyResourceIndexToRootConstants (PipelineShaderConstantsManager *pShaderConstantsManager, DirectXPso *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 | |
HlslShaderTextureResourceBinding (const std::string &sResourceName, std::unique_ptr< TextureHandle > pTextureToUse, std::unordered_map< DirectXPso *, std::pair< ContinuousDirectXDescriptorRange *, size_t > > &&usedDescriptorRanges) | |
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::pair< ContinuousDirectXDescriptorRange *, size_t >, Error > | getSrvDescriptorRangeAndRootConstantIndex (DirectXPso *pPipeline, const std::string &sShaderResourceName) |
Private Attributes | |
std::pair< std::mutex, std::unique_ptr< TextureHandle > > | mtxUsedTexture |
std::pair< std::recursive_mutex, std::unordered_map< DirectXPso *, std::pair< ContinuousDirectXDescriptorRange *, size_t > > > | mtxUsedPipelineDescriptorRanges |
Static Private Attributes | |
static constexpr bool | bBindSrvToCubemapFaces = false |
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 to which a descriptor should be binded. |
usedDescriptorRanges | Descriptor ranges that have an SRV binded to the specified texture and a shader constant index for our shader resource. |
|
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 root constant.
pShaderConstantsManager | Shader constants manager. |
pUsedPipeline | Current pipeline. |
|
staticprivate |
Creates a new HLSL shader resource.
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 to which a descriptor should be binded. |
|
staticprivate |
In the specified pipeline looks for a descriptor range that handles a shader resource with the specified name (creates a new descriptor range if not found and returns a pointer to it).
|
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.
|
staticconstexprprivate |
false
to avoid binding descriptors to cubemap faces - I don't see any point in that here, we don't use individual cubemap faces in this case
|
private |
Stores a raw pointer (per-pipeline) to a descriptor range (from the pipeline) that was used to bind an SRV to mtxUsedTexture and an offset of the shader constant for our shader resource.
|
private |
Texture to which a descriptor should be binded.