|
TachyonUI 1.1.0
High-performance UI for building tools.
|
#include <gui_core/graphics/vulkan/vk_window_context.h>
Public Member Functions | |
| FrameData & | GetCurrentFrame () |
| FrameData & | GetLastFrame () |
| bool | IsTransparent () const override |
| Whether the window has WindowFlags::Transparent. | |
| void | CreateSwapchain () |
| void | DestroySwapchain () |
| void | ResizeSwapchain (tachyon::int2 size) |
| void | FlushWindowContext () |
| 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. | |
| void | DestroyDrawDepthImages (VulkanImage &drawImage, VulkanImage &depthImage) |
| VkCommandBuffer | BeginWindowFrame (FrameData ¤tFrame, VulkanGraphicsContext *graphics=nullptr) |
| void | EndWindowFrame (FrameData ¤tFrame) |
| void | PerformReadback (FrameData &frame) |
| Copies frame's draw image into the readback buffer in a submit of its own, waits, and reads it (ReadPixels of a window whose frames aren't copied out themselves). | |
| void | RecordReadbackCopy (VkCommandBuffer cmd, FrameData &frame) |
| Records the copy of frame's draw image into the readback buffer, made visible to the host, into cmd. | |
| void | ReadBackBuffer () |
| The readback buffer into cachedBitmap, once the copy into it is done. | |
| double | LastGpuFrameSeconds () const |
| GPU time of the drawing of this window's most recent finished frame, in seconds; 0 until one finished, or when the device can't time. | |
| 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 window's pixel size. | |
| void | SetImageTarget (VkImage image, VkExtent2D extent) |
| The host image each frame is copied into (render-to-image windows); VK_NULL_HANDLE stops. | |
| void | TransitionTarget (VkCommandBuffer cmd, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags2 srcStage, VkAccessFlags2 srcAccess, VkPipelineStageFlags2 dstStage, VkAccessFlags2 dstAccess) |
| void | Destroy () |
| ~VulkanWindowContext () override | |
| tachyon::ID | GetID () const override |
| The GUI window's ID; the backend passes it with the window's input. | |
| void | RenderWindowFrame (tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect, bool resizing) override |
| A frame is recorded (drawn and submitted), then presented. | |
| void | RecordWindowFrame (tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect) override |
| Records and submits a frame without presenting it; PresentWindowFrame presents. | |
| std::optional< double > | PresentWindowFrame () override |
| May wait for vsync; nothing to do for a render-to-image window. | |
| double | LastSwapchainWaitSeconds () const |
| The last presented frame's wait on the swapchain, in seconds (PresentWindowFrame's). | |
| bool | NeedsRecord () const override |
| True when the window must be recorded this frame even though its draws didn't change (its swapchain is out of date). | |
| 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 | UpdateTransparentWindow () override |
| A transparent window the OS composites from a CPU copy (a layered window on Windows): shows its last frame again, where the window is. | |
| tachyon::OSWindowHandle | GetWindowHandle () const override |
| The window it was created for. | |
| Public Member Functions inherited from tachyon::IWindowContext | |
| virtual | ~IWindowContext ()=default |
Static Public Member Functions | |
| static VulkanWindowContext * | Create (tachyon::ID id, void *nativeHandle, tachyon::OSWindowHandle osHandle, tachyon::int2 size, tachyon::WindowFlags windowFlags, VulkanDeviceContext *deviceContext, tachyon::OnGuiFunc onGUI) |
Public Attributes | |
| tachyon::ID | id { tachyon::ID::Invalid()} |
| VulkanDeviceContext * | deviceContext { nullptr } |
| tachyon::OSWindowHandle | osHandle { nullptr } |
| void * | nativeHandle { nullptr } |
| tachyon::OnGuiFunc | onGui {} |
| std::shared_ptr< bool > | alive = std::make_shared<bool>(true) |
| False once the context is deleted: a live resize's onGui runs a whole app frame, which may close this very window (a drag preview whose drag ended). | |
| tachyon::WindowFlags | windowFlags = tachyon::WindowFlags::None |
| SwapchainState | swapchain = {} |
| WindowVulkanState | state = {} |
| VkSurfaceKHR | surface = {} |
| VkExtent2D | windowExtent = {} |
| VkExtent2D | drawExtent = {} |
| VkExtent2D | requestedExtent = {} |
| The size the last frame was recorded for; without a swapchain, what's drawn. | |
| VkExtent2D | swapchainRequest = {} |
| The size the swapchain was last remade for: a window grown smaller than its swapchain asks again once, even on drivers that don't report it out of date. | |
| bool | resize_requested { false } |
| bool | freeze_rendering { false } |
| tachyon::int2 | mouse_pos = { 0,0 } |
| uint64_t | frameNumber { 0 } |
| frames recorded; never wraps | |
| std::chrono::steady_clock::time_point | lastPresentEnd {} |
| When the last vkQueuePresentKHR returned. | |
| bool | havePresentEnd { false } |
| double | lastBuildSeconds { 0.0 } |
| bool | lastBuildValid { false } |
| double | acquireSeconds { 0.0 } |
| How long this frame's swapchain image took to acquire; counted with present's wait. | |
| double | lastSwapchainWaitSeconds { 0.0 } |
| The last presented frame's swapchain wait: acquiring its image and presenting it. | |
| bool | presentPending { false } |
| Recorded and submitted, waiting for PresentWindowFrame. | |
| FrameData * | readbackPending { nullptr } |
| bool | needsReadback { false } |
| Transparent window: each frame is read back for the Windows layered window. | |
| bool | renderToImage { false } |
| WindowFlags::RenderToImage: no surface. | |
| VkImage | targetImage { VK_NULL_HANDLE } |
| host image each frame is copied into | |
| VkExtent2D | targetExtent {} |
| bool | targetWritten { false } |
| targetImage holds a previous frame | |
| tachyon::vulkan::AllocatedBuffer | readbackBuffer = {} |
| std::vector< uint8_t > | cachedBitmap |
| uint64_t | immediateReadbacks = 0 |
| Readbacks that needed a submit of their own (PerformReadback). | |
| double | lastGpuFrameSeconds = 0.0 |
| float | timestampPeriodNs = 0.0f |
| nanoseconds per timestamp tick; 0: no timestamps | |
Static Public Attributes | |
| static constexpr VkImageUsageFlags | kDrawImageUsage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
| The draw image is drawn into as a color attachment and copied out; it's no storage image, which would keep drivers from compressing it (DCC). | |
|
inlineoverride |
| FrameData & tachyon::vulkan::VulkanWindowContext::GetCurrentFrame | ( | ) |
| FrameData & tachyon::vulkan::VulkanWindowContext::GetLastFrame | ( | ) |
|
inlineoverridevirtual |
Whether the window has WindowFlags::Transparent.
Implements tachyon::IWindowContext.
| void tachyon::vulkan::VulkanWindowContext::CreateSwapchain | ( | ) |
| void tachyon::vulkan::VulkanWindowContext::DestroySwapchain | ( | ) |
| void tachyon::vulkan::VulkanWindowContext::ResizeSwapchain | ( | tachyon::int2 | size | ) |
| void tachyon::vulkan::VulkanWindowContext::FlushWindowContext | ( | ) |
| void tachyon::vulkan::VulkanWindowContext::CreateDrawDepthImages | ( | VulkanImage & | drawImage, |
| VulkanImage & | depthImage, | ||
| VkFormat | colorFormat ) |
Creates a draw and depth image pair sized to windowExtent; each FRAME_OVERLAP slot has its own.
| void tachyon::vulkan::VulkanWindowContext::DestroyDrawDepthImages | ( | VulkanImage & | drawImage, |
| VulkanImage & | depthImage ) |
| VkCommandBuffer tachyon::vulkan::VulkanWindowContext::BeginWindowFrame | ( | FrameData & | currentFrame, |
| VulkanGraphicsContext * | graphics = nullptr ) |
| void tachyon::vulkan::VulkanWindowContext::EndWindowFrame | ( | FrameData & | currentFrame | ) |
| void tachyon::vulkan::VulkanWindowContext::PerformReadback | ( | FrameData & | frame | ) |
Copies frame's draw image into the readback buffer in a submit of its own, waits, and reads it (ReadPixels of a window whose frames aren't copied out themselves).
| void tachyon::vulkan::VulkanWindowContext::RecordReadbackCopy | ( | VkCommandBuffer | cmd, |
| FrameData & | frame ) |
Records the copy of frame's draw image into the readback buffer, made visible to the host, into cmd.
| void tachyon::vulkan::VulkanWindowContext::ReadBackBuffer | ( | ) |
The readback buffer into cachedBitmap, once the copy into it is done.
|
inline |
GPU time of the drawing of this window's most recent finished frame, in seconds; 0 until one finished, or when the device can't time.
|
overridevirtual |
The last rendered frame, BGRA8 with tightly packed rows; bgra holds width x height x 4 bytes of the window's pixel size.
False when it can't be read.
Reimplemented from tachyon::IWindowContext.
| void tachyon::vulkan::VulkanWindowContext::SetImageTarget | ( | VkImage | image, |
| VkExtent2D | extent ) |
The host image each frame is copied into (render-to-image windows); VK_NULL_HANDLE stops.
| void tachyon::vulkan::VulkanWindowContext::TransitionTarget | ( | VkCommandBuffer | cmd, |
| VkImageLayout | from, | ||
| VkImageLayout | to, | ||
| VkPipelineStageFlags2 | srcStage, | ||
| VkAccessFlags2 | srcAccess, | ||
| VkPipelineStageFlags2 | dstStage, | ||
| VkAccessFlags2 | dstAccess ) |
|
static |
| void tachyon::vulkan::VulkanWindowContext::Destroy | ( | ) |
|
inlineoverridevirtual |
The GUI window's ID; the backend passes it with the window's input.
Implements tachyon::IWindowContext.
|
overridevirtual |
A frame is recorded (drawn and submitted), then presented.
RenderWindowFrame does both; a host loop records every window before presenting any.
Implements tachyon::IWindowContext.
|
overridevirtual |
Records and submits a frame without presenting it; PresentWindowFrame presents.
The default does both, through RenderWindowFrame.
Reimplemented from tachyon::IWindowContext.
|
overridevirtual |
May wait for vsync; nothing to do for a render-to-image window.
Returns the seconds the frame waited on the OS to show it: getting its image and presenting it, since a driver may hold the vsync wait in either. Nothing when no frame was presented to it (a render-to-image window, a window not recorded this frame).
Reimplemented from tachyon::IWindowContext.
|
inline |
The last presented frame's wait on the swapchain, in seconds (PresentWindowFrame's).
|
inlineoverridevirtual |
True when the window must be recorded this frame even though its draws didn't change (its swapchain is out of date).
False by default.
Reimplemented from tachyon::IWindowContext.
| bool tachyon::vulkan::VulkanWindowContext::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.
|
overridevirtual |
A transparent window the OS composites from a CPU copy (a layered window on Windows): shows its last frame again, where the window is.
Only its picture: the window manager places it. The default does nothing.
Reimplemented from tachyon::IWindowContext.
|
inlineoverridevirtual |
The window it was created for.
Implements tachyon::IWindowContext.
| tachyon::ID tachyon::vulkan::VulkanWindowContext::id { tachyon::ID::Invalid()} |
| VulkanDeviceContext* tachyon::vulkan::VulkanWindowContext::deviceContext { nullptr } |
| tachyon::OSWindowHandle tachyon::vulkan::VulkanWindowContext::osHandle { nullptr } |
| void* tachyon::vulkan::VulkanWindowContext::nativeHandle { nullptr } |
| tachyon::OnGuiFunc tachyon::vulkan::VulkanWindowContext::onGui {} |
| std::shared_ptr<bool> tachyon::vulkan::VulkanWindowContext::alive = std::make_shared<bool>(true) |
False once the context is deleted: a live resize's onGui runs a whole app frame, which may close this very window (a drag preview whose drag ended).
| tachyon::WindowFlags tachyon::vulkan::VulkanWindowContext::windowFlags = tachyon::WindowFlags::None |
| SwapchainState tachyon::vulkan::VulkanWindowContext::swapchain = {} |
| WindowVulkanState tachyon::vulkan::VulkanWindowContext::state = {} |
| VkSurfaceKHR tachyon::vulkan::VulkanWindowContext::surface = {} |
| VkExtent2D tachyon::vulkan::VulkanWindowContext::windowExtent = {} |
| VkExtent2D tachyon::vulkan::VulkanWindowContext::drawExtent = {} |
| VkExtent2D tachyon::vulkan::VulkanWindowContext::requestedExtent = {} |
The size the last frame was recorded for; without a swapchain, what's drawn.
| VkExtent2D tachyon::vulkan::VulkanWindowContext::swapchainRequest = {} |
The size the swapchain was last remade for: a window grown smaller than its swapchain asks again once, even on drivers that don't report it out of date.
| bool tachyon::vulkan::VulkanWindowContext::resize_requested { false } |
| bool tachyon::vulkan::VulkanWindowContext::freeze_rendering { false } |
| tachyon::int2 tachyon::vulkan::VulkanWindowContext::mouse_pos = { 0,0 } |
| uint64_t tachyon::vulkan::VulkanWindowContext::frameNumber { 0 } |
frames recorded; never wraps
| std::chrono::steady_clock::time_point tachyon::vulkan::VulkanWindowContext::lastPresentEnd {} |
When the last vkQueuePresentKHR returned.
The frame-build time runs from here to just before the next present: the CPU work, without the vsync wait.
| bool tachyon::vulkan::VulkanWindowContext::havePresentEnd { false } |
| double tachyon::vulkan::VulkanWindowContext::lastBuildSeconds { 0.0 } |
| bool tachyon::vulkan::VulkanWindowContext::lastBuildValid { false } |
| double tachyon::vulkan::VulkanWindowContext::acquireSeconds { 0.0 } |
How long this frame's swapchain image took to acquire; counted with present's wait.
| double tachyon::vulkan::VulkanWindowContext::lastSwapchainWaitSeconds { 0.0 } |
The last presented frame's swapchain wait: acquiring its image and presenting it.
| bool tachyon::vulkan::VulkanWindowContext::presentPending { false } |
Recorded and submitted, waiting for PresentWindowFrame.
| FrameData* tachyon::vulkan::VulkanWindowContext::readbackPending { nullptr } |
| bool tachyon::vulkan::VulkanWindowContext::needsReadback { false } |
Transparent window: each frame is read back for the Windows layered window.
| bool tachyon::vulkan::VulkanWindowContext::renderToImage { false } |
WindowFlags::RenderToImage: no surface.
| VkImage tachyon::vulkan::VulkanWindowContext::targetImage { VK_NULL_HANDLE } |
host image each frame is copied into
| VkExtent2D tachyon::vulkan::VulkanWindowContext::targetExtent {} |
| bool tachyon::vulkan::VulkanWindowContext::targetWritten { false } |
targetImage holds a previous frame
| tachyon::vulkan::AllocatedBuffer tachyon::vulkan::VulkanWindowContext::readbackBuffer = {} |
| std::vector<uint8_t> tachyon::vulkan::VulkanWindowContext::cachedBitmap |
|
staticconstexpr |
The draw image is drawn into as a color attachment and copied out; it's no storage image, which would keep drivers from compressing it (DCC).
| uint64_t tachyon::vulkan::VulkanWindowContext::immediateReadbacks = 0 |
Readbacks that needed a submit of their own (PerformReadback).
| double tachyon::vulkan::VulkanWindowContext::lastGpuFrameSeconds = 0.0 |
| float tachyon::vulkan::VulkanWindowContext::timestampPeriodNs = 0.0f |
nanoseconds per timestamp tick; 0: no timestamps