From 84d8fedc201a66835f5c234160bda63bbc40f682 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 23 Nov 2018 16:07:34 -0800 Subject: Added IShaderResourceBinding::InitializeStaticResources() method to allow explicit initialization of static shader resources in a SRB --- Graphics/GraphicsEngine/interface/PipelineState.h | 5 ++++- .../GraphicsEngine/interface/ShaderResourceBinding.h | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index ca12dda4..2169eefb 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -190,7 +190,10 @@ public: /// \param [out] ppShaderResourceBinding - memory location where pointer to the new shader resource /// binding object is written. - virtual void CreateShaderResourceBinding( IShaderResourceBinding **ppShaderResourceBinding ) = 0; + /// \param [in] InitStaticResources - if set to true, the method will initialize static resources in + /// the created object, which has the exact same effect as calling + /// IShaderResourceBinding::InitializeStaticResources(). + virtual void CreateShaderResourceBinding( IShaderResourceBinding **ppShaderResourceBinding, bool InitStaticResources = false ) = 0; /// Checks if this pipeline state object is compatible with another PSO diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h index 2c177926..9b71f06c 100644 --- a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h +++ b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h @@ -58,7 +58,7 @@ public: /// Any combination of Diligent::SHADER_TYPE may be specified. /// \param [in] pResMapping - Shader resource mapping, where required resources will be looked up /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS. - virtual void BindResources(Uint32 ShaderFlags, IResourceMapping *pResMapping, Uint32 Flags) = 0; + virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) = 0; /// Returns variable @@ -84,6 +84,24 @@ public: /// \remark Only mutable and dynamic variables can be accessed through this method. /// Static variables are accessed through the Shader object. virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index) = 0; + + + /// Initializes static resources + + /// If shaders in the pipeline state contain static resources + /// (see Diligent::SHADER_VARIABLE_TYPE_STATIC), this method must be called + /// once to initialize static resources in this shader resource binding object. + /// The method must be called after all static variables are initialized + /// in the shaders. + /// \param [in] pPipelineState - Pipeline state to copy static shader resource + /// bindings from. The pipeline state must be compatible + /// with this shader resource binding object. + /// If null pointer is provided, the pipeline state + /// that this SRB object was created from is used. + /// \note The method must be called exactly once. If static resources have + /// already been initialized and the method is called again, it will have + /// no effect and a warning messge will be displayed. + virtual void InitializeStaticResources(const IPipelineState* pPipelineState = nullptr) = 0; }; } -- cgit v1.2.3