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

A graphics backend that draws nothing: the UI is built, laid out and recorded as usual, but no GPU is used and windows stay empty. More...

#include <gui_core/graphics/null/gui_null_graphics_context.h>

Inheritance diagram for tachyon::NullGraphicsContext:

Public Member Functions

 NullGraphicsContext ()
 ~NullGraphicsContext () override
GraphicsAPI GetAPI () const override
 The API it presents with; window backends make their windows for it.
void SetAllocationHooks (const AllocationHooks &) override
 Host memory functions for the graphics API's allocations. Call before Initialize.
Result< void > Initialize (IWindowBackend *windowBackend) override
 Brings the device up; GUIApplication::Initialize calls it once, before any window context.
void Cleanup () override
 Waits for the GPU and destroys what the backend made, the renderer included.
void BeginFrame () override
 Starts a frame's UI build: resets the renderer for new primitives (Vulkan: also frees what frame-scoped deletions held long enough).
void EndFrame () override
 Ends the UI build, before the uploads and the window contexts' recording.
Image * CreateImage (void *data, uint2 size, ImageFormat format, Sampler sampler, bool mipmapped=false) override
 Makes an image from size.x x size.y tightly packed pixels of format (Vulkan: data null for a cleared image); mipmapped generates its mip levels.
void DestroyImageAtEnd (Image *img, 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 DeviceScope::Frame, at Cleanup for DeviceScope::Application.
TextAtlasManager * CreateTextAtlasManager () override
 A new text atlas manager for the backend. The caller owns it and keeps it past Cleanup.
IWindowContext * CreateWindowContext (void *nativeWindowHandle, OSWindowHandle osHandle, ID id, int2 size, WindowFlags windowFlags, OnGuiFunc onGui) override
 Makes the context that renders an OS window: nativeWindowHandle comes from IWindowBackend::GetNativeHandle, size is in pixels and onGui builds the window's UI.
void DestroyWindowContext (IWindowContext *context) override
 Waits for the context's GPU work and destroys it now; its native window must still exist.
ImageSet * GetImageSet () const override
 The images the shaders sample, by ImageIndex.
ImageIndex RegisterImage (Image *image) override
 Adds the image to the image set; elements draw it by the returned index.
void UnregisterImage (ImageIndex index) override
 Frees the index for reuse; the image stays (DestroyImageAtEnd destroys it).
void PrepareFrame (StyleManager &, GradientManager &, float) override
 Uploads the styles and gradient pages for this frame's draws, after the UI build and before the window contexts record.
Public Member Functions inherited from tachyon::GraphicsContext
 GraphicsContext ()=default
virtual ~GraphicsContext ()
virtual bool DeviceLost () const
 True once the GPU device is lost; RecreateDevice then makes a new one.
virtual Result< void > RecreateDevice (IWindowBackend *)
 Makes a new device after DeviceLost, and everything the backend owns on it (the window contexts are the caller's to make again).
virtual float GetLastFrameBuildSeconds () const
 Wall-clock seconds of CPU work in the last frame: from just after one present returns to just before the next, so without the vsync wait.

Additional Inherited Members

Public Attributes inherited from tachyon::GraphicsContext
GUIRenderer * guiRenderer = nullptr
 Where the UI records its draw primitives.

Detailed Description

A graphics backend that draws nothing: the UI is built, laid out and recorded as usual, but no GPU is used and windows stay empty.

For headless runs and tests, and as the minimal example of a backend.

Constructor & Destructor Documentation

◆ NullGraphicsContext()

tachyon::NullGraphicsContext::NullGraphicsContext ( )

◆ ~NullGraphicsContext()

tachyon::NullGraphicsContext::~NullGraphicsContext ( )
override

Member Function Documentation

◆ GetAPI()

GraphicsAPI tachyon::NullGraphicsContext::GetAPI ( ) const
inlineoverridevirtual

The API it presents with; window backends make their windows for it.

Implements tachyon::GraphicsContext.

◆ SetAllocationHooks()

void tachyon::NullGraphicsContext::SetAllocationHooks ( const AllocationHooks & hooks)
inlineoverridevirtual

Host memory functions for the graphics API's allocations. Call before Initialize.

Implements tachyon::GraphicsContext.

◆ Initialize()

Result< void > tachyon::NullGraphicsContext::Initialize ( IWindowBackend * windowBackend)
overridevirtual

Brings the device up; GUIApplication::Initialize calls it once, before any window context.

It may make windows with the backend (Vulkan: a hidden one, to pick a GPU that can present to it).

Implements tachyon::GraphicsContext.

◆ Cleanup()

void tachyon::NullGraphicsContext::Cleanup ( )
overridevirtual

Waits for the GPU and destroys what the backend made, the renderer included.

The window contexts are destroyed before it.

Implements tachyon::GraphicsContext.

◆ BeginFrame()

void tachyon::NullGraphicsContext::BeginFrame ( )
overridevirtual

Starts a frame's UI build: resets the renderer for new primitives (Vulkan: also frees what frame-scoped deletions held long enough).

Implements tachyon::GraphicsContext.

◆ EndFrame()

void tachyon::NullGraphicsContext::EndFrame ( )
inlineoverridevirtual

Ends the UI build, before the uploads and the window contexts' recording.

Implements tachyon::GraphicsContext.

◆ CreateImage()

Image * tachyon::NullGraphicsContext::CreateImage ( void * data,
uint2 size,
ImageFormat format,
Sampler sampler,
bool mipmapped = false )
overridevirtual

Makes an image from size.x x size.y tightly packed pixels of format (Vulkan: data null for a cleared image); mipmapped generates its mip levels.

Doesn't wait for the GPU: the upload goes with the next frame. RegisterImage makes it drawable.

Implements tachyon::GraphicsContext.

◆ DestroyImageAtEnd()

void tachyon::NullGraphicsContext::DestroyImageAtEnd ( Image * img,
DeviceScope scope,
const std::source_location & loc = std::source_location::current() )
overridevirtual

Destroys the image and deletes the object once the GPU is done with it: a few frames on for DeviceScope::Frame, at Cleanup for DeviceScope::Application.

loc is for diagnostics.

Implements tachyon::GraphicsContext.

◆ CreateTextAtlasManager()

TextAtlasManager * tachyon::NullGraphicsContext::CreateTextAtlasManager ( )
overridevirtual

A new text atlas manager for the backend. The caller owns it and keeps it past Cleanup.

Implements tachyon::GraphicsContext.

◆ CreateWindowContext()

IWindowContext * tachyon::NullGraphicsContext::CreateWindowContext ( void * nativeWindowHandle,
OSWindowHandle osHandle,
ID id,
int2 size,
WindowFlags windowFlags,
OnGuiFunc onGui )
overridevirtual

Makes the context that renders an OS window: nativeWindowHandle comes from IWindowBackend::GetNativeHandle, size is in pixels and onGui builds the window's UI.

nullptr on failure. Destroy it with DestroyWindowContext.

Implements tachyon::GraphicsContext.

◆ DestroyWindowContext()

void tachyon::NullGraphicsContext::DestroyWindowContext ( IWindowContext * context)
overridevirtual

Waits for the context's GPU work and destroys it now; its native window must still exist.

Implements tachyon::GraphicsContext.

◆ GetImageSet()

ImageSet * tachyon::NullGraphicsContext::GetImageSet ( ) const
overridevirtual

The images the shaders sample, by ImageIndex.

Implements tachyon::GraphicsContext.

◆ RegisterImage()

ImageIndex tachyon::NullGraphicsContext::RegisterImage ( Image * image)
overridevirtual

Adds the image to the image set; elements draw it by the returned index.

Implements tachyon::GraphicsContext.

◆ UnregisterImage()

void tachyon::NullGraphicsContext::UnregisterImage ( ImageIndex index)
overridevirtual

Frees the index for reuse; the image stays (DestroyImageAtEnd destroys it).

Implements tachyon::GraphicsContext.

◆ PrepareFrame()

void tachyon::NullGraphicsContext::PrepareFrame ( StyleManager & styleManager,
GradientManager & gradientManager,
float elapsedTimeSecs )
inlineoverridevirtual

Uploads the styles and gradient pages for this frame's draws, after the UI build and before the window contexts record.

elapsedTimeSecs: the frame clock's time, for shader animation.

Implements tachyon::GraphicsContext.


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