From c5b5991bbe40f17df9e4a7b3e171d35636f67ab6 Mon Sep 17 00:00:00 2001 From: abux Date: Fri, 10 Jul 2026 00:23:33 +0100 Subject: [PATCH] added render_queue.zig, camera_render_queue.zig and draw_cmd.zig --- src/plugin.zig | 1 + src/resource/render_queue.zig | 34 ++++++++++++++++++++++ src/resource/root.zig | 3 ++ src/template/camera_pass.zig | 1 - src/template/camera_render_queue.zig | 43 ++++++++++++++++++++++++++++ src/template/draw_cmd.zig | 14 +++++++++ src/template/root.zig | 3 +- 7 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/resource/render_queue.zig delete mode 100644 src/template/camera_pass.zig create mode 100644 src/template/camera_render_queue.zig diff --git a/src/plugin.zig b/src/plugin.zig index 9612ca7..000d691 100644 --- a/src/plugin.zig +++ b/src/plugin.zig @@ -20,6 +20,7 @@ fn build( try ctx.app.resources.set(resource.Instance{}); try ctx.app.resources.set(resource.Device{}); try ctx.app.resources.set(resource.window{}); + try ctx.app.resources.set(resource.RenderQueue.init(ctx.app.alloc)); // --- INIT --- try ctx.app.schedules.addMany(App.stage.Init, &.{ diff --git a/src/resource/render_queue.zig b/src/resource/render_queue.zig new file mode 100644 index 0000000..fc2cf66 --- /dev/null +++ b/src/resource/render_queue.zig @@ -0,0 +1,34 @@ +//! ---------------------------------------------------- +//! ---------------------------------------------------- + +const std = @import("std"); +const CameraRenderQueue = @import("../template/camera_render_queue.zig"); +const Self = @This(); + +// +// FIELDS +// + +data: std.ArrayList(CameraRenderQueue), +alloc: std.mem.Allocator, + +/// ---------------------------------------------------- +/// ---------------------------------------------------- +pub fn init(alloc: std.mem.Allocator) Self { + return .{ + .data = .empty, + .alloc = alloc, + }; +} + +/// ---------------------------------------------------- +/// ---------------------------------------------------- +pub fn deinit(self: *Self) void { + self.data.deinit(self.alloc); +} + +/// ---------------------------------------------------- +/// ---------------------------------------------------- +pub fn clear(self: *Self) void { + self.data.clearRetainingCapacity(); +} diff --git a/src/resource/root.zig b/src/resource/root.zig index fcf9dd6..f7072dc 100644 --- a/src/resource/root.zig +++ b/src/resource/root.zig @@ -2,3 +2,6 @@ pub const Instance = @import("instance.zig"); pub const Device = @import("device.zig"); pub const window = @import("window.zig"); + +// --- DRAW --- +pub const RenderQueue = @import("render_queue.zig"); diff --git a/src/template/camera_pass.zig b/src/template/camera_pass.zig deleted file mode 100644 index 95a0b68..0000000 --- a/src/template/camera_pass.zig +++ /dev/null @@ -1 +0,0 @@ -const std = @import("std"); diff --git a/src/template/camera_render_queue.zig b/src/template/camera_render_queue.zig new file mode 100644 index 0000000..2498ada --- /dev/null +++ b/src/template/camera_render_queue.zig @@ -0,0 +1,43 @@ +//! ---------------------------------------------------- +//! ---------------------------------------------------- + +const std = @import("std"); +const DrawCMD = @import("draw_cmd.zig"); +const Self = @This(); + +// +// FIELDS +// + +shadows: std.ArrayList(DrawCMD), +opaques: std.ArrayList(DrawCMD), +transparents: std.ArrayList(DrawCMD), +alloc: std.mem.Allocator, + +/// ---------------------------------------------------- +/// ---------------------------------------------------- +pub fn init(alloc: std.mem.Allocator) Self { + return .{ + .shadows = .empty, + .opaques = .empty, + .transparents = .empty, + .alloc = alloc, + }; +} + +/// ---------------------------------------------------- +/// ---------------------------------------------------- +pub fn deinit(self: *Self) void { + self.shadows.deinit(self.alloc); + self.opaques.deinit(self.alloc); + self.transparents.deinit(self.alloc); +} + +/// ---------------------------------------------------- +/// ---------------------------------------------------- +pub fn clear(self: *Self) void { + self.shadows.clearRetainingCapacity(); + self.opaques.clearRetainingCapacity(); + self.transparents.clearRetainingCapacity(); +} + diff --git a/src/template/draw_cmd.zig b/src/template/draw_cmd.zig index e69de29..57a5ec3 100644 --- a/src/template/draw_cmd.zig +++ b/src/template/draw_cmd.zig @@ -0,0 +1,14 @@ +//! ---------------------------------------------------- +//! ---------------------------------------------------- + +const std = @import("std"); +const App = @import("app"); +const Handle = App.template.Handle; + +// +// FIELDS +// + +mesh: Handle(undefined), +pipeline: Handle(undefined), +bind_group: Handle(undefined), diff --git a/src/template/root.zig b/src/template/root.zig index 1e1606f..d104916 100644 --- a/src/template/root.zig +++ b/src/template/root.zig @@ -1,3 +1,4 @@ pub const Registry = @import("registry.zig").Registry; -pub const CameraPass = @import("camera_pass.zig"); + +pub const CameraRenderQueue = @import("camera_render_queue.zig"); pub const DrawCMD = @import("draw_cmd.zig");