TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
Graphics

The graphics backend interface, renderer, images and custom drawing. More...

Topics

 Vulkan backend
 The Vulkan graphics backend, and sharing a host's device and images.

Classes

class  tachyon::Buffer
class  tachyon::CustomDrawContext
 Passed to custom-draw callbacks (ElementStorage::AddCustomDraw / AddCustomDrawAfter): geometry lookups and drawing calls in a current space the callback switches with SetSpace or SetSpaceRaw, also between calls. More...
class  tachyon::PostLayoutContext
 Context for post-layout callbacks (AddPostLayout). More...
class  tachyon::GraphicsContext
 A graphics backend: the device, the window contexts that render the GUI's windows, and the images and text atlases they draw with. More...
class  tachyon::Image
 An image made by GraphicsContext::CreateImage; the backend defines its contents. More...
class  tachyon::ImageSet
 The images the shaders can sample, each at an ImageIndex. Implemented by the backend. More...
struct  tachyon::PrimitiveRenderPass
 One contiguous same-kind run of primitives, drawn with one call; or, with replay set, a cached scope's draw (its own passes), and the other fields unused. More...
struct  tachyon::PrimitiveRenderTarget
class  tachyon::PrimitiveRenderer
struct  tachyon::glsl_float4
struct  tachyon::Box
struct  tachyon::Glyph
struct  tachyon::Dot
struct  tachyon::Line
struct  tachyon::Triangle
struct  tachyon::Quad
struct  tachyon::Circle
 A circle outline: the ring lineWidth wide around center at radius, its color and dashes running clockwise from the right (+x towards +y), as LineStyle sets them. More...
struct  tachyon::Occluder
 Depth only: marks pos/size as covered by opaque content drawn after it, so what was drawn before under it is skipped (its fragments fail the depth test early). More...
struct  tachyon::PrimitiveSpec
struct  tachyon::GPUDrawPushConstants
struct  tachyon::LineStyle
class  tachyon::GUIRenderer
struct  tachyon::RHI::GpuPipeline
struct  tachyon::RHI::UploadRequest
class  tachyon::RHI::RenderDevice
 Device-lifetime operations. More...
class  tachyon::RHI::RenderCommandList
 One frame's recording surface for one window. More...
class  tachyon::NullGraphicsContext
 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...

Typedefs

using tachyon::PipelineSet = std::array<RHI::GpuPipeline, kPrimitiveKindCount>
using tachyon::DeviceAddress = uint64_t
 Shader-visible buffer address.
using tachyon::RHI::ResidentBufferId = uint64_t
 GPU storage kept across frames (UploadResidentBuffers); 0 is none.

Enumerations

enum class  tachyon::DrawSpace : uint8_t { tachyon::DrawSpace::Local , tachyon::DrawSpace::Screen }
 The coordinate space a CustomDrawContext draws in. More...
enum class  tachyon::DeviceScope { tachyon::DeviceScope::Frame , tachyon::DeviceScope::Application }
 When a deferred GPU resource destruction runs: Frame once the frames that may use it are done, Application at Cleanup. More...
enum class  tachyon::GraphicsAPI : uint8_t { tachyon::GraphicsAPI::None , tachyon::GraphicsAPI::Vulkan }
 The graphics API a backend presents with; window backends create their windows to match (SDL: SDL_WINDOW_VULKAN). More...
enum class  tachyon::ImageFormat {
  tachyon::ImageFormat::UNDEFINED , tachyon::ImageFormat::R8 , tachyon::ImageFormat::R8_SRGB , tachyon::ImageFormat::R8G8 ,
  tachyon::ImageFormat::R8G8_SRGB , tachyon::ImageFormat::R8G8B8 , tachyon::ImageFormat::R8G8B8_SRGB , tachyon::ImageFormat::R8G8B8A8 ,
  tachyon::ImageFormat::R8G8B8A8_SRGB
}
 Pixel formats for GraphicsContext::CreateImage, 8 bits per channel. More...
enum class  tachyon::Sampler { tachyon::Sampler::UNDEFINED , tachyon::Sampler::NearestRepeat , tachyon::Sampler::LinearRepeat , tachyon::Sampler::LinearClampToEdge }
 How an image is filtered and addressed when sampled. More...
enum  tachyon::ImageIndex : uint32_t { tachyon::Invalid = 0 }
 Index of an image in the graphics context's image set, as the shaders sample it. More...
enum class  tachyon::PrimitiveKind : uint8_t {
  tachyon::PrimitiveKind::Box = 0 , tachyon::PrimitiveKind::Glyph , tachyon::PrimitiveKind::Dot , tachyon::PrimitiveKind::Line ,
  tachyon::PrimitiveKind::Triangle , tachyon::PrimitiveKind::Quad , tachyon::PrimitiveKind::Circle , tachyon::PrimitiveKind::Occluder ,
  tachyon::PrimitiveKind::Count
}
enum class  tachyon::PrimitiveShape : uint8_t { tachyon::PrimitiveShape::Quad , tachyon::PrimitiveShape::Triangle }
 The vertices a primitive's vertex shader is run for; gl_VertexIndex divided by their count is the primitive, the remainder the corner. More...
