Diligent Engine  v.2.4.g
ShaderD3D12Impl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
34 #include "ShaderBase.hpp"
35 #include "ShaderD3DBase.hpp"
36 #include "ShaderResourcesD3D12.hpp"
37 
38 namespace Diligent
39 {
40 
42 class ShaderD3D12Impl final : public ShaderBase<EngineD3D12ImplTraits>, public ShaderD3DBase
43 {
44 public:
46 
47  ShaderD3D12Impl(IReferenceCounters* pRefCounters,
48  RenderDeviceD3D12Impl* pRenderDeviceD3D12,
49  const ShaderCreateInfo& ShaderCI);
51 
52  virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
53 
55  virtual Uint32 DILIGENT_CALL_TYPE GetResourceCount() const override final
56  {
57  return m_pShaderResources->GetTotalResources();
58  }
59 
61  virtual void DILIGENT_CALL_TYPE GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final
62  {
63  ResourceDesc = m_pShaderResources->GetHLSLShaderResourceDesc(Index);
64  }
65 
67  virtual void DILIGENT_CALL_TYPE GetHLSLResource(Uint32 Index, HLSLShaderResourceDesc& ResourceDesc) const override final
68  {
69  ResourceDesc = m_pShaderResources->GetHLSLShaderResourceDesc(Index);
70  }
71 
72  ID3DBlob* GetShaderByteCode() const { return m_pShaderByteCode; }
73  const Char* GetEntryPoint() const { return m_EntryPoint.c_str(); }
74 
75  const std::shared_ptr<const ShaderResourcesD3D12>& GetShaderResources() const { return m_pShaderResources; }
76 
77 private:
78  // ShaderResources class instance must be referenced through the shared pointer, because
79  // it is referenced by ShaderResourceLayoutD3D12 class instances
80  std::shared_ptr<const ShaderResourcesD3D12> m_pShaderResources;
81 
82  String m_EntryPoint;
83 };
84 
85 } // namespace Diligent
Diligent::ShaderD3D12Impl::GetResourceCount
virtual Uint32 GetResourceCount() const override final
Implementation of IShader::GetResourceCount() in Direct3D12 backend.
Definition: ShaderD3D12Impl.hpp:55
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::Char
char Char
Definition: BasicTypes.h:64
Diligent::ShaderD3D12Impl::ShaderD3D12Impl
ShaderD3D12Impl(IReferenceCounters *pRefCounters, RenderDeviceD3D12Impl *pRenderDeviceD3D12, const ShaderCreateInfo &ShaderCI)
Definition: ShaderD3D12Impl.cpp:87
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
ShaderBase.hpp
Diligent::HLSLShaderResourceDesc
HLSL resource description.
Definition: ShaderD3D.h:46
Diligent::ShaderBase
Template class implementing base functionality of the shader object.
Definition: ShaderBase.hpp:49
Diligent::ShaderD3D12Impl::GetEntryPoint
const Char * GetEntryPoint() const
Definition: ShaderD3D12Impl.hpp:73
Diligent::ShaderD3D12Impl::~ShaderD3D12Impl
~ShaderD3D12Impl()
Definition: ShaderD3D12Impl.cpp:114
Diligent::ShaderD3D12Impl::GetResourceDesc
virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc &ResourceDesc) const override final
Implementation of IShader::GetResource() in Direct3D12 backend.
Definition: ShaderD3D12Impl.hpp:61
Diligent::ShaderCreateInfo
Shader creation attributes.
Definition: Shader.h:241
Diligent::INTERFACE_ID
Unique interface identifier.
Definition: InterfaceID.h:37
Diligent::RenderDeviceD3D12Impl
Render device implementation in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.hpp:70
Diligent::ShaderD3D12Impl::GetShaderByteCode
ID3DBlob * GetShaderByteCode() const
Definition: ShaderD3D12Impl.hpp:72
Diligent::ShaderD3D12Impl::QueryInterface
virtual void QueryInterface(const INTERFACE_ID &IID, IObject **ppInterface) override final
Definition: ShaderD3D12Impl.cpp:118
ShaderResourcesD3D12.hpp
Diligent::ShaderD3D12Impl
Implementation of a shader object in Direct3D12 backend.
Definition: ShaderD3D12Impl.hpp:42
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::ShaderD3D12Impl::GetShaderResources
const std::shared_ptr< const ShaderResourcesD3D12 > & GetShaderResources() const
Definition: ShaderD3D12Impl.hpp:75
EngineD3D12ImplTraits.hpp
Diligent::ShaderResourceDesc
Shader resource description.
Definition: Shader.h:390
Diligent::ShaderD3DBase
Base implementation of a D3D shader.
Definition: ShaderD3DBase.hpp:40
Diligent::String
std::basic_string< Char > String
String variable.
Definition: BasicTypes.h:66
ShaderD3DBase.hpp
Diligent::ShaderD3DBase::m_pShaderByteCode
CComPtr< ID3DBlob > m_pShaderByteCode
Definition: ShaderD3DBase.hpp:46
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::ShaderD3D12Impl::GetHLSLResource
virtual void GetHLSLResource(Uint32 Index, HLSLShaderResourceDesc &ResourceDesc) const override final
Implementation of IShaderD3D::GetHLSLResource() in Direct3D12 backend.
Definition: ShaderD3D12Impl.hpp:67