TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::vulkan::VulkanWindowContext Class Reference

#include <gui_core/graphics/vulkan/vk_window_context.h>

Inheritance diagram for tachyon::vulkan::VulkanWindowContext:

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 &currentFrame)
void EndWindowFrame (FrameData &currentFrame)
void PerformReadback (const VulkanImage &drawImage)
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 UpdateLayeredWindowFromCache (int screenX, int screenY)
void Destroy ()
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.
void PresentWindowFrame () override
 May wait for vsync; nothing to do for a render-to-image window.
void RecordFrame (tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect, bool resizing)
void UpdateTransparentWindow (tachyon::int2 screenPos) override
 A transparent window the OS composites from a CPU copy (a layered window on Windows): shows its last frame again at screenPos (screen pixels).
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 {}
tachyon::WindowFlags windowFlags = tachyon::WindowFlags::None
SwapchainState swapchain = {}
WindowVulkanState state = {}
VkSurfaceKHR surface = {}
VkExtent2D windowExtent = {}
VkExtent2D drawExtent = {}
bool resize_requested { false }
bool freeze_rendering { false }
tachyon::int2 mouse_pos = { 0,0 }
int frameNumber { 0 }
std::chrono::steady_clock::time_point lastPresentEnd {}
 When the last vkQueuePresentKHR returned.
bool havePresentEnd { false }
double lastBuildSeconds { 0.0 }
bool lastBuildValid { false }
bool presentPending { false }
 Recorded and submitted, waiting for PresentWindowFrame.
FrameData * readbackPending { nullptr }
tachyon::int2 recordedPosition {}
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
double lastGpuFrameSeconds = 0.0
float timestampPeriodNs = 0.0f
 nanoseconds per timestamp tick; 0: no timestamps

Member Function Documentation

◆ GetCurrentFrame()

FrameData & tachyon::vulkan::VulkanWindowContext::GetCurrentFrame ( )

◆ GetLastFrame()

FrameData & tachyon::vulkan::VulkanWindowContext::GetLastFrame ( )

◆ IsTransparent()

bool tachyon::vulkan::VulkanWindowContext::IsTransparent ( ) const
inlineoverridevirtual

Whether the window has WindowFlags::Transparent.

Implements tachyon::IWindowContext.

◆ CreateSwapchain()

void tachyon::vulkan::VulkanWindowContext::CreateSwapchain ( )

◆ DestroySwapchain()

void tachyon::vulkan::VulkanWindowContext::DestroySwapchain ( )

◆ ResizeSwapchain()

void tachyon::vulkan::VulkanWindowContext::ResizeSwapchain ( tachyon::int2 size)

◆ FlushWindowContext()

void tachyon::vulkan::VulkanWindowContext::FlushWindowContext ( )

◆ CreateDrawDepthImages()

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.

◆ DestroyDrawDepthImages()

void tachyon::vulkan::VulkanWindowContext::DestroyDrawDepthImages ( VulkanImage & drawImage,
VulkanImage & depthImage )

◆ BeginWindowFrame()

VkCommandBuffer tachyon::vulkan::VulkanWindowContext::BeginWindowFrame ( FrameData & currentFrame)

◆ EndWindowFrame()

void tachyon::vulkan::VulkanWindowContext::EndWindowFrame ( FrameData & currentFrame)

◆ PerformReadback()

void tachyon::vulkan::VulkanWindowContext::PerformReadback ( const VulkanImage & drawImage)

◆ LastGpuFrameSeconds()

double tachyon::vulkan::VulkanWindowContext::LastGpuFrameSeconds ( ) const
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.

◆ ReadPixels()

bool tachyon::vulkan::VulkanWindowContext::ReadPixels ( std::span< uint8_t > bgra)
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.

◆ SetImageTarget()

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.

◆ TransitionTarget()

void tachyon::vulkan::VulkanWindowContext::TransitionTarget ( VkCommandBuffer cmd,
VkImageLayout from,
VkImageLayout to,
VkPipelineStageFlags2 srcStage,
VkAccessFlags2 srcAccess,
VkPipelineStageFlags2 dstStage,
VkAccessFlags2 dstAccess )

◆ UpdateLayeredWindowFromCache()

void tachyon::vulkan::VulkanWindowContext::UpdateLayeredWindowFromCache ( int screenX,
int screenY )

◆ Create()

VulkanWindowContext * tachyon::vulkan::VulkanWindowContext::Create ( tachyon::ID id,
void * nativeHandle,
tachyon::OSWindowHandle osHandle,
tachyon::int2 size,
tachyon::WindowFlags windowFlags,
VulkanDeviceContext * deviceContext,
tachyon::OnGuiFunc onGUI )
static

◆ Destroy()

void tachyon::vulkan::VulkanWindowContext::Destroy ( )

◆ GetID()

tachyon::ID tachyon::vulkan::VulkanWindowContext::GetID ( ) const
inlineoverridevirtual

The GUI window's ID; the backend passes it with the window's input.

Implements tachyon::IWindowContext.

◆ RenderWindowFrame()

void tachyon::vulkan::VulkanWindowContext::RenderWindowFrame ( tachyon::GraphicsContext * graphicsContext,
tachyon::IntRect rect,
bool resizing )
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.

