[D3D12] Context Begin/EndSwap
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#ifndef XENIA_UI_D3D12_D3D12_CONTEXT_H_
|
||||
#define XENIA_UI_D3D12_D3D12_CONTEXT_H_
|
||||
|
||||
#include "xenia/ui/d3d12/command_list.h"
|
||||
#include "xenia/ui/d3d12/cpu_fence.h"
|
||||
#include "xenia/ui/d3d12/d3d12_api.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
@@ -30,11 +31,26 @@ class D3D12Context : public GraphicsContext {
|
||||
|
||||
bool WasLost() override { return context_lost_; }
|
||||
|
||||
void BeginSwap() override;
|
||||
void EndSwap() override;
|
||||
|
||||
std::unique_ptr<RawImage> Capture() override;
|
||||
|
||||
// The count of copies of transient objects (like command lists, dynamic
|
||||
// descriptor heaps) that must be kept when rendering with this context.
|
||||
static constexpr uint32_t kFrameQueueLength = 3;
|
||||
uint32_t GetCurrentQueueFrame() { return current_queue_frame_; }
|
||||
void AwaitAllFramesCompletion();
|
||||
|
||||
static constexpr DXGI_FORMAT kSwapChainFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
ID3D12Resource* GetSwapChainBuffer(uint32_t buffer_index) const {
|
||||
return swap_chain_buffers_[buffer_index];
|
||||
}
|
||||
uint32_t GetSwapChainBackBufferIndex() const {
|
||||
return swap_chain_back_buffer_index_;
|
||||
}
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE GetSwapChainBufferRTV(
|
||||
uint32_t buffer_index) const;
|
||||
|
||||
private:
|
||||
friend class D3D12Provider;
|
||||
@@ -43,17 +59,26 @@ class D3D12Context : public GraphicsContext {
|
||||
|
||||
private:
|
||||
bool Initialize();
|
||||
bool InitializeSwapChainBuffers();
|
||||
void Shutdown();
|
||||
|
||||
bool initialized_fully_ = false;
|
||||
|
||||
bool context_lost_ = false;
|
||||
|
||||
uint32_t current_queue_frame_ = 0;
|
||||
std::unique_ptr<CPUFence> fences_[kFrameQueueLength] = {};
|
||||
|
||||
static constexpr uint32_t kSwapChainBufferCount = 3;
|
||||
IDXGISwapChain3* swap_chain_ = nullptr;
|
||||
uint32_t swap_chain_width_ = 0, swap_chain_height_ = 0;
|
||||
ID3D12Resource* swap_chain_buffers_[kSwapChainBufferCount] = {};
|
||||
uint32_t swap_chain_back_buffer_index_ = 0;
|
||||
ID3D12DescriptorHeap* swap_chain_rtv_heap_ = nullptr;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE swap_chain_rtv_heap_start_;
|
||||
std::unique_ptr<CommandList> swap_command_lists_begin_[kFrameQueueLength] =
|
||||
{};
|
||||
std::unique_ptr<CommandList> swap_command_lists_end_[kFrameQueueLength] = {};
|
||||
|
||||
std::unique_ptr<D3D12ImmediateDrawer> immediate_drawer_ = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user