From 43151809dac7041bd04bb5181abf7f1182ffea7f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 01:48:48 -0300 Subject: Add pardes's cell shaders, instance ABI and GPU resource helpers Moved verbatim from pardes's src/gui/gui.zig (step S1 of moving its renderer here): the seven GLSL shaders and their committed SPIR-V under src/gpu/shaders/, and src/gpu/Cells.zig with the instance structs the shaders read, the vertex inputs, makePipeline, the layer blend, texture2d and growInstances (which takes the device instead of pardes's Gui). Cells.zig imports the embedder's own SDL translation as `c`; pardes compiles it from this checkout. `zig build shaders` refreshes the prebuilt SPIR-V. --- build.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 1933d92..e441471 100644 --- a/build.zig +++ b/build.zig @@ -47,6 +47,16 @@ pub fn build(b: *Build) void { const abi = b.addModule("abi", .{ .root_source_file = b.path("src/abi.zig") }); const gpu = b.addModule("gpu", .{ .root_source_file = b.path("src/gpu/Executor.zig"), .imports = &.{.{ .name = "abi", .module = abi }} }); _ = b.addModule("gpu_scene", .{ .root_source_file = b.path("src/gpu/scene.zig"), .imports = &.{.{ .name = "abi", .module = abi }} }); + // The cell renderer's shaders (src/gpu/Cells.zig): embedders compile the + // GLSL or embed these committed copies; this refreshes the copies. + const update_shaders = b.addUpdateSourceFiles(); + for ([_][]const u8{ "ui.vert", "ui.frag", "decor.frag", "overlay.vert", "overlay.frag", "image.vert", "image.frag" }) |name| { + const glslc = b.addSystemCommand(&.{ "glslc", b.fmt("-fshader-stage={s}", .{if (std.mem.endsWith(u8, name, ".vert")) "vertex" else "fragment"}) }); + glslc.addFileArg(b.path(b.fmt("src/gpu/shaders/{s}.glsl", .{name}))); + glslc.addArg("-o"); + update_shaders.addCopyFileToSource(glslc.addOutputFileArg(b.fmt("{s}.spv", .{name})), b.fmt("src/gpu/shaders/prebuilt/{s}.spv", .{name})); + } + b.step("shaders", "refresh the committed src/gpu/shaders/prebuilt/*.spv (glslc)").dependOn(&update_shaders.step); // Embedders provide their existing SDL translation and device. if (b.option(bool, "gpu-only", "export GPU modules without building the sketch host") orelse false) return; // Geometry and noise, shared by the sketch library and `vector`. -- cgit v1.3