HatchitGraphics
ht_d3d12deviceresources.h
1 
15 #pragma once
16 
17 #include <ht_platform.h>
18 #include <ht_directx.h>
19 #include <ht_d3d12rootlayout.h>
20 
21 namespace Hatchit {
22  namespace Graphics {
23 
24  namespace DX
25  {
26  class HT_API D3D12DeviceResources
27  {
28  static const int NUM_BUFFER_FRAMES = 2;
29  public:
31 
33 
34  void Present();
35  void WaitForGpu();
36  void ExecuteCommandList();
37  void MoveToNextFrame();
38  void ValidateDevice();
39  bool Initialize(HWND hwnd, uint32_t width, uint32_t height);
40  void Resize(uint32_t width, uint32_t height);
41 
42 
43  ID3D12Device* GetDevice();
44  D3D12RootLayout* GetRootLayout();
45  IDXGISwapChain3* GetSwapChain();
46  ID3D12Resource* GetRenderTarget();
47  ID3D12Resource* GetDepthStencil();
48  ID3D12CommandAllocator* GetCommandAllocator();
49  ID3D12CommandQueue* GetCommandQueue();
50  ID3D12GraphicsCommandList* GetCommandList();
51  D3D12_VIEWPORT GetScreenViewport();
52  uint32_t GetCurrentFrameIndex();
53 
54  CD3DX12_CPU_DESCRIPTOR_HANDLE GetRenderTargetView();
55  CD3DX12_CPU_DESCRIPTOR_HANDLE GetDepthStencilView();
56  private:
57  HWND m_hwnd;
58  bool m_deviceRemoved;
59  uint32_t m_currentFrame;
60  ID3D12Fence* m_fence;
61  HANDLE m_fenceEvent;
62  uint64_t m_fenceValues[NUM_BUFFER_FRAMES];
63  uint64_t m_currentFence;
64 
65  D3D12_VIEWPORT m_viewport;
66  D3D12_RECT m_scissorRect;
67  ID3D12Device* m_device;
68  D3D12RootLayoutHandle m_rootLayout;
69  IDXGISwapChain3* m_swapChain;
70  DXGI_SWAP_CHAIN_DESC m_swapChainDesc;
71  ID3D12CommandQueue* m_commandQueue;
72  ID3D12CommandAllocator* m_commandAllocators[NUM_BUFFER_FRAMES];
73  ID3D12GraphicsCommandList* m_commandList;
74  ID3D12Resource* m_renderTargets[NUM_BUFFER_FRAMES];
75  ID3D12Resource* m_depthStencil;
76  ID3D12DescriptorHeap* m_renderTargetViewHeap;
77  uint32_t m_renderTargetViewHeapSize;
78  ID3D12DescriptorHeap* m_depthStencilHeap;
79 
80  private:
81  bool CreateDeviceResources(HWND hwnd, uint32_t width, uint32_t height);
82  HRESULT CheckHardwareAdapter(IDXGIFactory2 * pFactory, IDXGIAdapter1 ** ppAdapter);
83  void DestroyDeviceResources();
84  bool CreateBuffers(uint32_t width, uint32_t height);
85  };
86  }
87  }
88 }
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_color.h:19
Definition: ht_d3d12rootlayout.h:30
Definition: ht_d3d12deviceresources.h:26