Diligent Engine  v.2.4.g
TextureD3D12Impl.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 "TextureBase.hpp"
35 #include "TextureViewD3D12Impl.hpp"
36 #include "D3D12ResourceBase.hpp"
37 
38 namespace Diligent
39 {
40 
42 class TextureD3D12Impl final : public TextureBase<EngineD3D12ImplTraits>, public D3D12ResourceBase
43 {
44 public:
47 
48  // Creates a new D3D12 resource
50  FixedBlockMemoryAllocator& TexViewObjAllocator,
51  RenderDeviceD3D12Impl* pDeviceD3D12,
52  const TextureDesc& TexDesc,
53  const TextureData* pInitData = nullptr);
54 
55  // Attaches to an existing D3D12 resource
57  FixedBlockMemoryAllocator& TexViewObjAllocator,
58  class RenderDeviceD3D12Impl* pDeviceD3D12,
59  const TextureDesc& TexDesc,
60  RESOURCE_STATE InitialState,
61  ID3D12Resource* pTexture);
63 
65 
66 
67  virtual ID3D12Resource* DILIGENT_CALL_TYPE GetD3D12Texture() override final { return GetD3D12Resource(); }
68 
70  virtual void* DILIGENT_CALL_TYPE GetNativeHandle() override final { return GetD3D12Texture(); }
71 
73  virtual void DILIGENT_CALL_TYPE SetD3D12ResourceState(D3D12_RESOURCE_STATES state) override final;
74 
76  virtual D3D12_RESOURCE_STATES DILIGENT_CALL_TYPE GetD3D12ResourceState() const override final;
77 
78  D3D12_RESOURCE_DESC GetD3D12TextureDesc() const;
79 
80  const D3D12_PLACED_SUBRESOURCE_FOOTPRINT& GetStagingFootprint(Uint32 Subresource)
81  {
82  VERIFY_EXPR(m_StagingFootprints != nullptr);
84  return m_StagingFootprints[Subresource];
85  }
86 
87 protected:
88  void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) override final;
89  //void PrepareD3D12InitData(const TextureData &InitData, Uint32 NumSubresources, std::vector<D3D12_SUBRESOURCE_DATA> &D3D12InitData);
90 
91  void CreateSRV(TextureViewDesc& SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVHandle);
92  void CreateRTV(TextureViewDesc& RTVDesc, D3D12_CPU_DESCRIPTOR_HANDLE RTVHandle);
93  void CreateDSV(TextureViewDesc& DSVDesc, D3D12_CPU_DESCRIPTOR_HANDLE DSVHandle);
94  void CreateUAV(TextureViewDesc& UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVHandle);
95 
96  D3D12_PLACED_SUBRESOURCE_FOOTPRINT* m_StagingFootprints = nullptr;
97 };
98 
99 } // namespace Diligent
Diligent::RESOURCE_DIM_TEX_3D
@ RESOURCE_DIM_TEX_3D
Three-dimensional texture.
Definition: GraphicsTypes.h:264
D3D12ResourceBase.hpp
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::TextureDesc::ArraySize
Uint32 ArraySize
For a 1D array or 2D array, number of array slices.
Definition: Texture.h:61
Diligent::TextureViewD3D12Impl
Texture view object implementation in Direct3D12 backend.
Definition: TextureViewD3D12Impl.hpp:41
Diligent::DeviceObjectBase< EngineD3D12ImplTraits ::TextureInterface, EngineD3D12ImplTraits ::RenderDeviceImplType, TextureDesc >::m_Desc
TextureDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
Diligent::TextureD3D12Impl::SetD3D12ResourceState
virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state) override final
Implementation of ITextureD3D12::SetD3D12ResourceState().
Definition: TextureD3D12Impl.cpp:623
Diligent::ITextureView
Texture view interface.
Definition: TextureView.h:202
Diligent::TextureD3D12Impl::CreateDSV
void CreateDSV(TextureViewDesc &DSVDesc, D3D12_CPU_DESCRIPTOR_HANDLE DSVHandle)
Definition: TextureD3D12Impl.cpp:591
Diligent::TextureD3D12Impl::GetNativeHandle
virtual void * GetNativeHandle() override final
Implementation of ITexture::GetNativeHandle() in Direct3D12 backend.
Definition: TextureD3D12Impl.hpp:70
Diligent::TextureD3D12Impl
Implementation of a texture object in Direct3D12 backend.
Definition: TextureD3D12Impl.hpp:42
Diligent::TextureD3D12Impl::TextureD3D12Impl
TextureD3D12Impl(IReferenceCounters *pRefCounters, FixedBlockMemoryAllocator &TexViewObjAllocator, RenderDeviceD3D12Impl *pDeviceD3D12, const TextureDesc &TexDesc, const TextureData *pInitData=nullptr)
Definition: TextureD3D12Impl.cpp:132
Diligent::TextureD3D12Impl::~TextureD3D12Impl
~TextureD3D12Impl()
Definition: TextureD3D12Impl.cpp:550
Diligent::TextureDesc
Texture description.
Definition: Texture.h:47
Diligent::RenderDeviceD3D12Impl
Render device implementation in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.hpp:70
Diligent::TextureD3D12Impl::CreateRTV
void CreateRTV(TextureViewDesc &RTVDesc, D3D12_CPU_DESCRIPTOR_HANDLE RTVHandle)
Definition: TextureD3D12Impl.cpp:575
Diligent::TextureD3D12Impl::CreateSRV
void CreateSRV(TextureViewDesc &SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVHandle)
Definition: TextureD3D12Impl.cpp:560
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::TextureData
Describes the initial data to store in the texture.
Definition: Texture.h:221
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::TextureDesc::MipLevels
Uint32 MipLevels
Number of Mip levels in the texture. Multisampled textures can only have 1 Mip level....
Definition: Texture.h:72
Diligent::TextureBase
Base implementation of the ITexture interface.
Definition: TextureBase.hpp:71
Diligent::TextureD3D12Impl::CreateViewInternal
void CreateViewInternal(const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView) override final
Definition: TextureD3D12Impl.cpp:450
Diligent::TextureD3D12Impl::GetD3D12ResourceState
virtual D3D12_RESOURCE_STATES GetD3D12ResourceState() const override final
Implementation of ITextureD3D12::GetD3D12ResourceState().
Definition: TextureD3D12Impl.cpp:628
Diligent::TextureD3D12Impl::m_StagingFootprints
D3D12_PLACED_SUBRESOURCE_FOOTPRINT * m_StagingFootprints
Definition: TextureD3D12Impl.hpp:96
Diligent::TextureD3D12Impl::GetD3D12TextureDesc
D3D12_RESOURCE_DESC GetD3D12TextureDesc() const
Definition: TextureD3D12Impl.cpp:83
TextureViewD3D12Impl.hpp
EngineD3D12ImplTraits.hpp
Diligent::TextureD3D12Impl::CreateUAV
void CreateUAV(TextureViewDesc &UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVHandle)
Definition: TextureD3D12Impl.cpp:607
Diligent::TextureD3D12Impl::GetStagingFootprint
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT & GetStagingFootprint(Uint32 Subresource)
Definition: TextureD3D12Impl.hpp:80
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Diligent::FixedBlockMemoryAllocator
Memory allocator that allocates memory in a fixed-size chunks.
Definition: FixedBlockMemoryAllocator.hpp:56
Diligent::RESOURCE_STATE
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Diligent::TextureDesc::Type
RESOURCE_DIMENSION Type
Texture type. See Diligent::RESOURCE_DIMENSION for details.
Definition: Texture.h:50
Diligent::TextureViewDesc
Texture view description.
Definition: TextureView.h:80
TextureBase.hpp
Diligent::D3D12ResourceBase
Base implementation of a D3D12 resource.
Definition: D3D12ResourceBase.hpp:37
Diligent::TextureD3D12Impl::GetD3D12Texture
virtual ID3D12Resource * GetD3D12Texture() override final
Implementation of ITextureD3D12::GetD3D12Texture().
Definition: TextureD3D12Impl.hpp:67
Diligent::D3D12ResourceBase::GetD3D12Resource
ID3D12Resource * GetD3D12Resource() const
Definition: D3D12ResourceBase.hpp:43
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37