Diligent Engine  v.2.4.g
TextureBaseD3D11.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 "TextureViewD3D11Impl.hpp"
37 
38 namespace Diligent
39 {
40 
41 class FixedBlockMemoryAllocator;
42 
44 class TextureBaseD3D11 : public TextureBase<EngineD3D11ImplTraits>
45 {
46 public:
49 
51  FixedBlockMemoryAllocator& TexViewObjAllocator,
52  class RenderDeviceD3D11Impl* pDeviceD3D11,
53  const TextureDesc& TexDesc,
54  const TextureData* pInitData = nullptr);
56 
57  virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
58 
60  virtual ID3D11Resource* DILIGENT_CALL_TYPE GetD3D11Texture() override final { return m_pd3d11Texture; }
61 
63  virtual void* DILIGENT_CALL_TYPE GetNativeHandle() override final { return GetD3D11Texture(); }
64 
66  {
68  m_State |= State;
69  }
70 
72  {
74  m_State &= ~State;
77  }
78 
79 protected:
80  void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) override final;
81  void PrepareD3D11InitData(const TextureData* pInitData,
82  Uint32 NumSubresources,
83  std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA>>& D3D11InitData);
84 
85  // clang-format off
86  virtual void CreateSRV(TextureViewDesc& SRVDesc, ID3D11ShaderResourceView** ppD3D11SRV) = 0;
87  virtual void CreateRTV(TextureViewDesc& RTVDesc, ID3D11RenderTargetView** ppD3D11RTV) = 0;
88  virtual void CreateDSV(TextureViewDesc& DSVDesc, ID3D11DepthStencilView** ppD3D11DSV) = 0;
89  virtual void CreateUAV(TextureViewDesc& UAVDesc, ID3D11UnorderedAccessView** ppD3D11UAV) = 0;
90  // clang-format on
91 
92  friend class RenderDeviceD3D11Impl;
94  CComPtr<ID3D11Resource> m_pd3d11Texture;
95 };
96 
97 } // namespace Diligent
Diligent::TextureBaseD3D11::CreateRTV
virtual void CreateRTV(TextureViewDesc &RTVDesc, ID3D11RenderTargetView **ppD3D11RTV)=0
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
RenderDeviceD3D11Impl.hpp
Diligent::TextureBaseD3D11::ClearState
void ClearState(RESOURCE_STATE State)
Definition: TextureBaseD3D11.hpp:71
Diligent::TextureBase< EngineD3D11ImplTraits >::IsInKnownState
bool IsInKnownState() const
Definition: TextureBase.hpp:260
Diligent::TextureBase< EngineD3D11ImplTraits >::m_State
RESOURCE_STATE m_State
Definition: TextureBase.hpp:310
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::TextureBaseD3D11::GetNativeHandle
virtual void * GetNativeHandle() override final
Implementation of ITexture::GetNativeHandle().
Definition: TextureBaseD3D11.hpp:63
Diligent::TextureBaseD3D11::CreateUAV
virtual void CreateUAV(TextureViewDesc &UAVDesc, ID3D11UnorderedAccessView **ppD3D11UAV)=0
Diligent::ITextureView
Texture view interface.
Definition: TextureView.h:202
Diligent::TextureBaseD3D11::m_pd3d11Texture
CComPtr< ID3D11Resource > m_pd3d11Texture
D3D11 texture.
Definition: TextureBaseD3D11.hpp:94
Diligent::TextureBaseD3D11
Base implementation of a texture object in Direct3D11 backend.
Definition: TextureBaseD3D11.hpp:44
Diligent::TextureBaseD3D11::CreateSRV
virtual void CreateSRV(TextureViewDesc &SRVDesc, ID3D11ShaderResourceView **ppD3D11SRV)=0
Diligent::INTERFACE_ID
Unique interface identifier.
Definition: InterfaceID.h:37
Diligent::TextureViewD3D11Impl
Texture view implementation in Direct3D11 backend.
Definition: TextureViewD3D11Impl.hpp:42
Diligent::STDAllocator
Definition: STDAllocator.hpp:53
Diligent::TextureBaseD3D11::GetD3D11Texture
virtual ID3D11Resource * GetD3D11Texture() override final
Implementation of ITextureD3D11::GetD3D11Texture().
Definition: TextureBaseD3D11.hpp:60
Diligent::TextureDesc
Texture description.
Definition: Texture.h:47
Diligent::TextureBaseD3D11::~TextureBaseD3D11
~TextureBaseD3D11()
Definition: TextureBaseD3D11.cpp:160
Diligent::TextureBaseD3D11::AddState
void AddState(RESOURCE_STATE State)
Definition: TextureBaseD3D11.hpp:65
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::RESOURCE_STATE_UNDEFINED
@ RESOURCE_STATE_UNDEFINED
The resource state is known to the engine, but is undefined. A resource is typically in an undefined ...
Definition: GraphicsTypes.h:2820
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::TextureBaseD3D11::PrepareD3D11InitData
void PrepareD3D11InitData(const TextureData *pInitData, Uint32 NumSubresources, std::vector< D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem< D3D11_SUBRESOURCE_DATA >> &D3D11InitData)
Definition: TextureBaseD3D11.cpp:136
Diligent::TextureBase
Base implementation of the ITexture interface.
Definition: TextureBase.hpp:71
Diligent::RESOURCE_STATE_UNKNOWN
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
Diligent::TextureBaseD3D11::TextureBaseD3D11
TextureBaseD3D11(IReferenceCounters *pRefCounters, FixedBlockMemoryAllocator &TexViewObjAllocator, class RenderDeviceD3D11Impl *pDeviceD3D11, const TextureDesc &TexDesc, const TextureData *pInitData=nullptr)
Definition: TextureBaseD3D11.cpp:39
Diligent::TextureBaseD3D11::QueryInterface
virtual void QueryInterface(const INTERFACE_ID &IID, IObject **ppInterface) override final
TextureViewD3D11Impl.hpp
EngineD3D11ImplTraits.hpp
Diligent::TextureBaseD3D11::CreateViewInternal
void CreateViewInternal(const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView) override final
Definition: TextureBaseD3D11.cpp:62
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Diligent::TextureBaseD3D11::CreateDSV
virtual void CreateDSV(TextureViewDesc &DSVDesc, ID3D11DepthStencilView **ppD3D11DSV)=0
Diligent::RenderDeviceD3D11Impl
Render device implementation in Direct3D11 backend.
Definition: RenderDeviceD3D11Impl.hpp:40
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::TextureViewDesc
Texture view description.
Definition: TextureView.h:80
TextureBase.hpp
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37