31 ID GetID()
const override {
return m_id; }
43 static constexpr uint32_t kFrames = 2;
47 ComPtr<ID3D12CommandAllocator> allocator;
48 ComPtr<ID3D12Resource> drawTexture;
49 D3D12_RESOURCE_STATES drawState = D3D12_RESOURCE_STATE_RENDER_TARGET;
51 ComPtr<ID3D12DescriptorHeap> images;
53 UINT64 fenceValue = 0;
57 void Record(
IntRect rect,
bool resizing);
58 bool MakeSizedResources(uint32_t width, uint32_t height);
59 void ReleaseSizedResources();
60 void Draw(Frame& frame, D3D12_CPU_DESCRIPTOR_HANDLE rtv);
62 void CopyToTarget(Frame& frame, ID3D12Resource* target);
64 float ClearAlpha()
const {
return m_layered || m_toImage ? 0.0f : 1.0f; }
66 D3D12GraphicsContext& m_graphics;
67 D3D12GraphicsContext::Impl& m_device;
75 std::shared_ptr<bool> m_alive = std::make_shared<bool>(
true);
79 bool m_toImage =
false;
81 bool m_layered =
false;
82 std::vector<uint8_t> m_layeredPixels;
83 uint2 m_layeredSize {};
84 ComPtr<IDXGISwapChain3> m_swapchain;
85 std::array<ComPtr<ID3D12Resource>, kFrames> m_buffers;
86 ComPtr<ID3D12DescriptorHeap> m_rtvHeap;
89 ComPtr<ID3D12Resource> m_depth;
90 ComPtr<ID3D12DescriptorHeap> m_dsvHeap;
91 ComPtr<ID3D12GraphicsCommandList> m_list;
92 std::array<Frame, kFrames> m_frames;
93 uint32_t m_frameIndex = 0;
94 uint32_t m_width = 0, m_height = 0;
95 bool m_presentPending =
false;
96 std::optional<uint32_t> m_lastFrame;
99 ComPtr<ID3D12CommandAllocator> m_readAllocator;
100 ComPtr<ID3D12GraphicsCommandList> m_readList;
101 ComPtr<ID3D12Resource> m_readback;
102 UINT64 m_readbackSize = 0;
A graphics backend: the device, the window contexts that render the GUI's windows,...
Definition gui_graphics_context.h:53
A window's rendering state: made by GraphicsContext::CreateWindowContext for each OS window,...
Definition gui_window_backend.h:72
Definition d3d12_graphics_context.h:67
Definition d3d12_window_context.h:23
static D3D12WindowContext * Create(D3D12GraphicsContext &graphics, HWND window, OSWindowHandle osHandle, ID id, int2 size, WindowFlags flags, OnGuiFunc onGui)
window is null for a render-to-image window.
ID GetID() const override
The GUI window's ID; the backend passes it with the window's input.
Definition d3d12_window_context.h:31
bool ReadPixels(std::span< uint8_t > bgra) override
The last rendered frame, BGRA8 with tightly packed rows; bgra holds width x height x 4 bytes of the w...
void RecordWindowFrame(GraphicsContext *graphicsContext, IntRect rect) override
Records and submits a frame without presenting it; PresentWindowFrame presents.
OSWindowHandle GetWindowHandle() const override
The window it was created for.
Definition d3d12_window_context.h:32
std::optional< double > PresentWindowFrame() override
May wait for vsync; nothing to do for a render-to-image window.
~D3D12WindowContext() override
void RenderWindowFrame(GraphicsContext *graphicsContext, IntRect rect, bool resizing) override
resizing: a live resize's redraw, which lays the window out again (its onGui) before it's drawn at th...
bool IsTransparent() const override
Whether the window has WindowFlags::Transparent.
std::function< void()> OnGuiFunc
Definition gui_base_types.h:13
WindowFlags
How an OS window is made and behaves (IWindowBackend::CreateWindow); flags combine with |.
Definition gui_window_flags.h:14
void * OSWindowHandle
An OS window, opaque; what it points to is up to the window backend.
Definition gui_window_backend.h:37
Definition d3d12_common.h:22
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Definition gui_base_types.h:406
A frame slot's transient data: one upload buffer, written from the start each time the slot comes rou...
Definition d3d12_rhi.h:18
Integer 2D vector.
Definition gui_base_types.h:18
Definition gui_base_types.h:74