◆ RecordWindowFrame()

void tachyon::vulkan::VulkanWindowContext::RecordWindowFrame ( tachyon::GraphicsContext * graphicsContext,
tachyon::IntRect rect )
overridevirtual

Records and submits a frame without presenting it; PresentWindowFrame presents.

The default does both, through RenderWindowFrame.

Reimplemented from tachyon::IWindowContext.

◆ PresentWindowFrame()

void tachyon::vulkan::VulkanWindowContext::PresentWindowFrame ( )
overridevirtual

May wait for vsync; nothing to do for a render-to-image window.

Reimplemented from tachyon::IWindowContext.

◆ RecordFrame()

void tachyon::vulkan::VulkanWindowContext::RecordFrame ( tachyon::GraphicsContext * graphicsContext,
tachyon::IntRect rect,
bool resizing )

◆ UpdateTransparentWindow()

void tachyon::vulkan::VulkanWindowContext::UpdateTransparentWindow ( tachyon::int2 screenPos)
overridevirtual

A transparent window the OS composites from a CPU copy (a layered window on Windows): shows its last frame again at screenPos (screen pixels).

The default does nothing.

Reimplemented from tachyon::IWindowContext.

◆ GetWindowHandle()

tachyon::OSWindowHandle tachyon::vulkan::VulkanWindowContext::GetWindowHandle ( ) const
inlineoverridevirtual

The window it was created for.

Implements tachyon::IWindowContext.

Member Data Documentation

◆ id

tachyon::ID tachyon::vulkan::VulkanWindowContext::id { tachyon::ID::Invalid()}

◆ deviceContext

VulkanDeviceContext* tachyon::vulkan::VulkanWindowContext::deviceContext { nullptr }

◆ osHandle

tachyon::OSWindowHandle tachyon::vulkan::VulkanWindowContext::osHandle { nullptr }

◆ nativeHandle

void* tachyon::vulkan::VulkanWindowContext::nativeHandle { nullptr }

◆ onGui

tachyon::OnGuiFunc tachyon::vulkan::VulkanWindowContext::onGui {}

◆ windowFlags

tachyon::WindowFlags tachyon::vulkan::VulkanWindowContext::windowFlags = tachyon::WindowFlags::None

◆ swapchain

SwapchainState tachyon::vulkan::VulkanWindowContext::swapchain = {}

◆ state

WindowVulkanState tachyon::vulkan::VulkanWindowContext::state = {}

◆ surface

VkSurfaceKHR tachyon::vulkan::VulkanWindowContext::surface = {}

◆ windowExtent

VkExtent2D tachyon::vulkan::VulkanWindowContext::windowExtent = {}

◆ drawExtent

VkExtent2D tachyon::vulkan::VulkanWindowContext::drawExtent = {}

◆ resize_requested

bool tachyon::vulkan::VulkanWindowContext::resize_requested { false }

◆ freeze_rendering

bool tachyon::vulkan::VulkanWindowContext::freeze_rendering { false }

◆ mouse_pos

tachyon::int2 tachyon::vulkan::VulkanWindowContext::mouse_pos = { 0,0 }

◆ frameNumber

int tachyon::vulkan::VulkanWindowContext::frameNumber { 0 }

◆ lastPresentEnd

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.

◆ havePresentEnd

bool tachyon::vulkan::VulkanWindowContext::havePresentEnd { false }

◆ lastBuildSeconds

double tachyon::vulkan::VulkanWindowContext::lastBuildSeconds { 0.0 }

◆ lastBuildValid

bool tachyon::vulkan::VulkanWindowContext::lastBuildValid { false }

◆ presentPending

bool tachyon::vulkan::VulkanWindowContext::presentPending { false }

Recorded and submitted, waiting for PresentWindowFrame.

◆ readbackPending

FrameData* tachyon::vulkan::VulkanWindowContext::readbackPending { nullptr }

◆ recordedPosition

tachyon::int2 tachyon::vulkan::VulkanWindowContext::recordedPosition {}

◆ needsReadback

bool tachyon::vulkan::VulkanWindowContext::needsReadback { false }

Transparent window: each frame is read back for the Windows layered window.

◆ renderToImage

bool tachyon::vulkan::VulkanWindowContext::renderToImage { false }

◆ targetImage

VkImage tachyon::vulkan::VulkanWindowContext::targetImage { VK_NULL_HANDLE }

host image each frame is copied into

◆ targetExtent

VkExtent2D tachyon::vulkan::VulkanWindowContext::targetExtent {}

◆ targetWritten

bool tachyon::vulkan::VulkanWindowContext::targetWritten { false }

targetImage holds a previous frame

◆ readbackBuffer

tachyon::vulkan::AllocatedBuffer tachyon::vulkan::VulkanWindowContext::readbackBuffer = {}

◆ cachedBitmap

std::vector<uint8_t> tachyon::vulkan::VulkanWindowContext::cachedBitmap

◆ lastGpuFrameSeconds

double tachyon::vulkan::VulkanWindowContext::lastGpuFrameSeconds = 0.0

◆ timestampPeriodNs

float tachyon::vulkan::VulkanWindowContext::timestampPeriodNs = 0.0f

nanoseconds per timestamp tick; 0: no timestamps


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