TachyonUI 1.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 <cstddef>
14#include <span>
15
16namespace tachyon::RHI
17{
20
22 {
23 uint64_t pipeline = 0;
24 uint64_t layout = 0;
25 bool IsValid() const { return pipeline != 0; }
26 };
27
29 {
30 const void* data = nullptr;
31 size_t bytes = 0;
32 size_t alignment = 16;
33 };
34
36 using ResidentBufferId = uint64_t;
37
39 enum class ResidentState : uint8_t
40 {
44 };
45
48 {
49 public:
50 virtual ~RenderDevice() = default;
51
57
58 };
59
62 {
63 public:
64 virtual ~RenderCommandList() = default;
65
71 virtual void DrawPrimitives(const GpuPipeline& pipeline,
72 const GPUDrawPushConstants& pushConstants,
73 uint32_t primitiveCount, uint32_t firstPrimitive, PrimitiveShape shape,
74 std::span<const std::byte> primitives) = 0;
75
79 virtual void UploadTransientBuffers(std::span<const UploadRequest> requests,
80 std::span<DeviceAddress> addresses) = 0;
81
86 virtual ResidentBufferId UploadResidentBuffers(std::span<const UploadRequest> requests,
87 std::span<DeviceAddress> addresses) = 0;
91 };
92
93}
One frame's recording surface for one window.
Definition gui_rhi.h:62
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, std::span< const std::byte > primitives)=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:48
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:36
ResidentState
Where a resident buffer is.
Definition gui_rhi.h:40
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:225
@ Gone
released, or never made (or lost with its device)
Definition gui_rhi.h:41
@ Pending
its copy to the GPU isn't recorded yet: it can't be drawn from this frame
Definition gui_rhi.h:42
@ Ready
on the GPU: draws recorded from now on can read it
Definition gui_rhi.h:43
Definition gui_rhi.h:17
Definition gui_render_primitives.h:257
Definition gui_render_primitives.h:231
Definition gui_rhi.h:22
uint64_t pipeline
backend pipeline handle (VkPipeline on Vulkan)
Definition gui_rhi.h:23
bool IsValid() const
Definition gui_rhi.h:25
uint64_t layout
its layout, the shared GUI layout (VkPipelineLayout)
Definition gui_rhi.h:24
Definition gui_rhi.h:29
size_t bytes
Definition gui_rhi.h:31
const void * data
Definition gui_rhi.h:30
size_t alignment
Definition gui_rhi.h:32