TachyonUI
0.1.0
High-performance UI for building tools.
Toggle main menu visibility
Loading...
Searching...
No Matches
gui_rhi.h
Go to the documentation of this file.
1
#pragma once
2
3
// Thin render-hardware-interface for the GUI primitive renderer - deliberately
4
// minimal: pipeline creation from a PrimitiveSpec, transient batch upload to
5
// fence-protected storage, and draw. Textures, samplers, descriptor
6
// sets, render passes and the swapchain are NOT part of this interface; they
7
// stay behind GraphicsContext / the backend's window context. A second backend
8
// implements these two classes (plus GraphicsContext) and compiles the shader
9
// pairs named by kPrimitiveSpecs to its own format.
10
11
#include <
gui_core/graphics/gui_render_primitives.h
>
12
13
#include <span>
14
15
namespace
tachyon::RHI
16
{
19
20
struct
GpuPipeline
21
{
22
uint64_t
pipeline
= 0;
23
uint64_t
layout
= 0;
24
bool
IsValid
()
const
{
return
pipeline
!= 0; }
25
};
26
27
struct
UploadRequest
28
{
29
const
void
*
data
=
nullptr
;
30
size_t
bytes
= 0;
31
size_t
alignment
= 16;
32
};
33
35
using
ResidentBufferId
= uint64_t;
36
38
enum class
ResidentState
: uint8_t
39
{
40
Gone
,
41
Pending
,
42
Ready
,
43
};
44
46
class
RenderDevice
47
{
48
public
:
49
virtual
~RenderDevice
() =
default
;
50
55
virtual
GpuPipeline
CreatePrimitivePipeline
(
const
PrimitiveSpec
& spec) = 0;
56
57
};
58
60
class
RenderCommandList
61
{
62
public
:
63
virtual
~RenderCommandList
() =
default
;
64
68
virtual
void
DrawPrimitives
(
const
GpuPipeline
& pipeline,
69
const
GPUDrawPushConstants
& pushConstants,
70
uint32_t primitiveCount, uint32_t firstPrimitive,
PrimitiveShape
shape) = 0;
71
75
virtual
void
UploadTransientBuffers
(std::span<const UploadRequest> requests,
76
std::span<DeviceAddress> addresses) = 0;
77
82
virtual
ResidentBufferId
UploadResidentBuffers
(std::span<const UploadRequest> requests,
83
std::span<DeviceAddress> addresses) = 0;
84
virtual
ResidentState
ResidentBufferState
(
ResidentBufferId
id
)
const
= 0;
86
virtual
void
ReleaseResidentBuffer
(
ResidentBufferId
id
) = 0;
87
};
88
89
}
tachyon::RHI::RenderCommandList
One frame's recording surface for one window.
Definition
gui_rhi.h:61
tachyon::RHI::RenderCommandList::UploadTransientBuffers
virtual void UploadTransientBuffers(std::span< const UploadRequest > requests, std::span< DeviceAddress > addresses)=0
Copies a batch of transient data into storage that remains valid until this command list's frame fenc...
tachyon::RHI::RenderCommandList::DrawPrimitives
virtual void DrawPrimitives(const GpuPipeline &pipeline, const GPUDrawPushConstants &pushConstants, uint32_t primitiveCount, uint32_t firstPrimitive, PrimitiveShape shape)=0
Binds the pipeline and the GUI image set, pushes the constants and draws primitiveCount primitives st...
tachyon::RHI::RenderCommandList::ResidentBufferState
virtual ResidentState ResidentBufferState(ResidentBufferId id) const =0
tachyon::RHI::RenderCommandList::~RenderCommandList
virtual ~RenderCommandList()=default
tachyon::RHI::RenderCommandList::UploadResidentBuffers
virtual ResidentBufferId UploadResidentBuffers(std::span< const UploadRequest > requests, std::span< DeviceAddress > addresses)=0
Copies a batch of data into GPU memory that stays until released, for data drawn again over many fram...
tachyon::RHI::RenderCommandList::ReleaseResidentBuffer
virtual void ReleaseResidentBuffer(ResidentBufferId id)=0
Frees the buffer once no frame in flight reads it; an unknown id does nothing.
tachyon::RHI::RenderDevice
Device-lifetime operations.
Definition
gui_rhi.h:47
tachyon::RHI::RenderDevice::CreatePrimitivePipeline
virtual GpuPipeline CreatePrimitivePipeline(const PrimitiveSpec &spec)=0
Builds the pipeline for one primitive kind: the spec's shader pair + the fixed GUI pipeline state (tr...
tachyon::RHI::RenderDevice::~RenderDevice
virtual ~RenderDevice()=default
tachyon::RHI::ResidentBufferId
uint64_t ResidentBufferId
GPU storage kept across frames (UploadResidentBuffers); 0 is none.
Definition
gui_rhi.h:35
tachyon::RHI::ResidentState
ResidentState
Where a resident buffer is.
Definition
gui_rhi.h:39
tachyon::PrimitiveShape
PrimitiveShape
The vertices a primitive's vertex shader is run for; gl_VertexIndex divided by their count is the pri...
Definition
gui_render_primitives.h:216
tachyon::RHI::ResidentState::Gone
@ Gone
released, or never made (or lost with its device)
Definition
gui_rhi.h:40
tachyon::RHI::ResidentState::Pending
@ Pending
its copy to the GPU isn't recorded yet: it can't be drawn from this frame
Definition
gui_rhi.h:41
tachyon::RHI::ResidentState::Ready
@ Ready
on the GPU: draws recorded from now on can read it
Definition
gui_rhi.h:42
gui_render_primitives.h
tachyon::RHI
Definition
gui_rhi.h:16
tachyon::GPUDrawPushConstants
Definition
gui_render_primitives.h:248
tachyon::PrimitiveSpec
Definition
gui_render_primitives.h:222
tachyon::RHI::GpuPipeline
Definition
gui_rhi.h:21
tachyon::RHI::GpuPipeline::pipeline
uint64_t pipeline
backend pipeline handle (VkPipeline on Vulkan)
Definition
gui_rhi.h:22
tachyon::RHI::GpuPipeline::IsValid
bool IsValid() const
Definition
gui_rhi.h:24
tachyon::RHI::GpuPipeline::layout
uint64_t layout
its layout, the shared GUI layout (VkPipelineLayout)
Definition
gui_rhi.h:23
tachyon::RHI::UploadRequest
Definition
gui_rhi.h:28
tachyon::RHI::UploadRequest::bytes
size_t bytes
Definition
gui_rhi.h:30
tachyon::RHI::UploadRequest::data
const void * data
Definition
gui_rhi.h:29
tachyon::RHI::UploadRequest::alignment
size_t alignment
Definition
gui_rhi.h:31
gui_core
graphics
gui_rhi.h
Generated by
1.18.0