Diligent Engine  v.2.4.g
SwapChainD3D12Impl.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 
33 #include <dxgi1_4.h>
34 #include "SwapChainD3D12.h"
35 #include "SwapChainD3DBase.hpp"
36 
37 namespace Diligent
38 {
39 
41 class SwapChainD3D12Impl final : public SwapChainD3DBase<ISwapChainD3D12, IDXGISwapChain3>
42 {
43 public:
45 
48  const FullScreenModeDesc& FSDesc,
49  class RenderDeviceD3D12Impl* pRenderDeviceD3D12,
50  class DeviceContextD3D12Impl* pDeviceContextD3D12,
51  const NativeWindow& Window);
53 
55 
56 
57  virtual void DILIGENT_CALL_TYPE Present(Uint32 SyncInterval) override final;
58 
60  virtual void DILIGENT_CALL_TYPE Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform) override final;
61 
63  virtual IDXGISwapChain* DILIGENT_CALL_TYPE GetDXGISwapChain() override final { return m_pSwapChain; }
64 
67  {
68  auto CurrentBackBufferIndex = m_pSwapChain->GetCurrentBackBufferIndex();
69  VERIFY_EXPR(CurrentBackBufferIndex >= 0 && CurrentBackBufferIndex < m_SwapChainDesc.BufferCount);
70  return m_pBackBufferRTV[CurrentBackBufferIndex];
71  }
72 
74  virtual ITextureViewD3D12* DILIGENT_CALL_TYPE GetDepthBufferDSV() override final { return m_pDepthBufferDSV; }
75 
76 private:
77  virtual void UpdateSwapChain(bool CreateNew) override final;
78  void InitBuffersAndViews();
79 
80  std::vector<RefCntAutoPtr<ITextureViewD3D12>, STDAllocatorRawMem<RefCntAutoPtr<ITextureViewD3D12>>> m_pBackBufferRTV;
81  RefCntAutoPtr<ITextureViewD3D12> m_pDepthBufferDSV;
82 };
83 
84 } // namespace Diligent
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::SwapChainD3D12Impl::SwapChainD3D12Impl
SwapChainD3D12Impl(IReferenceCounters *pRefCounters, const SwapChainDesc &SwapChainDesc, const FullScreenModeDesc &FSDesc, class RenderDeviceD3D12Impl *pRenderDeviceD3D12, class DeviceContextD3D12Impl *pDeviceContextD3D12, const NativeWindow &Window)
Definition: SwapChainD3D12Impl.cpp:42
Diligent::SwapChainD3D12Impl::~SwapChainD3D12Impl
~SwapChainD3D12Impl()
Definition: SwapChainD3D12Impl.cpp:71
SwapChainD3D12.h
Diligent::SwapChainD3DBase< ISwapChainD3D12, IDXGISwapChain3 >::m_pSwapChain
CComPtr< IDXGISwapChain3 > m_pSwapChain
Definition: SwapChainD3DBase.hpp:364
Diligent::SwapChainD3D12Impl::GetDXGISwapChain
virtual IDXGISwapChain * GetDXGISwapChain() override final
Implementation of ISwapChainD3D12::GetDXGISwapChain().
Definition: SwapChainD3D12Impl.hpp:63
Diligent::SwapChainD3D12Impl
Swap chain implementation in Direct3D12 backend.
Definition: SwapChainD3D12Impl.hpp:41
Diligent::SwapChainD3D12Impl::GetCurrentBackBufferRTV
virtual ITextureViewD3D12 * GetCurrentBackBufferRTV() override final
Implementation of ISwapChain::GetCurrentBackBufferRTV() in Direct3D12 backend.
Definition: SwapChainD3D12Impl.hpp:66
Diligent::STDAllocator
Definition: STDAllocator.hpp:53
Diligent::SURFACE_TRANSFORM
SURFACE_TRANSFORM
The transform applied to the image content prior to presentation.
Definition: GraphicsTypes.h:1315
Diligent::RenderDeviceD3D12Impl
Render device implementation in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.hpp:70
Diligent::SwapChainD3DBase
Base implementation of a D3D swap chain.
Definition: SwapChainD3DBase.hpp:41
SwapChainD3DBase.hpp
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Diligent::RefCntAutoPtr
Template class that implements reference counting.
Definition: RefCntAutoPtr.hpp:73
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::SwapChainDesc::BufferCount
Uint32 BufferCount
The number of buffers in the swap chain.
Definition: GraphicsTypes.h:1379
Diligent::ITextureViewD3D12
Exposes Direct3D12-specific functionality of a texture view object.
Definition: TextureViewD3D12.h:49
Diligent::SwapChainDesc
Swap chain description.
Definition: GraphicsTypes.h:1347
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::SwapChainD3D12Impl::GetDepthBufferDSV
virtual ITextureViewD3D12 * GetDepthBufferDSV() override final
Implementation of ISwapChain::GetDepthBufferDSV() in Direct3D12 backend.
Definition: SwapChainD3D12Impl.hpp:74
Diligent::SwapChainBase< ISwapChainD3D12 >::m_SwapChainDesc
SwapChainDesc m_SwapChainDesc
Swap chain description.
Definition: SwapChainBase.hpp:122
Diligent::SwapChainD3D12Impl::UpdateSwapChain
virtual void UpdateSwapChain(bool CreateNew) override final
Definition: SwapChainD3D12Impl.cpp:171
Diligent::DeviceContextD3D12Impl
Device context implementation in Direct3D12 backend.
Definition: DeviceContextD3D12Impl.hpp:59
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Diligent::SwapChainD3D12Impl::Present
virtual void Present(Uint32 SyncInterval) override final
Implementation of ISwapChain::Present() in Direct3D12 backend.
Definition: SwapChainD3D12Impl.cpp:126
Diligent::SwapChainD3D12Impl::Resize
virtual void Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform) override final
Implementation of ISwapChain::Resize() in Direct3D12 backend.
Definition: SwapChainD3D12Impl.cpp:240
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::FullScreenModeDesc
Full screen mode description.
Definition: GraphicsTypes.h:1425