TachyonUI 0.1.0
High-performance UI for building tools.
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
12
13#include <span>
14
15namespace tachyon::RHI
16{
19
21 {
22 uint64_t pipeline = 0;
23 uint64_t layout = 0;
24 bool IsValid() const { return pipeline != 0; }
25 };
26
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 {
43 };
44
47 {
48 public:
49 virtual ~RenderDevice() = default;
50
56
57 };
58
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;
87 };
88
89}
One frame's recording surface for one window.
Definition gui_rhi.h:61
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...
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...
virtual ResidentState ResidentBufferState(ResidentBufferId id) const =0
virtual ~RenderCommandList()=default
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...
virtual void ReleaseResidentBuffer(ResidentBufferId id)=0
Frees the buffer once no frame in flight reads it; an unknown id does nothing.
Device-lifetime operations.
Definition gui_rhi.h:47
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...
virtual ~RenderDevice()=default
uint64_t ResidentBufferId
GPU storage kept across frames (UploadResidentBuffers); 0 is none.
Definition gui_rhi.h:35
ResidentState
Where a resident buffer is.
Definition gui_rhi.h:39
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
@ Gone
released, or never made (or lost with its device)
Definition gui_rhi.h:40
@ Pending
its copy to the GPU isn't recorded yet: it can't be drawn from this frame
Definition gui_rhi.h:41
@ Ready
on the GPU: draws recorded from now on can read it
Definition gui_rhi.h:42
Definition gui_rhi.h:16
Definition gui_render_primitives.h:248
Definition gui_render_primitives.h:222
Definition gui_rhi.h:21
uint64_t pipeline
backend pipeline handle (VkPipeline on Vulkan)
Definition gui_rhi.h:22
bool IsValid() const
Definition gui_rhi.h:24
uint64_t layout
its layout, the shared GUI layout (VkPipelineLayout)
Definition gui_rhi.h:23
Definition gui_rhi.h:28
size_t bytes
Definition gui_rhi.h:30
const void * data
Definition gui_rhi.h:29
size_t alignment
Definition gui_rhi.h:31