diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 01:48:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 43151809dac7041bd04bb5181abf7f1182ffea7f (patch) | |
| tree | 7a81f64c72683cc8b88c3a371dc17d18d23b499e /build.zig | |
| parent | 1cb36ee39a8bbc2cf61c28003670d760841d6d3e (diff) | |
| download | sketchbook-43151809dac7041bd04bb5181abf7f1182ffea7f.tar.gz sketchbook-43151809dac7041bd04bb5181abf7f1182ffea7f.zip | |
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.
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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`. |
