Diligent Engine API Reference
ShaderResourceBindingD3D11Impl.h
1 /* Copyright 2015-2018 Egor Yusov
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12  *
13  * In no event and under no legal theory, whether in tort (including negligence),
14  * contract, or otherwise, unless required by applicable law (such as deliberate
15  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16  * liable for any damages, including any direct, indirect, special, incidental,
17  * or consequential damages of any character arising as a result of this License or
18  * out of the use or inability to use the software (including but not limited to damages
19  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20  * all other commercial damages or losses), even if such Contributor has been advised
21  * of the possibility of such damages.
22  */
23 
24 #pragma once
25 
28 
29 #include "ShaderResourceBindingD3D11.h"
30 #include "RenderDeviceD3D11.h"
31 #include "ShaderResourceBindingBase.h"
32 #include "ShaderResourceCacheD3D11.h"
33 #include "ShaderResourceLayoutD3D11.h"
34 #include "STDAllocator.h"
35 
36 namespace Diligent
37 {
38 
39 class FixedBlockMemoryAllocator;
41 class ShaderResourceBindingD3D11Impl : public ShaderResourceBindingBase<IShaderResourceBindingD3D11>
42 {
43 public:
45  ShaderResourceBindingD3D11Impl(IReferenceCounters *pRefCounters, class PipelineStateD3D11Impl *pPSO, bool IsInternal);
47 
48  virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final;
49 
50  virtual void BindResources(Uint32 ShaderFlags, IResourceMapping *pResMapping, Uint32 Flags)override final;
51 
52  virtual IShaderVariable *GetVariable(SHADER_TYPE ShaderType, const char *Name)override final;
53 
54  ShaderResourceCacheD3D11 &GetResourceCache(Uint32 Ind){VERIFY_EXPR(Ind < m_NumActiveShaders); return m_pBoundResourceCaches[Ind];}
55  ShaderResourceLayoutD3D11 &GetResourceLayout(Uint32 Ind){VERIFY_EXPR(Ind < m_NumActiveShaders); return m_pResourceLayouts[Ind];}
56 
57  void BindStaticShaderResources();
58  inline bool IsStaticResourcesBound(){return m_bIsStaticResourcesBound;}
59 
60  Uint32 GetNumActiveShaders()
61  {
62  return static_cast<Uint32>(m_NumActiveShaders);
63  }
64 
65  Int32 GetActiveShaderTypeIndex(Uint32 s){return m_ShaderTypeIndex[s];}
66 
67 private:
68  // The caches are indexed by the shader order in the PSO, not shader index
69  ShaderResourceCacheD3D11* m_pBoundResourceCaches = nullptr;
70  ShaderResourceLayoutD3D11* m_pResourceLayouts = nullptr;
71 
72  Int8 m_ShaderTypeIndex[6] = {};
73 
74  // Resource layout index in m_ResourceLayouts[] array for every shader stage
75  Int8 m_ResourceLayoutIndex[6];
76  Uint8 m_NumActiveShaders = 0;
77 
78  bool m_bIsStaticResourcesBound = false;
79 };
80 
81 }
Shader resource variable.
Definition: Shader.h:265
The class implements a cache that holds resources bound to a specific shader stage.
Definition: ShaderResourceCacheD3D11.h:46
SHADER_TYPE
Describes the shader type.
Definition: Shader.h:46
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Resouce mapping.
Definition: ResourceMapping.h:80
virtual void BindResources(Uint32 ShaderFlags, IResourceMapping *pResMapping, Uint32 Flags) override final
Binds all resource using the resource mapping.
Definition: ShaderResourceBindingD3D11Impl.cpp:103
Implementation of the Diligent::IShaderResourceBindingD3D11 interface.
Definition: ShaderResourceBindingD3D11Impl.h:41
Template class implementing base functionality for a shader resource binding.
Definition: ShaderResourceBindingBase.h:42
Implementation of the Diligent::IPipelineStateD3D11 interface.
Definition: PipelineStateD3D11Impl.h:40
Diligent::ShaderResourceLayoutD3D11 class http://diligentgraphics.com/diligent-engine/architecture/d3...
Definition: ShaderResourceLayoutD3D11.h:49
virtual IShaderVariable * GetVariable(SHADER_TYPE ShaderType, const char *Name) override final
Returns variable.
Definition: ShaderResourceBindingD3D11Impl.cpp:146