100 std::shared_ptr<bool>
alive = std::make_shared<bool>(
true);
157 static constexpr VkImageUsageFlags
kDrawImageUsage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
186 VkPipelineStageFlags2 srcStage, VkAccessFlags2 srcAccess,
187 VkPipelineStageFlags2 dstStage, VkAccessFlags2 dstAccess);
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
The Vulkan device the GUI renders with: its own, or a host's (SetExternalDevice).
Definition vk_device_context.h:114
The default graphics backend, on Vulkan 1.3.
Definition vk_graphics_context.h:46
Definition vk_window_context.h:91
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...
bool renderToImage
WindowFlags::RenderToImage: no surface.
Definition vk_window_context.h:138
VkExtent2D targetExtent
Definition vk_window_context.h:140
std::shared_ptr< bool > alive
False once the context is deleted: a live resize's onGui runs a whole app frame, which may close this...
Definition vk_window_context.h:100
static VulkanWindowContext * Create(tachyon::ID id, void *nativeHandle, tachyon::OSWindowHandle osHandle, tachyon::int2 size, tachyon::WindowFlags windowFlags, VulkanDeviceContext *deviceContext, tachyon::OnGuiFunc onGUI)
void DestroyDrawDepthImages(VulkanImage &drawImage, VulkanImage &depthImage)
bool presentPending
Recorded and submitted, waiting for PresentWindowFrame.
Definition vk_window_context.h:133
void CreateDrawDepthImages(VulkanImage &drawImage, VulkanImage &depthImage, VkFormat colorFormat)
Creates a draw and depth image pair sized to windowExtent; each FRAME_OVERLAP slot has its own.
std::chrono::steady_clock::time_point lastPresentEnd
When the last vkQueuePresentKHR returned.
Definition vk_window_context.h:124
VulkanDeviceContext * deviceContext
Definition vk_window_context.h:94
SwapchainState swapchain
Definition vk_window_context.h:104
VkExtent2D swapchainRequest
The size the swapchain was last remade for: a window grown smaller than its swapchain asks again once...
Definition vk_window_context.h:115
bool havePresentEnd
Definition vk_window_context.h:125
uint64_t frameNumber
frames recorded; never wraps
Definition vk_window_context.h:120
double lastBuildSeconds
Definition vk_window_context.h:126
bool IsTransparent() const override
Whether the window has WindowFlags::Transparent.
Definition vk_window_context.h:148
void ReadBackBuffer()
The readback buffer into cachedBitmap, once the copy into it is done.
uint64_t immediateReadbacks
Readbacks that needed a submit of their own (PerformReadback).
Definition vk_window_context.h:175
void PerformReadback(FrameData &frame)
Copies frame's draw image into the readback buffer in a submit of its own, waits, and reads it (ReadP...
double lastGpuFrameSeconds
Definition vk_window_context.h:180
tachyon::WindowFlags windowFlags
Definition vk_window_context.h:102
VkExtent2D requestedExtent
The size the last frame was recorded for; without a swapchain, what's drawn.
Definition vk_window_context.h:112
bool needsReadback
Transparent window: each frame is read back for the Windows layered window.
Definition vk_window_context.h:137
FrameData * readbackPending
Definition vk_window_context.h:134
double LastSwapchainWaitSeconds() const
The last presented frame's wait on the swapchain, in seconds (PresentWindowFrame's).
Definition vk_window_context.h:200
VkExtent2D windowExtent
Definition vk_window_context.h:109
bool resize_requested
Definition vk_window_context.h:117
WindowVulkanState state
Definition vk_window_context.h:105
void RenderWindowFrame(tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect, bool resizing) override
A frame is recorded (drawn and submitted), then presented.
float timestampPeriodNs
nanoseconds per timestamp tick; 0: no timestamps
Definition vk_window_context.h:181
double acquireSeconds
How long this frame's swapchain image took to acquire; counted with present's wait.
Definition vk_window_context.h:129
double lastSwapchainWaitSeconds
The last presented frame's swapchain wait: acquiring its image and presenting it.
Definition vk_window_context.h:131
VkImage targetImage
host image each frame is copied into
Definition vk_window_context.h:139
bool lastBuildValid
Definition vk_window_context.h:127
void UpdateTransparentWindow() override
A transparent window the OS composites from a CPU copy (a layered window on Windows): shows its last ...
tachyon::vulkan::AllocatedBuffer readbackBuffer
Definition vk_window_context.h:142
~VulkanWindowContext() override
Definition vk_window_context.h:191
tachyon::ID GetID() const override
The GUI window's ID; the backend passes it with the window's input.
Definition vk_window_context.h:194
VkSurfaceKHR surface
Definition vk_window_context.h:108
std::vector< uint8_t > cachedBitmap
Definition vk_window_context.h:143
static constexpr VkImageUsageFlags kDrawImageUsage
The draw image is drawn into as a color attachment and copied out; it's no storage image,...
Definition vk_window_context.h:157
std::optional< double > PresentWindowFrame() override
May wait for vsync; nothing to do for a render-to-image window.
void SetImageTarget(VkImage image, VkExtent2D extent)
The host image each frame is copied into (render-to-image windows); VK_NULL_HANDLE stops.
tachyon::ID id
Definition vk_window_context.h:93
void RecordReadbackCopy(VkCommandBuffer cmd, FrameData &frame)
Records the copy of frame's draw image into the readback buffer, made visible to the host,...
void FlushWindowContext()
VkExtent2D drawExtent
Definition vk_window_context.h:110
double LastGpuFrameSeconds() const
GPU time of the drawing of this window's most recent finished frame, in seconds; 0 until one finished...
Definition vk_window_context.h:179
bool targetWritten
targetImage holds a previous frame
Definition vk_window_context.h:141
tachyon::OnGuiFunc onGui
Definition vk_window_context.h:97
void ResizeSwapchain(tachyon::int2 size)
bool freeze_rendering
Definition vk_window_context.h:118
FrameData & GetLastFrame()
void EndWindowFrame(FrameData ¤tFrame)
FrameData & GetCurrentFrame()
void * nativeHandle
Definition vk_window_context.h:96
tachyon::OSWindowHandle osHandle
Definition vk_window_context.h:95
bool RecordFrame(tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect, bool resizing)
False when the frame a live resize ran deleted this context: nothing of it may be used then.
void RecordWindowFrame(tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect) override
Records and submits a frame without presenting it; PresentWindowFrame presents.
tachyon::OSWindowHandle GetWindowHandle() const override
The window it was created for.
Definition vk_window_context.h:207
VkCommandBuffer BeginWindowFrame(FrameData ¤tFrame, VulkanGraphicsContext *graphics=nullptr)
bool NeedsRecord() const override
True when the window must be recorded this frame even though its draws didn't change (its swapchain i...
Definition vk_window_context.h:201
tachyon::int2 mouse_pos
Definition vk_window_context.h:119
void TransitionTarget(VkCommandBuffer cmd, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags2 srcStage, VkAccessFlags2 srcAccess, VkPipelineStageFlags2 dstStage, VkAccessFlags2 dstAccess)
constexpr unsigned int FRAME_OVERLAP
Definition vk_window_context.h:26
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
@ Transparent
Definition gui_window_flags.h:27
@ None
Definition gui_window_flags.h:15
Definition vk_defaults.h:6
Definition gui_logging.h:24
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
Definition gui_base_types.h:406
Integer 2D vector.
Definition gui_base_types.h:18
Definition vk_meshes.h:14
Library internal: destroy functions that run later, newest first.
Definition vk_device_context.h:47
Definition vk_descriptors.h:56
Definition vk_window_context.h:29
DeletionQueue deletionQueue
Definition vk_window_context.h:41
VkCommandPool commandPool
Definition vk_window_context.h:43
VulkanImage depthImage
Definition vk_window_context.h:57
uint64_t imageDescriptorsVersion
Definition vk_window_context.h:39
size_t primitiveUploadCapacity
Definition vk_window_context.h:50
VkFence renderFence
Definition vk_window_context.h:31
Buffer primitiveUploadBuffer
Fence-protected, persistently mapped upload arena for GUI primitive streams, reused each time this fr...
Definition vk_window_context.h:48
VkSemaphore swapchainSemaphore
Definition vk_window_context.h:30
DeletionQueue flushQueue
Definition vk_window_context.h:40
VkCommandBuffer mainCommandBuffer
Definition vk_window_context.h:44
VulkanImage drawImage
Per-slot draw and depth images, so in-flight frames don't share them (frame N's blit reads drawImage ...
Definition vk_window_context.h:56
VkImageLayout drawImageLayout
The layout the slot's last commands left drawImage in: COLOR_ATTACHMENT_OPTIMAL after drawing,...
Definition vk_window_context.h:60
VkQueryPool timestamps
GPU timestamps at the start and the end of the frame's drawing; none when the queue can't time.
Definition vk_window_context.h:64
VkDeviceAddress primitiveUploadAddress
Definition vk_window_context.h:49
DescriptorAllocatorGrowable frameDescriptors
Holds imageDescriptors alone; cleared when that is made again.
Definition vk_window_context.h:34
VkDescriptorSet imageDescriptors
The image set's slots as this frame slot last wrote them, bound again while the set's version is imag...
Definition vk_window_context.h:38
bool timestampsWritten
by the last frame in this slot
Definition vk_window_context.h:65
size_t primitiveUploadOffset
Definition vk_window_context.h:51
Definition vk_window_context.h:69
uint32_t swapchainImageIndex
Definition vk_window_context.h:79
::std::vector< VkImageView > swapchainImageViews
Definition vk_window_context.h:75
::std::vector< VkSemaphore > presentSemaphores
Definition vk_window_context.h:78
VkPresentModeKHR presentMode
Definition vk_window_context.h:80
VkExtent2D swapchainExtent
Definition vk_window_context.h:73
VkFormat swapchainImageFormat
Definition vk_window_context.h:72
VkSwapchainKHR swapchain
Definition vk_window_context.h:71
::std::vector< VkImage > swapchainImages
Definition vk_window_context.h:74
Definition vk_window_context.h:84
FrameData frames[FRAME_OVERLAP]
Definition vk_window_context.h:86
VkCommandBuffer commandBuffer
Definition vk_window_context.h:87