Diligent Engine API Reference
ShaderD3D11Impl.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 "ShaderD3D11.h"
30 #include "RenderDeviceD3D11.h"
31 #include "ShaderBase.h"
32 #include "ShaderD3DBase.h"
33 #include "ShaderResourceLayoutD3D11.h"
34 #include "ShaderResourceCacheD3D11.h"
35 #include "EngineD3D11Defines.h"
36 #include "ShaderResourcesD3D11.h"
37 
38 namespace Diligent
39 {
40 
41 class FixedBlockMemoryAllocator;
42 class ResourceMapping;
43 
45 class ShaderD3D11Impl : public ShaderBase<IShaderD3D11, IRenderDeviceD3D11>, public ShaderD3DBase
46 {
47 public:
49 
50  ShaderD3D11Impl(IReferenceCounters *pRefCounters, class RenderDeviceD3D11Impl *pRenderDeviceD3D11, const ShaderCreationAttribs &CreationAttribs);
51  ~ShaderD3D11Impl();
52 
53  virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final;
54 
55  virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override final;
56 
57  virtual IShaderVariable* GetShaderVariable( const Char* Name )override final;
58 
59  virtual ID3D11DeviceChild* GetD3D11Shader()override final{ return m_pShader; }
60 
61  ID3DBlob* GetBytecode(){return m_pShaderByteCode;}
62 
63  ShaderResourceLayoutD3D11& GetStaticResourceLayout(){return m_StaticResLayout;}
64  const std::shared_ptr<const ShaderResourcesD3D11>& GetResources(){return m_pShaderResources;}
65  Uint32 GetShaderTypeIndex(){return m_ShaderTypeIndex;}
66 
67 private:
68 
69  DummyShaderVariable m_DummyShaderVar;
70 
72  CComPtr<ID3D11DeviceChild> m_pShader;
73 
74  // ShaderResources class instance must be referenced through the shared pointer, because
75  // it is referenced by ShaderResourceLayoutD3D11 class instances
76  std::shared_ptr<const ShaderResourcesD3D11> m_pShaderResources;
77 
78  ShaderResourceCacheD3D11 m_StaticResCache;
79  ShaderResourceLayoutD3D11 m_StaticResLayout;
80  Uint32 m_ShaderTypeIndex; // VS == 0, PS == 1, GS == 2, HS == 3, DS == 4, CS == 5
81 };
82 
83 }
Shader resource variable.
Definition: Shader.h:265
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Template class implementing base functionality for a shader object.
Definition: ShaderBase.h:172
Resouce mapping.
Definition: ResourceMapping.h:80
virtual ID3D11DeviceChild * GetD3D11Shader() override final
Returns a pointer to the ID3D11DeviceChild interface of the internal Direct3D11 object.
Definition: ShaderD3D11Impl.h:59
virtual void BindResources(IResourceMapping *pResourceMapping, Uint32 Flags) override final
Binds shader resources.
Definition: ShaderD3D11Impl.cpp:105
Implementation of the Diligent::IRenderDeviceD3D11 interface.
Definition: RenderDeviceD3D11Impl.h:38
Implementation of the Diligent::IShaderD3D11 interface.
Definition: ShaderD3D11Impl.h:45
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override final
Queries the specific interface, see IObject::QueryInterface() for details.
virtual IShaderVariable * GetShaderVariable(const Char *Name) override final
Returns an interface to a shader variable. If the shader variable is not found, an interface to a dum...
Definition: ShaderD3D11Impl.cpp:97
Shader creation attributes.
Definition: Shader.h:204