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/abi.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/abi.zig') diff --git a/src/abi.zig b/src/abi.zig index d91fa23..7177f14 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -370,6 +370,8 @@ pub const Command = union(enum) { /// Renders a GPU pass into an image made by `Host.newImage`, when /// `Host.gpu` says the host can. gpu: gpu.Pass, + /// Fullscreen pass sampling a completed GPU image, into a different image. + post_process: struct { source: Image, target: Image, effect: gpu.PostProcess }, /// Bytes into a buffer made by `Host.newBuffer`, at `offset`. upload: struct { buffer: Buffer, offset: u32 = 0, bytes: []const u8 }, /// Runs a compute shader over buffers (see `abi.gpu`). @@ -579,8 +581,10 @@ pub const gpu = struct { draws: []const Draw, }; - /// A fullscreen triangle sampling one completed pass at fragment binding 0. + /// Fullscreen triangle: color at fragment binding 0, optional depth at 1. pub const PostProcess = struct { + /// Requires a preceding single-sample pass with depth enabled. + sample_depth: bool = false, vertex: Shader, fragment: Shader, fragment_uniforms: []const u8 = &.{}, @@ -813,7 +817,7 @@ pub const Sketch = struct { pub const hash: u64 = blk: { @setEvalBranchQuota(1_000_000); var h: u64 = 0; - for (.{ Rect, Color, BlendMode, Corners, Event, Mode, Stream, Input, Image, Audio, Cursor, Voice, Command, gpu.Pass, gpu.Pipeline, gpu.Draw, gpu.Dispatch, Host, Host.VTable, Context, Field, Layout, Info, Memory, Sketch }) |T| { + for (.{ Rect, Color, BlendMode, Corners, Event, Mode, Stream, Input, Image, Audio, Cursor, Voice, Command, gpu.Pass, gpu.Pipeline, gpu.Draw, gpu.Dispatch, gpu.PostProcess, Host, Host.VTable, Context, Field, Layout, Info, Memory, Sketch }) |T| { h = std.hash.Wyhash.hash(h, @typeName(T) ++ layout.signature(T)); } break :blk h; -- cgit v1.3