diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-12 10:56:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | f2b02c455f2bcdfb905a015eefbb630a28b4b12e (patch) | |
| tree | c344c7ad42ec288dd5e1ebd0eb6d25f5aa2fbccc /src/screen_state.zig | |
| parent | fc38c73c59f7855a4caad8aa4d3bb8e023309c13 (diff) | |
| download | pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.tar.gz pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.zip | |
addons: an addon can hand the frontend a GPU scene (ABI 3.1), and a snake drawn by shaders does; a commit's patch keeps its own +Diff pane; a real ZLS checked through the window build
ABI 3.1 appends an optional `gpu` callback and its context to pa_paint: one self-contained sketchbook SGPU v1 scene for the pane, at most 4 MiB, copied during the call, the last successful call winning. The SDL frontend runs it on its own GPU through sketchbook's executor and composites its target texture into the pane; replicas carry the scene beside the authoritative pane frame; cells and rasters stay the fallback for terminals, older hosts and frontends without an executor. addons/snake_shader is such an addon (`zig build snake-shader`, the SnakeShader word: a board that follows its pane, buffered turns, a CRT look), with test/gpu_snake.py, test/gpu_snake_interaction.py and test/gpu_upgrade.py.
Commit patches open as `+Diff-<short-hash>` and reuse only their own commit's pane, so another paged patch no longer replaces one already open.
The language-server client looks in the standard per-user bin directory, which desktop launchers often leave out of PATH, and takes an empty answer that beats the startup progress notification onto the wire; test/real_zls.py checks imports, hover, references, rename previews, diagnostics and completion against a real ZLS from a private home.
The dump's schema reader skips two fields older builds persisted, and a replica's shadow of a kind ticks when the authority's does. The reference, the guide, the building and setup notes and the changelog say so.
The working copy as it stood on 2026-11-12; message written by Claude from the diff, at the author's request.
Diffstat (limited to 'src/screen_state.zig')
| -rw-r--r-- | src/screen_state.zig | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/screen_state.zig b/src/screen_state.zig index eeb1c059..8032e79a 100644 --- a/src/screen_state.zig +++ b/src/screen_state.zig @@ -1154,6 +1154,7 @@ const Place = Kind.c.pa_placement; /// A replica's frame of a pane of a kind: what Kind.draw draws for it, its /// placements' pixels its peer's `Blobs`. pub const Shadow = struct { + gpu: []const u8 = &.{}, cols: u16 = 0, rows: u16 = 0, cells: []Cell = &.{}, @@ -1164,6 +1165,7 @@ pub const Shadow = struct { wanted: u64 = 0, pub fn deinit(sh: *Shadow, gpa: std.mem.Allocator) void { + gpa.free(sh.gpu); gpa.free(sh.cells); gpa.free(sh.hashes); sh.places.deinit(gpa); @@ -1216,6 +1218,12 @@ pub const Shadow = struct { }).ptr; try sh.places.append(gpa, pl); } + // Older frames have no optional GPU tail. + const n = if (r.seek < r.end) try r.takeInt(u32, .little) else 0; + if (n > 4 << 20) return error.BadGpuFrame; + const gpu = try gpa.dupe(u8, try r.take(n)); + gpa.free(sh.gpu); + sh.gpu = gpu; if (lacking == sh.wanted) return 0; sh.wanted = lacking; return lacking; @@ -1354,6 +1362,7 @@ pub fn encodeShadow(gpa: std.mem.Allocator, sent: *ShadowSent, f: *const Kind.Fr const places = f.places[0..@min(f.n, 64)]; var ph = std.hash.Wyhash.init(pointer); for (places) |*pl| inline for (.{ pl.w, pl.h, pl.src, pl.at, pl.dst, pl.key }) |v| ph.update(std.mem.asBytes(&v)); + if (f.gpu.len != 0) ph.update(f.gpu); const places_hash = ph.final(); if (sent.cols == f.cols and std.mem.eql(Hash, sent.hashes.items, hashes.items) and sent.places == places_hash) { hashes.deinit(gpa); @@ -1384,6 +1393,9 @@ pub fn encodeShadow(gpa: std.mem.Allocator, sent: *ShadowSent, f: *const Kind.Fr inline for (.{ pl.dst.x, pl.dst.y, pl.dst.w, pl.dst.h }) |v| try w.writeInt(u16, v, .little); try w.writeInt(u64, pl.key, .little); } + if (f.gpu.len > 4 << 20) return error.BadGpuFrame; + try w.writeInt(u32, @intCast(f.gpu.len), .little); + try w.writeAll(f.gpu); sent.hashes.deinit(gpa); sent.hashes = hashes; sent.cols = f.cols; @@ -1626,3 +1638,27 @@ test "a pane of a kind crosses as its frame, a row the peer holds as its hash, a try std.testing.expectEqual(@as(usize, 0), sh.places.items.len); try std.testing.expectEqual(@as(u64, 0), try sh.apply(gpa, out.written(), 1, &blobs)); } + +test "optional GPU frames cross shadows, change independently, and disappear" { + const gpa = std.testing.allocator; + var sent: ShadowSent = .{}; + defer sent.deinit(gpa); + const shadow = try gpa.create(Shadow); + shadow.* = .{}; + defer shadow.deinit(gpa); + var blobs: Blobs = .{}; + defer blobs.deinit(gpa); + var cell = std.mem.zeroes(Cell); + var frame: Kind.Frame = .{ .cols = 1, .rows = 1, .cells = @as([*]Cell, @ptrCast(&cell))[0..1], .gpu = "first scene" }; + var out: std.Io.Writer.Allocating = .init(gpa); + defer out.deinit(); + for ([_][]const u8{ "first scene", "second scene", "" }) |bytes| { + frame.gpu = bytes; + out.clearRetainingCapacity(); + try std.testing.expect(try encodeShadow(gpa, &sent, &frame, 0, &out.writer)); + _ = try shadow.apply(gpa, out.written(), 1, &blobs); + try std.testing.expectEqualStrings(bytes, shadow.gpu); + out.clearRetainingCapacity(); + try std.testing.expect(!try encodeShadow(gpa, &sent, &frame, 0, &out.writer)); + } +} |
