summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:13:53 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:40:08 -0300
commitb1d2c6ae01bf08370e18913ac6a7e8f0074c9113 (patch)
tree37612ae2f85e931ba62c6d91674a758896133802
parent3ece644731e94584beb17bc75e3628ecde8cd7d2 (diff)
downloadpardes-b1d2c6ae01bf08370e18913ac6a7e8f0074c9113.tar.gz
pardes-b1d2c6ae01bf08370e18913ac6a7e8f0074c9113.zip
gui: gripDecor draws a grip's mode bars from its first row without a loop over the rows it skipped, Post's vignette ceiling is shadowCeiling's (the same sum), ShaderBuild drops expand and a Wake struct whose ctx was never set, and ShaderBuild's and Post's headers say an attached window runs the bundled passes alone (no SPIR-V travels the wire)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
-rw-r--r--src/ShaderBuild.zig30
-rw-r--r--src/gui/Post.zig10
-rw-r--r--src/gui/gui.zig38
3 files changed, 33 insertions, 45 deletions
diff --git a/src/ShaderBuild.zig b/src/ShaderBuild.zig
index e5b6680b..74ec6826 100644
--- a/src/ShaderBuild.zig
+++ b/src/ShaderBuild.zig
@@ -1,7 +1,7 @@
//! The post chain's Shadertoy files as SPIR-V (docs/render-pipeline.md §6),
-//! for whichever process holds the core: a local GUI makes its pipelines
-//! from them, a detached session sends them to the GUIs attached to it
-//! (wire `post`), which never read a disk or run a program themselves.
+//! for the window that holds the core, which makes its pipelines from them.
+//! A window attached to a session elsewhere compiles none: it runs the
+//! bundled passes alone.
//!
//! Each file compiles behind the prefix by the build's own glslc invocation,
//! on a thread of its own and never on the frame path, when it joins the
@@ -24,8 +24,8 @@ const prefix = @embedFile("post-prefix.glsl");
/// A pass as a shell draws it: a bundled scene at its level, or a file with
/// its last good SPIR-V (empty until a compile succeeds), whose `revision`
-/// moves each time that SPIR-V does. Slices borrow the build's (or, in an
-/// attached GUI, the client's) storage until its next change.
+/// moves each time that SPIR-V does. Slices borrow the build's storage
+/// until its next change.
pub const Pass = struct {
scene: ?Scene = null,
level: u8 = 0,
@@ -51,10 +51,7 @@ pub fn readsTime(source: []const u8) bool {
}
/// Who to wake when a compile is done: the host's loop.
-pub const Wake = struct {
- ctx: ?*anyopaque = null,
- call: ?*const fn (?*anyopaque) void = null,
-};
+pub const Wake = ?*const fn (?*anyopaque) void;
const File = struct {
path: []u8 = &.{},
@@ -137,7 +134,7 @@ pub fn sync(b: *Build, gpa: std.mem.Allocator, io: std.Io, core: *pardes.Pardes,
b.len = len;
var bufs: [max][4096]u8 = undefined;
var expanded: [max][]const u8 = undefined;
- for (paths[0..len], 0..) |path, i| expanded[i] = expand(&bufs[i], path);
+ for (paths[0..len], 0..) |path, i| expanded[i] = pardes.filesystem.expandHome(path, &bufs[i]);
file_watch.watchShaders(fd, watches, expanded[0..len]);
}
var stale = false;
@@ -241,11 +238,6 @@ fn collect(b: *Build, gpa: std.mem.Allocator, core: *pardes.Pardes, job: *Job) v
}
}
-/// `~` is the home directory (the one rule, filesystem.expandHome).
-fn expand(buf: *[4096]u8, path: []const u8) []const u8 {
- return pardes.filesystem.expandHome(path, buf);
-}
-
/// The compile thread: each file behind the prefix, through glslc with the
/// build's own flags (build.zig compileGlsl), source on stdin, SPIR-V on
/// stdout.
@@ -255,14 +247,14 @@ fn compile(job: *Job) void {
job.results[i] = compileOne(job.gpa, job.io, path, job.known[i]);
}
job.done.store(true, .release);
- if (job.wake.call) |call| call(job.wake.ctx);
+ if (job.wake) |wake| wake(null);
}
fn compileOne(gpa: std.mem.Allocator, io: std.Io, path: []const u8, known: ?u64) Result {
var home_buf: [4096]u8 = undefined;
// Not fs.zig's readFile: that hands the core's turn over for the read,
// a turn this thread never holds.
- const body = std.Io.Dir.cwd().readFileAlloc(io, expand(&home_buf, path), gpa, .limited(1 << 20)) catch |err|
+ const body = std.Io.Dir.cwd().readFileAlloc(io, pardes.filesystem.expandHome(path, &home_buf), gpa, .limited(1 << 20)) catch |err|
return .{ .failed = .{ .text = std.fmt.allocPrint(gpa, "cannot read it ({t})", .{err}) catch return .none, .source = 0 } };
defer gpa.free(body);
const source = std.hash.Wyhash.hash(0, body);
@@ -384,11 +376,11 @@ test "a save that changes a file compiles it again, a failed one keeps the last
defer b.deinit(gpa, fd, &watches);
const settle = struct {
fn run(build: *Build, c: *pardes.Pardes, f: c_int, w: *file_watch.Table) void {
- _ = build.sync(std.testing.allocator, std.testing.io, c, f, w, .{});
+ _ = build.sync(std.testing.allocator, std.testing.io, c, f, w, null);
while (build.job) |job| {
job.future.await(std.testing.io);
job.done.store(true, .release);
- _ = build.sync(std.testing.allocator, std.testing.io, c, f, w, .{});
+ _ = build.sync(std.testing.allocator, std.testing.io, c, f, w, null);
}
}
}.run;
diff --git a/src/gui/Post.zig b/src/gui/Post.zig
index 64a431b9..19b10c52 100644
--- a/src/gui/Post.zig
+++ b/src/gui/Post.zig
@@ -2,8 +2,8 @@
//! finished frame, each reading the one before it (the frame first) and the
//! last one writing the window. A pass is the bundled Crt (shaders/post/,
//! compiled with the build) or a user's file (Shader <path>), whose SPIR-V
-//! comes from ShaderBuild.zig: compiled by the process that holds the core,
-//! this one or the detached session this GUI is attached to. A file whose
+//! comes from ShaderBuild.zig, compiled by this process (a window attached
+//! to a session elsewhere runs the bundled passes alone). A file whose
//! compile fails keeps its last good pipeline.
//!
//! The uniforms are ghostty's (Uniforms), so a shader written for ghostty runs
@@ -289,7 +289,6 @@ fn unit(rgb: [3]u8) [3]f32 {
pub fn capsOf(frame: Frame) std.EnumArray(Scene, f32) {
const pairs = [_][2][3]f32{ .{ unit(frame.foreground), unit(frame.background) }, .{ unit(frame.selection_foreground), unit(frame.selection_background) } };
var bloom: f32 = 1;
- var shade: f32 = 1;
for (pairs) |pair| {
const a = luminance(pair[0]);
const b = luminance(pair[1]);
@@ -298,10 +297,9 @@ pub fn capsOf(frame: Frame) std.EnumArray(Scene, f32) {
const target = @min(contrastOf(a, b), 4.5);
// (light + e + .05) / (dark + e + .05) >= target
bloom = @min(bloom, @max(0, (light + 0.05 - target * (dark + 0.05)) / @max(target - 1, 1e-3)));
- // (k light + .05) / (k dark + .05) >= target, darkened by 1 - k
- const room = light - target * dark;
- shade = @min(shade, if (room <= 0) 0 else std.math.clamp(1 - 0.05 * (target - 1) / room, 0, 1));
}
+ // A vignette darkens both of a pair as a lift's shadow does.
+ const shade = @min(gui.shadowCeiling(frame.foreground, frame.background), gui.shadowCeiling(frame.selection_foreground, frame.selection_background));
// Grain: the largest step off the page, up and down, that keeps the text
// on it at its contrast or 4.5 (searched in 1/1020 steps up to 8/255).
const ink = luminance(unit(frame.foreground));
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 3ed97f10..c7b52fc4 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -4484,7 +4484,7 @@ fn pollFrame(ctx: ?*anyopaque) void {
const geom = windowCells(g);
if (updateCoreResize(core, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) resetScroll(g);
stepScroll(g, core, s.gpa);
- _ = s.shaders.sync(s.gpa, s.io, core, s.inotify_fd, s.watches, .{ .call = sdlWake });
+ _ = s.shaders.sync(s.gpa, s.io, core, s.inotify_fd, s.watches, sdlWake);
{
var passes: [Post.max]ShaderBuild.Pass = undefined;
g.post.sync(s.gpa, g.device, g.swapchain_format, s.shaders.view(&core.settings.post, &passes), s.shaders.revision, core);
@@ -8959,7 +8959,7 @@ const luminance = pardes.colors.relativeLuminance;
/// How dark a shadow may make the page and its text, both together, before
/// the pair drops below its own contrast or 4.5, whichever is lower (§8.2):
/// darkening in linear light by k leaves (k L1 + .05) / (k L2 + .05).
-fn shadowCeiling(fg: [3]u8, bg: [3]u8) f32 {
+pub fn shadowCeiling(fg: [3]u8, bg: [3]u8) f32 {
const a = luminance(fg);
const b = luminance(bg);
const light = @max(a, b);
@@ -9839,25 +9839,23 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
try addDecor(g, gpa, x1 - gap, y0 + gap, x1 - b, y1 - gap, band, 1, track, win_w, win_h);
}
}
+ // The marks are the first row's alone, where its cell is blank (no
+ // mode glyph), centered in the button, in its ink from the region's
+ // state.
const x = grip.rect.x;
- for (0..grip.rect.h) |line| {
- const y = grip.rect.y + @as(u16, @intCast(line));
- if (x >= cols or y >= rows) continue;
- const cell = &cells[@as(usize, y) * cols + x];
- if (cell.default or cell.printableAscii() != ' ') continue;
- // The marks are in the button's ink, from the region's state.
- const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty));
- // The marks are the first row's alone, centered in the button.
- if (line != 0) continue;
- const center_x = @floor((button[0] + button[2]) / 2);
- const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, win_h, g.cell_h, g.tagline_height))) + @as(f32, @floatFromInt(g.tagline_height)) / 2;
- const half_w = @max(dp(1), @min(dp(3), @floor((button[2] - button[0] - 2 * dp(3)) / 2)));
- // The mode's two bars: a logical pixel thick, a pixel either
- // side of the middle.
- const bar = dp(1);
- try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, track, win_w, win_h);
- try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, track, win_w, win_h);
- }
+ const y = grip.rect.y;
+ if (x >= cols) continue;
+ const cell = &cells[@as(usize, y) * cols + x];
+ if (cell.default or cell.printableAscii() != ' ') continue;
+ const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty));
+ const center_x = @floor((button[0] + button[2]) / 2);
+ const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, win_h, g.cell_h, g.tagline_height))) + @as(f32, @floatFromInt(g.tagline_height)) / 2;
+ const half_w = @max(dp(1), @min(dp(3), @floor((button[2] - button[0] - 2 * dp(3)) / 2)));
+ // The mode's two bars: a logical pixel thick, a pixel either side of
+ // the middle.
+ const bar = dp(1);
+ try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, track, win_w, win_h);
}
}