aboutsummaryrefslogtreecommitdiff
path: root/src/rendering/rhi.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-24 18:28:39 +0200
committerhachem <im@hachem.wtf>2026-08-24 18:28:39 +0200
commita34c49f103c8950a57687ea3d866c244d95b4414 (patch)
treeff268f4a7f52769a252443d6f2822c9814e3bb1c /src/rendering/rhi.h
parent06398a7a176e123506de6e8851866a8bec0b3427 (diff)
[docs]: added a few comments cause i wont be able to read this in a week's time
Diffstat (limited to 'src/rendering/rhi.h')
-rw-r--r--src/rendering/rhi.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/rendering/rhi.h b/src/rendering/rhi.h
index 6a2042a..a92d65e 100644
--- a/src/rendering/rhi.h
+++ b/src/rendering/rhi.h
@@ -3,7 +3,7 @@
// Donut RHI (Render Hardware Interface): a small, portable GPU abstraction that
// OpenGL, Vulkan (and later Metal / D3D12) implement behind ONE interface, so the
// app's rendering — the black hole, the scene — is written ONCE on top and runs
-// on any backend. The shape is modelled on the explicit APIs (baked pipelines,
+// on any backend. the shape is modelled on the explicit APIs (baked pipelines,
// recorded command lists, explicit render targets); OpenGL emulates that, which
// is easy, whereas the reverse (making Vulkan speak GL's immediate mode) is not.
@@ -26,8 +26,8 @@ namespace Donut::RHI
D32, // 32-bit depth
};
- // The attachment signature of a render pass / target: a colour format plus an
- // optional depth format. A pipeline is compatible with any target sharing this
+ // the attachment signature of a render pass / target: a colour format plus an
+ // optional depth format. a pipeline is compatible with any target sharing this
// signature, so this is what replaces "which render pass" as an explicit value.
struct RenderTargetFormat
{
@@ -35,9 +35,9 @@ namespace Donut::RHI
Format depth = Format::None;
};
- // The window the device presents into. GLFW is the windowing layer for every
+ // the window the device presents into. GLFW is the windowing layer for every
// backend, so this carries the GLFWwindow*; each backend derives what it needs
- // (a GL context, a Vulkan surface, later a CAMetalLayer / HWND) from it. The
+ // (a GL context, a Vulkan surface, later a CAMetalLayer / HWND) from it. the
// RHI names the concept "native window" rather than baking GLFW into its API.
struct NativeWindow
{
@@ -53,23 +53,23 @@ namespace Donut::RHI
enum class CompareOp { Always, Less, LessEqual };
enum class Filter { Nearest, Linear };
- // One vertex attribute; offsets/stride are in bytes. `components` is 1..4 floats.
+ // one vertex attribute; offsets/stride are in bytes. `components` is 1..4 floats.
struct VertexAttribute { uint32_t location; uint32_t components; uint32_t offset; };
struct VertexLayout { uint32_t stride = 0; std::vector<VertexAttribute> attributes; };
- // A shader resource slot the pipeline exposes. `binding` is the set-0 binding
+ // a shader resource slot the pipeline exposes. `binding` is the set-0 binding
// index used by Vulkan; `name` is the GLSL block/sampler identifier used by the
- // OpenGL backend (GL 4.1 has no binding qualifier, so it binds by name). The app
+ // OpenGL backend (GL 4.1 has no binding qualifier, so it binds by name). the app
// declares both when building a pipeline (it knows its own shader).
enum class ResourceKind { UniformBuffer, Texture };
struct ResourceSlot { ResourceKind kind; uint32_t binding; std::string name; };
- // --- opaque GPU resources (backends subclass) --------------------------
+ // opaque GPU resources; each backend subclasses these.
class Buffer { public: virtual ~Buffer() = default; virtual auto update(const void* data, size_t size) -> void = 0; };
class Texture { public: virtual ~Texture() = default; };
class Pipeline{ public: virtual ~Pipeline() = default; };
- // An off-screen target (colour, optional depth). The swapchain is the implicit
+ // an off-screen target (colour, optional depth). the swapchain is the implicit
// default target, addressed by passing nullptr to begin_render_pass.
class RenderTarget
{
@@ -94,7 +94,7 @@ namespace Donut::RHI
RenderTargetFormat target; // attachment signature of the pass it draws into
};
- // Records draws for one frame. Obtained from Device::begin_frame (targets the
+ // records draws for one frame. obtained from Device::begin_frame (targets the
// swapchain) or created transiently for off-screen passes via the Device.
class CommandList
{
@@ -118,7 +118,7 @@ namespace Donut::RHI
virtual auto draw_indexed(uint32_t index_count) -> void = 0;
};
- // The backend root: owns the device/swapchain and creates every resource.
+ // the backend root: owns the device/swapchain and creates every resource.
class Device
{
public:
@@ -129,8 +129,8 @@ namespace Donut::RHI
virtual auto resize(int width, int height) -> void = 0;
virtual auto wait_idle() -> void = 0;
- // Present pacing: GL toggles the swap interval; Vulkan swaps the present
- // mode (FIFO vs IMMEDIATE) and rebuilds the swapchain. Default: no-op.
+ // present pacing: GL toggles the swap interval; Vulkan swaps the present
+ // mode (FIFO vs IMMEDIATE) and rebuilds the swapchain. default: no-op.
virtual auto set_vsync(bool enabled) -> void { (void)enabled; }
virtual auto create_buffer(BufferType type, size_t size, const void* data = nullptr) -> Ref<Buffer> = 0;
@@ -140,23 +140,23 @@ namespace Donut::RHI
Filter sample_filter = Filter::Linear, int mip_levels = 1) -> Ref<RenderTarget> = 0;
virtual auto create_pipeline(const PipelineDesc& desc) -> Ref<Pipeline> = 0;
- // Frame loop: begin_frame returns the frame's command list (or nullptr if
+ // frame loop: begin_frame returns the frame's command list (or nullptr if
// the frame is skipped, e.g. minimised); record one or more render passes
// into it — off-screen passes into RenderTargets first, then the swapchain
// pass (begin_render_pass(nullptr, ...)) — then end_frame submits + presents.
virtual auto begin_frame(const glm::vec4& clear) -> CommandList* = 0;
virtual auto end_frame() -> void = 0;
- // One-shot off-screen work outside the frame loop (used by the exporter):
+ // one-shot off-screen work outside the frame loop (used by the exporter):
// records a self-contained pass into a transient command list and blocks
// until the GPU finishes, so the target can be read back immediately.
virtual auto run_offscreen(const std::function<void(CommandList&)>& record) -> void = 0;
- // Reads a render target's colour back to the CPU as tightly-packed RGBA8,
- // top-left origin (out is resized to width*height*4). For export/analysis.
+ // reads a render target's colour back to the CPU as tightly-packed RGBA8,
+ // top-left origin (out is resized to width*height*4). for export/analysis.
virtual auto read_render_target(RenderTarget* target, std::vector<uint8_t>& out) -> void = 0;
- // Same, but as full-float RGBA (out resized to width*height*4 floats). Read
+ // same, but as full-float RGBA (out resized to width*height*4 floats). read
// an RGBA32F target back for raw observable export.
virtual auto read_render_target_float(RenderTarget* target, std::vector<float>& out) -> void = 0;