enum class  tachyon::TriangleEdges : uint8_t { tachyon::TriangleEdges::None = 0 , tachyon::TriangleEdges::Edge01 = 1 << 0 , tachyon::TriangleEdges::Edge12 = 1 << 1 , tachyon::TriangleEdges::Edge20 = 1 << 2 }
 A triangle's edges, for the ones drawn without a soft edge: where it meets another triangle of the same shape (a polygon's fan), so no seam shows between them. More...
enum class  tachyon::RHI::ResidentState : uint8_t { tachyon::RHI::ResidentState::Gone , tachyon::RHI::ResidentState::Pending , tachyon::RHI::ResidentState::Ready }
 Where a resident buffer is. More...

Functions

int32_t tachyon::SnapPx (float v)
 Round half up, the same rule the box shader uses.
IntRect tachyon::SnapAbsolute (float4 px)
 A box with no snapped parent: each edge to the nearest pixel.
float4 tachyon::PixelBounds (const float3x2 &toPixels, IntRect r)
 The bounds of a rect mapped to window pixels, { x0, y0, x1, y1 }.
IntRect tachyon::SnapToParent (float4 parentPx, IntRect parentSnapped, float4 childPx)
 A nested box: each edge keeps its rounded distance from the parent's snapped edge on the same side.

Variables

constexpr float tachyon::kPrimitiveDepthStep = 1.0f / float(1 << 22)
 The depth between two primitives drawn one after the other; past the depth range all are at the nearest depth.
constexpr size_t tachyon::kPrimitiveKindCount = size_t(PrimitiveKind::Count)
constexpr PrimitiveSpec tachyon::kPrimitiveSpecs [kPrimitiveKindCount]
 Push-constant slot order matches the GLSL push block (box, glyph, dot, line, triangle).

Detailed Description

The graphics backend interface, renderer, images and custom drawing.

Typedef Documentation

◆ PipelineSet

◆ DeviceAddress

using tachyon::DeviceAddress = uint64_t

#include <gui_core/graphics/gui_render_primitives.h>

Shader-visible buffer address.

uint64_t on every modern API (VkDeviceAddress / D3D12_GPU_VIRTUAL_ADDRESS / MTLGPUAddress).

◆ ResidentBufferId

#include <gui_core/graphics/gui_rhi.h>

GPU storage kept across frames (UploadResidentBuffers); 0 is none.

Enumeration Type Documentation

◆ DrawSpace

enum class tachyon::DrawSpace : uint8_t
strong

#include <gui_core/graphics/gui_custom_draw_context.h>

The coordinate space a CustomDrawContext draws in.

Enumerator
Local 

The default: the registered element's content space, (0,0) at its padding box's top-left.

Its contentTransform (a node view's pan and zoom) and every ancestor's apply when drawing.

Screen 

Absolute layout pixels: the space of stored element rects and event.state.screenPos.

◆ DeviceScope

enum class tachyon::DeviceScope
strong

#include <gui_core/graphics/gui_graphics_context.h>

When a deferred GPU resource destruction runs: Frame once the frames that may use it are done, Application at Cleanup.

Enumerator
Frame 
Application 

◆ GraphicsAPI

enum class tachyon::GraphicsAPI : uint8_t
strong

#include <gui_core/graphics/gui_graphics_context.h>

The graphics API a backend presents with; window backends create their windows to match (SDL: SDL_WINDOW_VULKAN).

Enumerator
None 

nothing is presented (NullGraphicsContext)

Vulkan 

◆ ImageFormat

enum class tachyon::ImageFormat
strong

#include <gui_core/graphics/gui_image.h>

Pixel formats for GraphicsContext::CreateImage, 8 bits per channel.

The _SRGB formats decode sRGB to linear when sampled.

Enumerator
UNDEFINED 
R8 
R8_SRGB 
R8G8 
R8G8_SRGB 
R8G8B8 
R8G8B8_SRGB 
R8G8B8A8 
R8G8B8A8_SRGB 

◆ Sampler

enum class tachyon::Sampler
strong

#include <gui_core/graphics/gui_image.h>

How an image is filtered and addressed when sampled.

Enumerator
UNDEFINED 
NearestRepeat 
LinearRepeat 
LinearClampToEdge 

◆ ImageIndex

enum tachyon::ImageIndex : uint32_t

#include <gui_core/graphics/gui_image.h>

Index of an image in the graphics context's image set, as the shaders sample it.

Invalid (0) is no image.

Enumerator
Invalid 
Examples
host_device/host_device.cpp.

◆ PrimitiveKind

enum class tachyon::PrimitiveKind : uint8_t
strong

#include <gui_core/graphics/gui_render_primitives.h>

Enumerator
Box 
Glyph 
Dot 
Line 
Triangle 
Quad 
Circle 
Occluder 
Count 

◆ PrimitiveShape

enum class tachyon::PrimitiveShape : uint8_t
strong

#include <gui_core/graphics/gui_render_primitives.h>

The vertices a primitive's vertex shader is run for; gl_VertexIndex divided by their count is the primitive, the remainder the corner.

Enumerator
Quad 

4 corners of its rectangle, drawn as two indexed triangles (0,1,3, 0,3,2)

Triangle 

3 corners of one triangle around its shape (clipped per fragment)

◆ TriangleEdges

enum class tachyon::TriangleEdges : uint8_t
strong

#include <gui_core/graphics/gui_renderer.h>

A triangle's edges, for the ones drawn without a soft edge: where it meets another triangle of the same shape (a polygon's fan), so no seam shows between them.

