HatchitGraphics
ht_d3d12swapchain.h
1 
15 #pragma once
16 
17 #include <ht_platform.h>
18 #include <ht_directx.h>
19 #include <ht_swapchain.h>
20 
21 namespace Hatchit
22 {
23  namespace Graphics
24  {
25  namespace DX
26  {
27  class HT_API D3D12SwapChain : public SwapChain
28  {
29  static const uint32_t NUM_BUFFER_FRAMES = 2;
30  public:
31  D3D12SwapChain(HWND hwnd);
32 
33  ~D3D12SwapChain();
34 
35  void VClear(float* color) override;
36 
37  bool VInitialize(uint32_t width, uint32_t height) override;
38 
39  void VResize(uint32_t width, uint32_t height) override;
40 
41  void VExecute(std::vector<RenderPassHandle> renderPasses) override;
42 
43  void VSetInput(RenderPassHandle handle) override;
44 
45  void VPresent() override;
46 
47  CD3DX12_CPU_DESCRIPTOR_HANDLE GetRenderTargetView();
48 
49  CD3DX12_CPU_DESCRIPTOR_HANDLE GetDepthStencilView();
50 
51  ID3D12CommandList* GetCommandList();
52 
53  private:
54  IDXGISwapChain3* m_chain;
55  ID3D12CommandAllocator* m_commandAllocators[NUM_BUFFER_FRAMES];
56  ID3D12Resource* m_renderTargets[NUM_BUFFER_FRAMES];
57  ID3D12Resource* m_depthStencilTarget;
58  ID3D12DescriptorHeap* m_renderTargetHeap;
59  ID3D12DescriptorHeap* m_depthStencilTargetHeap;
60  ID3D12GraphicsCommandList* m_commandList;
61  HWND m_hwnd;
62 
63  //CPU-GPU ynchronization
64  ID3D12Fence* m_fence;
65  HANDLE m_fenceEvent;
66  uint64_t m_fenceValues[NUM_BUFFER_FRAMES];
67  uint64_t m_currentFence;
68 
69  bool CreateBuffers(uint32_t width, uint32_t height);
70  void MoveToNextFrame();
71  void WaitForGpu();
72  };
73  }
74  }
75 }
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_color.h:19
Definition: ht_swapchain.h:38
Definition: ht_d3d12swapchain.h:27