Diligent Engine API Reference
ShaderD3D12Impl.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 "RenderDeviceD3D12.h"
30 #include "ShaderD3D12.h"
31 #include "ShaderBase.h"
32 #include "ShaderD3DBase.h"
33 #include "ShaderResourceLayoutD3D12.h"
34 
35 #ifdef _DEBUG
36 # define VERIFY_SHADER_BINDINGS
37 #endif
38 
39 namespace Diligent
40 {
41 
42 class ResourceMapping;
43 class FixedBlockMemoryAllocator;
44 
46 class ShaderD3D12Impl : public ShaderBase<IShaderD3D12, IRenderDeviceD3D12>, public ShaderD3DBase
47 {
48 public:
50 
51  ShaderD3D12Impl(IReferenceCounters *pRefCounters, class RenderDeviceD3D12Impl *pRenderDeviceD3D12, const ShaderCreationAttribs &ShaderCreationAttribs);
52  ~ShaderD3D12Impl();
53 
54  //virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
55 
56  virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override;
57 
58  virtual IShaderVariable* GetShaderVariable(const Char* Name)override;
59 
60  ID3DBlob* GetShaderByteCode(){return m_pShaderByteCode;}
61  const std::shared_ptr<const ShaderResourcesD3D12>& GetShaderResources()const{return m_pShaderResources;}
62  const ShaderResourceLayoutD3D12& GetConstResLayout()const{return m_StaticResLayout;}
63 
64 #ifdef VERIFY_SHADER_BINDINGS
65  void DbgVerifyStaticResourceBindings();
66 #endif
67 
68 private:
69 
70  DummyShaderVariable m_DummyShaderVar;
71 
72  // ShaderResources class instance must be referenced through the shared pointer, because
73  // it is referenced by ShaderResourceLayoutD3D12 class instances
74  std::shared_ptr<const ShaderResourcesD3D12> m_pShaderResources;
75  ShaderResourceLayoutD3D12 m_StaticResLayout;
76  ShaderResourceCacheD3D12 m_ConstResCache;
77 };
78 
79 }
virtual void BindResources(IResourceMapping *pResourceMapping, Uint32 Flags) override
Binds shader resources.
Definition: ShaderD3D12Impl.cpp:62
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
Implementation of a dummy shader variable that silently ignores all operations.
Definition: ShaderBase.h:146
virtual IShaderVariable * GetShaderVariable(const Char *Name) override
Returns an interface to a shader variable. If the shader variable is not found, an interface to a dum...
Definition: ShaderD3D12Impl.cpp:67
Diligent::ShaderResourceLayoutD3D12 class.
Definition: ShaderResourceLayoutD3D12.h:125
Implementation of the Diligent::IShaderD3D12 interface.
Definition: ShaderD3D12Impl.h:46
Shader creation attributes.
Definition: Shader.h:204
Implementation of the Diligent::IRenderDeviceD3D12 interface.
Definition: RenderDeviceD3D12Impl.h:43