From 1cb36ee39a8bbc2cf61c28003670d760841d6d3e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 22:02:43 -0300 Subject: gpu: add a post-process pass with optional depth sampling, and describe the executor pardes shares `f.postProcess(source, target, .{...})` records a fullscreen pass that samples a completed render into a distinct target image: colour at fragment binding 0 and, with `sample_depth`, depth at 1, which needs the source's latest pass to have depth and one sample (missing depth, multisampled depth and feedback loops are rejected). The scene format's version 4 carries it, the executor records it on the caller's command buffer and owns the sampler, the web host does the same with its texture and sampler pairs, and native profiling reports the work as `postprocess`. The README says how to use it. docs/pardes-rendering.md describes the executor as pardes uses it for addon scenes: a borrowed SDL GPU device, `record` into the caller's command buffer, `run`, `output` and `postProcess`. The working copy as it stood on 2026-11-16; message written by Claude from the diff, at the author's request. --- src/host/Host.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/host') diff --git a/src/host/Host.zig b/src/host/Host.zig index 745d9a1..035a004 100644 --- a/src/host/Host.zig +++ b/src/host/Host.zig @@ -447,6 +447,7 @@ fn draw(self: *Host, now: u64, started: u64) !u64 { .audio => |a| self.audio.push(a.key, a.samples, a.clear), .quit => self.quit = true, .gpu => |pass| if (self.passes) |*g| self.runGpu(g, pass) catch |err| self.print("gpu pass: {t} ({s})", .{ err, c.SDL_GetError() }), + .post_process => |p| if (self.passes) |*g| self.runPostProcess(g, p.source, p.target, p.effect) catch |err| self.print("gpu postprocess: {t} ({s})", .{ err, c.SDL_GetError() }), .upload => |u| if (self.passes) |*g| g.write(u.buffer, u.offset, u.bytes) catch |err| self.print("gpu upload: {t} ({s})", .{ err, c.SDL_GetError() }), .compute => |d| if (self.passes) |*g| g.compute(d) catch |err| self.print("gpu compute: {t} ({s})", .{ err, c.SDL_GetError() }), .microphone => self.audio.listen(), @@ -981,6 +982,15 @@ fn apiEnv(ctx: *anyopaque, name: []const u8) ?[]const u8 { return hostOf(ctx).environ.get(name); } +fn runPostProcess(self: *Host, g: *Gpu, source: abi.Image, target: abi.Image, post: abi.gpu.PostProcess) !void { + const input = g.output(source) orelse return error.MissingImage; + const before = g.output(target); + const changed = if (before) |t| t.width != input.width or t.height != input.height else true; + if (changed) self.images.unwrap(target); + try g.runPostProcess(source, target, post); + if (g.output(target)) |t| try self.images.wrap(target, t.texture, t.width, t.height); +} + fn runGpu(self: *Host, g: *Gpu, pass: abi.gpu.Pass) !void { const before = g.output(pass.image); const changed = if (before) |t| t.width != pass.width or t.height != pass.height else true; -- cgit v1.3