Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
bicameral::gpu::SwapChain Class Reference

#include <swap_chain.h>

Classes

struct  HandleCloser

Public Member Functions

bool WaitForFrame (uint32_t timeoutMs) const
uint32_t CurrentIndex () const
ID3D12Resource * BackBuffer (uint32_t index) const
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView (uint32_t index) const
uint32_t Width () const
uint32_t Height () const
bool Present (bool vsync) const
bool Resize (ID3D12Device *device, uint32_t width, uint32_t height)

Static Public Member Functions

static std::expected< SwapChain, std::string > Create (ID3D12Device *device, IDXGIFactory6 *factory, ID3D12CommandQueue *directQueue, HWND window, uint32_t maxFrameLatency)

Static Public Attributes

static constexpr uint32_t BUFFER_COUNT = 3
static constexpr DXGI_FORMAT FORMAT = DXGI_FORMAT_R8G8B8A8_UNORM

Private Member Functions

 SwapChain ()=default
bool AcquireBuffers (ID3D12Device *device)

Private Attributes

ComPtr< IDXGISwapChain3 > m_swapChain
ComPtr< ID3D12DescriptorHeap > m_rtvHeap
std::array< ComPtr< ID3D12Resource >, BUFFER_COUNT > m_buffers
uint32_t m_rtvStride = 0
std::unique_ptr< void, HandleCloser > m_frameLatencyWaitable
uint32_t m_width = 0
uint32_t m_height = 0
bool m_tearingSupported = false

Detailed Description

Definition at line 19 of file swap_chain.h.

Constructor & Destructor Documentation

◆ SwapChain()

bicameral::gpu::SwapChain::SwapChain ( )
privatedefault

Referenced by Create().

Here is the caller graph for this function:

Member Function Documentation

◆ AcquireBuffers()

bool bicameral::gpu::SwapChain::AcquireBuffers ( ID3D12Device * device)
private

Definition at line 73 of file swap_chain.cpp.

References BICAMERAL_CHECK_HR, BUFFER_COUNT, bicameral::Gpu, m_buffers, m_height, m_swapChain, m_width, and RenderTargetView().

Referenced by Create(), and Resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BackBuffer()

ID3D12Resource * bicameral::gpu::SwapChain::BackBuffer ( uint32_t index) const
inlinenodiscard

Definition at line 32 of file swap_chain.h.

References m_buffers.

◆ Create()

std::expected< SwapChain, std::string > bicameral::gpu::SwapChain::Create ( ID3D12Device * device,
IDXGIFactory6 * factory,
ID3D12CommandQueue * directQueue,
HWND window,
uint32_t maxFrameLatency )
staticnodiscard

Definition at line 22 of file swap_chain.cpp.

References AcquireBuffers(), BUFFER_COUNT, bicameral::DescribeHresult(), FORMAT, bicameral::Gpu, bicameral::Info, bicameral::Log(), m_frameLatencyWaitable, m_height, m_rtvHeap, m_rtvStride, m_swapChain, m_tearingSupported, m_width, and SwapChain().

Referenced by bicameral::frame::anonymous_namespace{frame_loop.cpp}::CreateParts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CurrentIndex()

uint32_t bicameral::gpu::SwapChain::CurrentIndex ( ) const
inlinenodiscard

Definition at line 31 of file swap_chain.h.

References m_swapChain.

◆ Height()

uint32_t bicameral::gpu::SwapChain::Height ( ) const
inlinenodiscard

Definition at line 35 of file swap_chain.h.

References m_height.

◆ Present()

bool bicameral::gpu::SwapChain::Present ( bool vsync) const

Definition at line 102 of file swap_chain.cpp.

References BICAMERAL_CHECK_HR, bicameral::Gpu, m_swapChain, and m_tearingSupported.

◆ RenderTargetView()

D3D12_CPU_DESCRIPTOR_HANDLE bicameral::gpu::SwapChain::RenderTargetView ( uint32_t index) const
nodiscard

Definition at line 91 of file swap_chain.cpp.

References m_rtvHeap, and m_rtvStride.

Referenced by AcquireBuffers().

Here is the caller graph for this function:

◆ Resize()

bool bicameral::gpu::SwapChain::Resize ( ID3D12Device * device,
uint32_t width,
uint32_t height )

Definition at line 107 of file swap_chain.cpp.

References AcquireBuffers(), BICAMERAL_CHECK_HR, BUFFER_COUNT, FORMAT, bicameral::Gpu, m_buffers, m_swapChain, and m_tearingSupported.

Here is the call graph for this function:

◆ WaitForFrame()

bool bicameral::gpu::SwapChain::WaitForFrame ( uint32_t timeoutMs) const

Definition at line 98 of file swap_chain.cpp.

References m_frameLatencyWaitable.

◆ Width()

uint32_t bicameral::gpu::SwapChain::Width ( ) const
inlinenodiscard

Definition at line 34 of file swap_chain.h.

References m_width.

Member Data Documentation

◆ BUFFER_COUNT

uint32_t bicameral::gpu::SwapChain::BUFFER_COUNT = 3
staticconstexpr

Definition at line 21 of file swap_chain.h.

Referenced by AcquireBuffers(), Create(), and Resize().

◆ FORMAT

DXGI_FORMAT bicameral::gpu::SwapChain::FORMAT = DXGI_FORMAT_R8G8B8A8_UNORM
staticconstexpr

◆ m_buffers

std::array<ComPtr<ID3D12Resource>, BUFFER_COUNT> bicameral::gpu::SwapChain::m_buffers
private

Definition at line 55 of file swap_chain.h.

Referenced by AcquireBuffers(), BackBuffer(), and Resize().

◆ m_frameLatencyWaitable

std::unique_ptr<void, HandleCloser> bicameral::gpu::SwapChain::m_frameLatencyWaitable
private

Definition at line 59 of file swap_chain.h.

Referenced by Create(), and WaitForFrame().

◆ m_height

uint32_t bicameral::gpu::SwapChain::m_height = 0
private

Definition at line 63 of file swap_chain.h.

Referenced by AcquireBuffers(), Create(), and Height().

◆ m_rtvHeap

ComPtr<ID3D12DescriptorHeap> bicameral::gpu::SwapChain::m_rtvHeap
private

Definition at line 54 of file swap_chain.h.

Referenced by Create(), and RenderTargetView().

◆ m_rtvStride

uint32_t bicameral::gpu::SwapChain::m_rtvStride = 0
private

Definition at line 56 of file swap_chain.h.

Referenced by Create(), and RenderTargetView().

◆ m_swapChain

ComPtr<IDXGISwapChain3> bicameral::gpu::SwapChain::m_swapChain
private

Definition at line 53 of file swap_chain.h.

Referenced by AcquireBuffers(), Create(), CurrentIndex(), Present(), and Resize().

◆ m_tearingSupported

bool bicameral::gpu::SwapChain::m_tearingSupported = false
private

Definition at line 64 of file swap_chain.h.

Referenced by Create(), Present(), and Resize().

◆ m_width

uint32_t bicameral::gpu::SwapChain::m_width = 0
private

Definition at line 62 of file swap_chain.h.

Referenced by AcquireBuffers(), Create(), and Width().


The documentation for this class was generated from the following files: