A sandbox to test and play around with DirectX 12 API.
This sandbox requires that the host machine has a DirectX 12 supported GPU and Windows 10 installed.
Procedure of initializing the Direct3D 12 goes as following.
(N is the amount of buffers used within the application)
- [Optional] Enable debug layer.
- [Optional] Enumerate and select a graphics adapter (IDXGIAdapter).
- Create a device (ID3D12Device).
- Create a command queue (ID3D12CommandQueue).
- Create a swap chain (IDXGISwapChain).
- Create a descriptor heap for render target views (ID3D12DescriptorHeap).
- Create N-amount of render target views (ID3D12Resource).
- Create a command allocator (ID3D12CommandAllocator).
Note that before initializing Direct3D, we also need to register window class and create a window.
Procedure of initializing resources (e.g. assets) for Direct3D 12 goes as following.
- Serialize and create a root signature (ID3D12RootSignature).
- Load and compile shaders (ID3DBlob).
- Create a pipeline state object (ID3D12PipelineState).
- Create and close a command list (ID3D12GraphicsCommandList).
- Create and fill vertex buffer (ID3D12Resource).
- Create a vertex buffer view (D3D12_VERTEX_BUFFER_VIEW).
- Wait until resources are in sync with GPU (ID3D12Fence).
Procedure of rendering in Direct3D 12 goes as following.
- Reset command list allocator for the next buffer (ID3D12CommandAllocator).
- Reset command list for the next buffer (ID3D12GraphicsCommandList).
- Set the graphics root signature.
- Set viewport.
- Set scissor rectangles.
- Use barrier to indicate that backbuffer is now the render target.
- Add commands into the command list.
- Use barrier to indicate that backbuffer is being presented after commands have finished.
- Close command list.
- Execute command list.
- Present the backbuffer.
- Wait until GPU has finished.