Enumerator
None 
Edge01 

p0 to p1

Edge12 

p1 to p2

Edge20 

p2 to p0

◆ ResidentState

enum class tachyon::RHI::ResidentState : uint8_t
strong

#include <gui_core/graphics/gui_rhi.h>

Where a resident buffer is.

Enumerator
Gone 

released, or never made (or lost with its device)

Pending 

its copy to the GPU isn't recorded yet: it can't be drawn from this frame

Ready 

on the GPU: draws recorded from now on can read it

Function Documentation

◆ SnapPx()

int32_t tachyon::SnapPx ( float v)
inline

#include <gui_core/graphics/gui_pixel_snap.h>

Round half up, the same rule the box shader uses.

◆ SnapAbsolute()

IntRect tachyon::SnapAbsolute ( float4 px)
inline

#include <gui_core/graphics/gui_pixel_snap.h>

A box with no snapped parent: each edge to the nearest pixel.

◆ PixelBounds()

float4 tachyon::PixelBounds ( const float3x2 & toPixels,
IntRect r )
inline

#include <gui_core/graphics/gui_pixel_snap.h>

The bounds of a rect mapped to window pixels, { x0, y0, x1, y1 }.

◆ SnapToParent()

IntRect tachyon::SnapToParent ( float4 parentPx,
IntRect parentSnapped,
float4 childPx )
inline

#include <gui_core/graphics/gui_pixel_snap.h>

A nested box: each edge keeps its rounded distance from the parent's snapped edge on the same side.

Variable Documentation

◆ kPrimitiveDepthStep

float tachyon::kPrimitiveDepthStep = 1.0f / float(1 << 22)
inlineconstexpr

#include <gui_core/graphics/gui_render_primitives.h>

The depth between two primitives drawn one after the other; past the depth range all are at the nearest depth.

◆ kPrimitiveKindCount

size_t tachyon::kPrimitiveKindCount = size_t(PrimitiveKind::Count)
inlineconstexpr

◆ kPrimitiveSpecs

PrimitiveSpec tachyon::kPrimitiveSpecs[kPrimitiveKindCount]
inlineconstexpr

#include <gui_core/graphics/gui_render_primitives.h>

Initial value:
= {
{ "box_shader", sizeof(Box), 0 },
{ "glyph_shader", sizeof(Glyph), 1 },
{ "dot_shader", sizeof(Dot), 2, PrimitiveShape::Triangle },
{ "line_shader", sizeof(Line), 3 },
{ "triangle_shader", sizeof(Triangle), 4 },
{ "quad_shader", sizeof(Quad), 4 },
{ "circle_shader", sizeof(Circle), 3 },
{ "occluder_shader", sizeof(Occluder), 0, PrimitiveShape::Quad, true },
}
@ Triangle
3 corners of one triangle around its shape (clipped per fragment)
Definition gui_render_primitives.h:218
@ Quad
4 corners of its rectangle, drawn as two indexed triangles (0,1,3, 0,3,2)
Definition gui_render_primitives.h:217
Definition gui_render_primitives.h:33
A circle outline: the ring lineWidth wide around center at radius, its color and dashes running clock...
Definition gui_render_primitives.h:162
Definition gui_render_primitives.h:58
Definition gui_render_primitives.h:99
Depth only: marks pos/size as covered by opaque content drawn after it, so what was drawn before unde...
Definition gui_render_primitives.h:184
Definition gui_render_primitives.h:143
Definition gui_render_primitives.h:125

Push-constant slot order matches the GLSL push block (box, glyph, dot, line, triangle).

The block is exactly 128 bytes, with no room for more addresses, so Quad shares the Triangle slot, Circle the Line slot and Occluder the Box slot: each pass writes its own buffer address into its slot before drawing, and a draw call holds one kind.