79 const std::source_location& loc = std::source_location::current())
override;
87 const std::source_location& loc = std::source_location::current());
95 const std::source_location& loc = std::source_location::current());
142 void AddFrameWait(VkSemaphore semaphore, uint64_t value, VkPipelineStageFlags2 stageMask)
153 struct ImageTarget { VkImage image; VkExtent2D extent; };
154 std::unordered_map<tachyon::ID, ImageTarget> m_imageTargets;
155 std::unordered_map<tachyon::ID, tachyon::vulkan::VulkanWindowContext*> m_windowContexts;
185 float m_lastElapsedTimeSecs{ 0.0f };
186 float m_frameBuildSeconds{ 0.0f };
Definition gui_buffer.h:9
virtual void StopResizing()=0
virtual bool StartResizing(ID id)=0
The atlas that the colors of color styles are baked into: pages of 2D textures, one row per gradient,...
Definition gui_gradient_manager.h:64
A graphics backend: the device, the window contexts that render the GUI's windows,...
Definition gui_graphics_context.h:60
GUIRenderer * guiRenderer
Where the UI records its draw primitives.
Definition gui_graphics_context.h:64
Makes and manages the OS windows and delivers their input; GUIApplication::SetWindowBackend sets one,...
Definition gui_window_backend.h:105
A window's rendering state: made by GraphicsContext::CreateWindowContext for each OS window,...
Definition gui_window_backend.h:72
The images the shaders can sample, each at an ImageIndex. Implemented by the backend.
Definition gui_image.h:44
An image made by GraphicsContext::CreateImage; the backend defines its contents.
Definition gui_image.h:40
A value, or the Error saying why there is none.
Definition gui_result.h:36
Bakes serializable Styles into deduplicated runtime layout/visual styles; a StyleRef holds indices in...
Definition gui_style_manager.h:39
Definition gui_text_atlas_manager.h:17
The Vulkan device the GUI renders with: its own, or a host's (SetExternalDevice).
Definition vk_device_context.h:118
void SetAllocationHooks(const tachyon::AllocationHooks &hooks)
Host memory functions for every Vulkan object, vk-bootstrap and VMA.
std::string shaderDirectory
Where to load the compiled shaders from; empty uses the built-in ones.
Definition vk_device_context.h:286
void SetSurfaceFactory(SurfaceFactory factory)
How surfaces are made; set before initialization. SDLWindowBackend installs its own.
Definition vk_device_context.h:124
void SetExternalDevice(const ExternalDevice &external)
Renders on the host's device instead of making one; call before initialization.
Definition vk_device_context.h:175
std::function< VkSurfaceKHR(VkInstance, const VkAllocationCallbacks *, tachyon::OSWindowHandle)> SurfaceFactory
Makes a VkSurfaceKHR for one of the window backend's windows with the given instance and allocation c...
Definition vk_device_context.h:122
FrameWaits frameWaits
Library internal: the timeline semaphores the frame's submissions wait on.
Definition vk_device_context.h:262
std::vector< tachyon::ImageIndex > gradientPageImageIndices
Library internal: the gradient pages' image indices.
Definition vk_graphics_context.h:42
void Reset()
Library internal: clears the renderer's recorded primitives.
Definition vk_graphics_context.h:159
tachyon::Buffer * PrepareVisualBoxStylesBuffer(tachyon::StyleManager &styleManager)
Library internal: the box styles' buffer, uploaded again when they changed.
tachyon::Result< void > RecreateDevice(tachyon::IWindowBackend *windowBackend) override
Makes a new device after DeviceLost, and everything the backend owns on it (the window contexts are t...
tachyon::Image * CreateImage(void *data, tachyon::uint2 size, tachyon::ImageFormat format, tachyon::Sampler sampler, bool mipmapped=false) override
GraphicsContext::CreateImage; null data makes a cleared image.
void SetAllocationHooks(const tachyon::AllocationHooks &hooks) override
Host memory functions for the graphics API's allocations. Call before Initialize.
Definition vk_graphics_context.h:60
void EndFrame() override
Ends the UI build, before the uploads and the window contexts' recording.
Definition vk_graphics_context.h:68
void SimulateDeviceLoss()
Diagnostic: as if the device were lost, so the next frame recreates it.
Definition vk_graphics_context.h:66
tachyon::ImageIndex RegisterImage(tachyon::Image *image) override
Adds the image to the image set; elements draw it by the returned index.
void DestroyVisualBoxStyles(tachyon::Buffer *buffer)
Library internal: destroys the buffer's GPU objects now.
tachyon::GPUDrawPushConstants pushConstants
Library internal: the push constants PrepareFrame sets for the frame's draws.
Definition vk_graphics_context.h:167
void DestroyVisualColorStyles(tachyon::Buffer *buffer)
Library internal: destroys the buffer's GPU objects now.
tachyon::IWindowContext * CreateWindowContext(void *nativeHandle, tachyon::OSWindowHandle osHandle, tachyon::ID id, tachyon::int2 size, tachyon::WindowFlags windowFlags, tachyon::OnGuiFunc onGui) override
Makes the context that renders an OS window: nativeWindowHandle comes from IWindowBackend::GetNativeH...
void PrepareFrame(tachyon::StyleManager &styleManager, tachyon::GradientManager &gradientManager, float elapsedTimeSecs) override
GraphicsContext::PrepareFrame: uploads changed styles and registers the gradient pages.
void StopResizing()
Library internal: the live-resize redraw ends.
Definition vk_graphics_context.h:150
void AddFrameWait(VkSemaphore semaphore, uint64_t value, VkPipelineStageFlags2 stageMask)
The GUI's next frame waits for the timeline semaphore semaphore (made on the GUI's device) to reach v...
Definition vk_graphics_context.h:142
void SetWindowImageTarget(tachyon::ID window, VkImage image, VkExtent2D extent)
The host image a render-to-image window (WindowFlags::RenderToImage) is copied into after each of its...
void DestroyWindowContext(tachyon::IWindowContext *context) override
Waits for the context's GPU work and destroys it now; its native window must still exist.
tachyon::Buffer * PrepareVisualColorStylesBuffer(tachyon::StyleManager &styleManager, tachyon::GradientManager &gradientManager)
Library internal: the color styles' buffer, uploaded again when they changed.
Result< void > Initialize(tachyon::IWindowBackend *windowBackend) override
Brings the device up; GUIApplication::Initialize calls it once, before any window context.
tachyon::Buffer * visualBoxStylesMesh
Library internal: the box styles' GPU buffer.
Definition vk_graphics_context.h:38
void SetSurfaceFactory(VulkanDeviceContext::SurfaceFactory factory)
How surfaces are made for the window backend's windows; SDLWindowBackend installs its own.
Definition vk_graphics_context.h:55
bool DeviceLost() const override
True once the GPU device is lost; RecreateDevice then makes a new one.
Definition vk_graphics_context.h:63
void UpdateExternalImage(tachyon::ImageIndex index, VkImageView view, VkSampler sampler)
Points an existing index at a new view, for example after a resize, under the same rules as RegisterE...
VulkanDeviceContext deviceContext
The device; set it up (external device, debug config) before Initialize.
Definition vk_graphics_context.h:44
tachyon::ImageSet * GetImageSet() const override
The images the shaders sample, by ImageIndex.
tachyon::Buffer * colorStylesMesh
Library internal: the color styles' GPU buffer.
Definition vk_graphics_context.h:40
VulkanImageSet * vulkanImageSet
Library internal: the image set behind GetImageSet.
Definition vk_graphics_context.h:36
tachyon::Buffer * UploadVisualColorStyles(std::span< const tachyon::VisualColorStyle > colorStyles)
Library internal: the color styles in a GPU buffer for the shaders.
tachyon::Buffer * UploadVisualBoxStyles(std::span< const tachyon::VisualBoxStyle > visualBoxStyles)
Library internal: the box styles in a GPU buffer for the shaders.
void DestroyImage(tachyon::Image *img)
Destroys the image's Vulkan objects now, without waiting for the GPU; doesn't delete the object.
void SetShaderDirectory(std::string_view directory)
Loads the compiled shaders (box_shader.vert.spv, ...) from directory instead of the ones built into t...
Definition vk_graphics_context.h:59
void SetFrameBuildSeconds(float seconds)
Library internal: window contexts report their CPU seconds between presents (GetLastFrameBuildSeconds...
Definition vk_graphics_context.h:180
bool StartResizing(tachyon::ID id)
Library internal: a window's live-resize redraw starts (GUIRenderer::StartResizing).
Definition vk_graphics_context.h:148
tachyon::GraphicsAPI GetAPI() const override
The API it presents with; window backends make their windows for it.
Definition vk_graphics_context.h:49
tachyon::ImageIndex RegisterExternalImage(VkImageView view, VkSampler sampler)
An image the host renders itself (a 3D viewport, a preview) as an ImageIndex, drawn like GUI-owned im...
tachyon::TextAtlasManager * CreateTextAtlasManager() override
A new text atlas manager for the backend. The caller owns it and keeps it past Cleanup.
void BeginFrame() override
Starts a frame's UI build: resets the renderer for new primitives (Vulkan: also frees what frame-scop...
tachyon::Image * CreateImage(tachyon::uint2 size, tachyon::ImageFormat format, tachyon::Sampler sampler, bool mipmapped=false)
An image nothing is uploaded to (undefined contents), for sampling only.
void DestroyVisualBoxStylesAtEnd(tachyon::Buffer *buffer, tachyon::DeviceScope scope, const std::source_location &loc=std::source_location::current())
Library internal: destroys and deletes the buffer when the scope's queue flushes.
void RePrepareFrame()
Library internal: PrepareFrame with the last call's arguments; lets a live resize pick up the style c...
void DestroyVisualColorStylesAtEnd(tachyon::Buffer *buffer, tachyon::DeviceScope scope, const std::source_location &loc=std::source_location::current())
Library internal: destroys and deletes the buffer when the scope's queue flushes.
float GetLastFrameBuildSeconds() const override
Wall-clock seconds of CPU work in the last frame: from just after one present returns to just before ...
Definition vk_graphics_context.h:177
void SetExternalDevice(const VulkanDeviceContext::ExternalDevice &external)
Render on the host's device instead of creating one.
Definition vk_graphics_context.h:53
void Cleanup() override
Waits for the GPU and destroys what the backend made, the renderer included.
void UnregisterImage(tachyon::ImageIndex index) override
Frees the index for reuse; the image stays (DestroyImageAtEnd destroys it).
bool RenderWindowFrame(VkCommandBuffer cmd, FrameData ¤tFrame, tachyon::ID windowID, tachyon::uint2 extent)
Library internal: records a window's primitives into cmd.
void DestroyImageAtEnd(tachyon::Image *img, tachyon::DeviceScope scope, const std::source_location &loc=std::source_location::current()) override
Destroys the image and deletes the object once the GPU is done with it: a few frames on for DeviceSco...
Definition vk_window_context.h:82
void SetDeviceLost(bool lost)
Sampler
How an image is filtered and addressed when sampled.
Definition gui_image.h:27
ImageFormat
Pixel formats for GraphicsContext::CreateImage, 8 bits per channel.
Definition gui_image.h:13
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:37
DeviceScope
When a deferred GPU resource destruction runs: Frame once the frames that may use it are done,...
Definition gui_graphics_context.h:43
GraphicsAPI
The graphics API a backend presents with; window backends create their windows to match (SDL: SDL_WIN...
Definition gui_graphics_context.h:51
@ Vulkan
Definition gui_graphics_context.h:53
std::function< void()> OnGuiFunc
Definition gui_base_types.h:14
WindowFlags
How an OS window is made and behaves (IWindowBackend::CreateWindow); flags combine with |.
Definition gui_window_flags.h:12
void * OSWindowHandle
An OS window, opaque; what it points to is up to the window backend.
Definition gui_window_backend.h:37
Definition vk_defaults.h:4
Definition gui_logging.h:24
Memory functions a host gives the library, for the allocations that can be routed: Vulkan objects,...
Definition gui_allocation_hooks.h:15
Definition gui_render_primitives.h:248
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Integer 2D vector.
Definition gui_base_types.h:19
Definition gui_base_types.h:75
Definition vk_window_context.h:29
void Add(VkSemaphore semaphore, uint64_t value, VkPipelineStageFlags2 stageMask)
Waits for semaphore to reach value before stageMask.
Definition vk_device_context.h:76
A host's Vulkan handles for SetExternalDevice, so the GUI renders on the host's device (an engine hos...
Definition vk_device_context.h:152