summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 10:46:03 -0300
committerGabriel Schneider <[email protected]>2026-11-05 15:12:36 -0300
commit11204e1206f7f7ffeaa861c1a442a312e563d3ed (patch)
treef788736bf5b6a56694563b664b5db73bc54bff72
parentc9b9dad8469f5d654c31d688d7e2d93da8325f39 (diff)
downloadpardes-11204e1206f7f7ffeaa861c1a442a312e563d3ed.tar.gz
pardes-11204e1206f7f7ffeaa861c1a442a312e563d3ed.zip
effects out, the post chain: Crt, Bloom, Vignette, Grain, Shader and ShaderAnimation go with src/gui/Post.zig, src/ShaderBuild.zig (the run-time glslc spawn and its watched files), shaders/post/, post.vert, bloom-down and bloom-up and their prebuilt .spv, the window's scene texture and its post-chain-only redraw (level A), the disable_scene_effects tape site and Pardes.disableSceneEffects; EffectCode goes with src/effect_sources.zig, which only embedded the effects' sources (/virtual keeps src/); the corner-click test keeps its point without a chain, the window monkey loses its Bloom axis; macOS's post-processor (ScenePostprocessor.swift, crt.ci.metal, pardes_scene) is a change of its own
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
-rw-r--r--build.zig43
-rw-r--r--build/snap.zig2
-rw-r--r--docs/typ/builtins-gui.json7
-rw-r--r--docs/typ/builtins-tui.json1
-rw-r--r--docs/typ/reference.typ22
-rw-r--r--docs/typ/style.typ2
-rw-r--r--shaders/bloom-down.frag.glsl39
-rw-r--r--shaders/bloom-up.frag.glsl26
-rw-r--r--shaders/post.vert.glsl10
-rw-r--r--shaders/post/bloom.glsl40
-rw-r--r--shaders/post/crt.glsl85
-rw-r--r--shaders/post/grain.glsl32
-rw-r--r--shaders/post/prefix.glsl101
-rw-r--r--shaders/post/vignette.glsl38
-rw-r--r--shaders/prebuilt/bloom-down.frag.spvbin3876 -> 0 bytes
-rw-r--r--shaders/prebuilt/bloom-up.frag.spvbin3504 -> 0 bytes
-rw-r--r--shaders/prebuilt/post-bloom.frag.spvbin8500 -> 0 bytes
-rw-r--r--shaders/prebuilt/post-crt.frag.spvbin13092 -> 0 bytes
-rw-r--r--shaders/prebuilt/post-grain.frag.spvbin8236 -> 0 bytes
-rw-r--r--shaders/prebuilt/post-vignette.frag.spvbin8652 -> 0 bytes
-rw-r--r--shaders/prebuilt/post.vert.spvbin1208 -> 0 bytes
-rw-r--r--src/Output.zig23
-rw-r--r--src/ShaderBuild.zig427
-rw-r--r--src/builtins.zig27
-rw-r--r--src/config.zig229
-rw-r--r--src/effect_sources.zig98
-rw-r--r--src/exec.zig4
-rw-r--r--src/file_watch.zig13
-rw-r--r--src/fs.zig5
-rw-r--r--src/gui/Post.zig653
-rw-r--r--src/gui/gui.zig191
-rw-r--r--src/main.zig1
-rw-r--r--src/pardes.zig15
-rw-r--r--src/tape.zig2
-rw-r--r--test/behaviour/settings.zig8
-rw-r--r--test/output.zig53
-rw-r--r--test/process/window.zig19
37 files changed, 55 insertions, 2161 deletions
diff --git a/build.zig b/build.zig
index 60e848e5..2a408bbf 100644
--- a/build.zig
+++ b/build.zig
@@ -57,16 +57,6 @@ const gui_shaders = [_][]const u8{
"overlay.frag",
"image.vert",
"image.frag",
- "post.vert",
- // The bundled post passes: shaders/post/<name>.glsl behind the
- // Shadertoy prefix (shaderSource).
- "post-crt.frag",
- "post-bloom.frag",
- "post-vignette.frag",
- "post-grain.frag",
- // Bloom's steps below the frame (src/gui/Post.zig bloomChain).
- "bloom-down.frag",
- "bloom-up.frag",
};
pub fn build(b: *std.Build) void {
@@ -857,13 +847,6 @@ pub fn build(b: *std.Build) void {
mod.addOptions("doc_typ", doc_typ_opts);
mod.addOptions("pardes_config", if (also_gui and shell == .gui) gui_opts.? else opts);
mod.addOptions("pardes_isolation", if (isolated_mod == mod) iso_on else iso_off);
- if (shell == .gui) for (gui_shaders) |name| mod.addAnonymousImport(
- b.fmt("effect-source-{s}.glsl", .{name}),
- .{ .root_source_file = shaderSource(b, name) },
- );
- if (shell == .macos) mod.addAnonymousImport("effect-source-crt.ci.metal", .{
- .root_source_file = b.path("shaders/crt.ci.metal"),
- });
}
// docs/typ/builtins-<platform>.json: every builtin, from the registry and the Help
@@ -960,8 +943,6 @@ pub fn build(b: *std.Build) void {
gm.addAnonymousImport("AdwaitaMono-Regular.ttf", .{
.root_source_file = b.path("assets/AdwaitaMono-Regular.ttf"),
});
- // Put before a user's Shadertoy file when the gui compiles it.
- gm.addAnonymousImport("post-prefix.glsl", .{ .root_source_file = b.path("shaders/post/prefix.glsl") });
for (gui_shaders) |name| gm.addAnonymousImport(b.fmt("{s}.spv", .{name}), .{
.root_source_file = if (prebuilt_shaders)
b.path(b.fmt("shaders/prebuilt/{s}.spv", .{name}))
@@ -970,11 +951,6 @@ pub fn build(b: *std.Build) void {
});
}
- // A detached session compiles its attached GUIs' Shadertoy files
- // (ShaderBuild.zig), whichever shell it was built for.
- if (gui_shell_mod != root_mod)
- root_mod.addAnonymousImport("post-prefix.glsl", .{ .root_source_file = b.path("shaders/post/prefix.glsl") });
-
if (platform == .macos) {
const header = b.addTranslateC(.{
.root_source_file = b.path("src/macos/pardes.h"),
@@ -1896,25 +1872,12 @@ fn reindexed(b: *std.Build, archive: std.Build.LazyPath, index: usize) std.Build
return run.addOutputFileArg(b.fmt("{d}.a", .{index}));
}
-// glslc shaders/<name>.glsl -fshader-stage=<vertex|fragment> -o <name>.spv,
-// returned as a LazyPath for @embedFile. The stage is the name's own suffix.
-/// The GLSL a shader is compiled from: shaders/<name>.glsl, or for a bundled
-/// post pass (post-<name>.frag) shaders/post/<name>.glsl behind the Shadertoy
-/// prefix, the one the gui puts before a user's file at run time.
-fn shaderSource(b: *std.Build, name: []const u8) std.Build.LazyPath {
- if (!std.mem.startsWith(u8, name, "post-")) return b.path(b.fmt("shaders/{s}.glsl", .{name}));
- const joined = b.addSystemCommand(&.{"cat"});
- joined.addFileArg(b.path("shaders/post/prefix.glsl"));
- joined.addFileArg(b.path(b.fmt("shaders/post/{s}.glsl", .{name["post-".len .. name.len - ".frag".len]})));
- return joined.captureStdOut(.{});
-}
-
-/// The one glslc invocation every shader is compiled with, at build time here
-/// and at run time for a user's post pass (src/gui/Post.zig).
+/// glslc shaders/<name>.glsl -fshader-stage=<vertex|fragment> -o <name>.spv,
+/// returned as a LazyPath for @embedFile. The stage is the name's own suffix.
fn compileGlsl(b: *std.Build, name: []const u8) std.Build.LazyPath {
const stage = if (std.mem.endsWith(u8, name, ".vert")) "vertex" else "fragment";
const cmd = b.addSystemCommand(&.{ "glslc", b.fmt("-fshader-stage={s}", .{stage}) });
- cmd.addFileArg(shaderSource(b, name));
+ cmd.addFileArg(b.path(b.fmt("shaders/{s}.glsl", .{name})));
cmd.addArg("-o");
return cmd.addOutputFileArg(b.fmt("{s}.spv", .{name}));
}
diff --git a/build/snap.zig b/build/snap.zig
index 01316966..ac4e55c5 100644
--- a/build/snap.zig
+++ b/build/snap.zig
@@ -66,7 +66,7 @@ pub fn addTty(b: *std.Build, opts: struct {
run_process_test.has_side_effects = true;
b.step("process-test", "run the process tests: real sessions driven over their sockets (-- [filter])").dependOn(&run_process_test.step);
// The window's own, run in full when asked (test/process/window.zig):
- // the monkey over every Motion x Lift x Bloom, and the frames against
+ // the monkey over every Motion x Lift, and the frames against
// this machine's goldens (PARDES_GUI_GOLDEN=update rewrites them).
const monkey_gui_step = b.step("monkey-gui", "random input to the hidden window across the effect settings (-Dplatform=gui; PARDES_GUI_MONKEY_SEED, _STEPS)");
const gui_golden_step = b.step("gui-golden", "the hidden window's scenes against test/gui-goldens.txt, this machine's (-Dplatform=gui; PARDES_GUI_GOLDEN=update rewrites)");
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json
index e48dc0cd..e2e118c7 100644
--- a/docs/typ/builtins-gui.json
+++ b/docs/typ/builtins-gui.json
@@ -2,7 +2,6 @@
{"name": "Adopt", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Take in the shells of a session that died holding them, each as a terminal pane here: the pardes daemon kept their terminals open."},
{"name": "Ascii", "leader": "SPC t a", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "add the printable ASCII bitmaps to the matcher's glyph set"},
{"name": "Back", "leader": "SPC j o", "also": ["C-o"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Ctrl-o: one step back into the history."},
- {"name": "Bloom", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off, 0-3", "doc": "The brightest ink glows a little: a level, 0 (off) through 3."},
{"name": "Callees", "leader": "SPC l C", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the functions the function under the cursor calls."},
{"name": "Callers", "leader": "SPC l c", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the callers of the function under the cursor."},
{"name": "Callstack", "leader": "SPC l b", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Show outermost callers first, with signatures and call sites (gc)."},
@@ -18,7 +17,6 @@
{"name": "Collapse", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Fold a pane to its tag, or restore its share of the column."},
{"name": "Colors", "leader": "SPC t c", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Syntax colours in text panes, on or off."},
{"name": "Config", "leader": "SPC f c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the startup file, `init`, in a pane: its pane when it is open, else the file, else a pane of that name for Save to make it and its directory."},
- {"name": "Crt", "leader": "SPC t r", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off, 0-3", "doc": "The bundled CRT post pass over the window, on or off."},
{"name": "CursorBlink", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "The cursor blinks, solid while typing, on or off."},
{"name": "Debug", "leader": "SPC t d", "also": ["topbar"], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A small box of frame statistics at the top right, on or off."},
{"name": "Def", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Go to the definition of the symbol under the cursor; with an argument (a 2-1 chord's selection), of that symbol, where it is nearest."},
@@ -35,7 +33,6 @@
{"name": "DumpDir", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The directory Dump writes to and a relative Restore reads from; bare, the default."},
{"name": "DumpThemes", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Write the bundled themes into the config directory's themes, to edit."},
{"name": "Edit", "leader": null, "also": [], "arg": true, "scope": "both", "setting": false, "choices": null, "doc": "acme's Edit: sam's command language over the open text panes, from a tag, a pane ctl or exec, starting in the pane's body."},
- {"name": "EffectCode", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Open the source of a panel transition or post shader, by name."},
{"name": "Exec", "leader": null, "also": ["tab", "middle-click"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Execute its argument as a middle click on it would, a builtin or a shell command."},
{"name": "Exit", "leader": "SPC q", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Quit the editor, refusing once while a pane holds unsaved text: an Exit with nothing edited since discards it."},
{"name": "Filter", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Recolour a terminal's or a +Pager's program colours to the theme, or show them as sent, flipping between them."},
@@ -45,7 +42,6 @@
{"name": "Fonts", "leader": "SPC t f", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the fonts in a pane, each a word to click."},
{"name": "Forward", "leader": "SPC j i", "also": ["C-i"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Ctrl-i: one step forward again, up to wherever Back started."},
{"name": "Get", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Get: the pane's file read again, its unsaved edits refused once as Del refuses them."},
- {"name": "Grain", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off, 0-3", "doc": "The page takes a fine, still grain, like paper: a level, 0 (off) through 3."},
{"name": "Grep", "leader": "SPC f g", "also": ["topbar"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Find's sibling: Find matches file NAMES under this pane's directory, Grep matches the LINES of those files, on the disk engine's worker."},
{"name": "GripWidth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The grip and scrollbar width, as a percent of the theme's rail."},
{"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the help: every key and every builtin."},
@@ -121,8 +117,6 @@
{"name": "SearchRows", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The rows a query pane is born with under its line 1, 1 through 100; default 8. It never resizes itself."},
{"name": "SelectRefs", "leader": "SPC l h", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Select every reference to the symbol under the cursor."},
{"name": "SelectionGlow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A soft halo of the selection's colour round it in the body, on or off."},
- {"name": "Shader", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "A Shadertoy file into the post chain, or out of it, compiled again when saved; off empties the chain."},
- {"name": "ShaderAnimation", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "off, on, always", "doc": "When the post chain animates on its own: off, on (while focused) or always."},
{"name": "Shell", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The shell new terminals run; bare, $SHELL if it is executable, else /bin/sh."},
{"name": "Subtypes", "leader": "SPC l T", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the subtypes of the type under the cursor."},
{"name": "Supertypes", "leader": "SPC l t", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the supertypes of the type under the cursor."},
@@ -147,7 +141,6 @@
{"name": "Up", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane above, and from a column's top pane to its tag."},
{"name": "Upgrade", "leader": "SPC s U", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Move this session onto the pardes installed since it started, in place: its text, undo, views, terminals with their running shells, and its terminals and windows come along."},
{"name": "Verbose", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A builtin says its own name on the message row as it runs, on or off."},
- {"name": "Vignette", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off, 0-3", "doc": "The window's corners fall into shade: a level, 0 (off) through 3."},
{"name": "Window", "leader": "SPC w", "also": ["C-w"], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Window mode: h/j/k/l move an outline between the panes; Enter or Esc focuses the outlined pane, `:` its tag, the letter shown on a pane that one; d is Del on it (then k or j between two), c Collapse."},
{"name": "WindowOpacity", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The window's opacity, a percentage."},
{"name": "Wrap", "leader": "SPC t w", "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "Long lines wrap onto the next row, on or off."},
diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json
index 93ae6a8f..8fdbec16 100644
--- a/docs/typ/builtins-tui.json
+++ b/docs/typ/builtins-tui.json
@@ -32,7 +32,6 @@
{"name": "DumpDir", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The directory Dump writes to and a relative Restore reads from; bare, the default."},
{"name": "DumpThemes", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Write the bundled themes into the config directory's themes, to edit."},
{"name": "Edit", "leader": null, "also": [], "arg": true, "scope": "both", "setting": false, "choices": null, "doc": "acme's Edit: sam's command language over the open text panes, from a tag, a pane ctl or exec, starting in the pane's body."},
- {"name": "EffectCode", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Open the source of a panel transition or post shader, by name."},
{"name": "Exec", "leader": null, "also": ["tab", "middle-click"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Execute its argument as a middle click on it would, a builtin or a shell command."},
{"name": "Exit", "leader": "SPC q", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Quit the editor, refusing once while a pane holds unsaved text: an Exit with nothing edited since discards it."},
{"name": "Filter", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Recolour a terminal's or a +Pager's program colours to the theme, or show them as sent, flipping between them."},
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ
index de886c87..84eeff47 100644
--- a/docs/typ/reference.typ
+++ b/docs/typ/reference.typ
@@ -373,9 +373,8 @@ reads changes nothing.
Writes take settings and session builtins (`scope = .session` in
`src/builtins.zig`), acting at the pane with the keyboard:
-- A setting written bare steps to its next value (a switch flips; so does
- #word("Crt")). A value it does not
- take is `bad value in control message; ...` naming what it takes;
+- A setting written bare steps to its next value (a switch flips). A
+ value it does not take is `bad value in control message; ...` naming what it takes;
#file("/commands") lists them. A setting the frontend cannot show is
refused (`Lift is GUI-only, invalid here`).
- #word("Newcol") makes an empty column right of the keyboard's, halving
@@ -420,9 +419,8 @@ runs fails with the editor's words (`Mount: already mounted`, `Save /root/x: acc
== Settings <settings>
-A setting that chooses among words (`on`/`off` switches, #word("Crt"), #word("Bloom"),
-#word("Vignette"), #word("Grain"), #word("Lift"), #word("Motion"),
-#word("ShaderAnimation")) steps to its next value when given bare, as its
+A setting that chooses among words (`on`/`off` switches, #word("Lift"),
+#word("Motion")) steps to its next value when given bare, as its
word clicked in a tag does. The same lines go in the startup file
(#doc("config")).
@@ -468,11 +466,7 @@ turning it off: #word("PanelSlide"), #word("PanelZoom"),
#word("PanelDissolve"), #word("PanelAscii"), #word("PanelVertical"),
#word("PanelEdges"), #word("PanelFall"), #word("PanelWave"),
#word("PanelCurtain"), #word("PanelScramble"), #word("PanelType"); all
-start off, and the web shell has none. Scene passes (the SDL window), each at a level 0-3 (`on` is 2), all
-off: #word("Crt"), #word("Bloom"), #word("Vignette"), #word("Grain").
-#word("Shader") `<file.glsl>` adds a Shadertoy file written for ghostty to the
-chain (#word("Shader") `off` removes it; it recompiles when saved);
-#word("ShaderAnimation") `off|on|always` says when the chain animates by itself. The
+start off, and the web shell has none. The
focused pane can stand off the page: #word("Lift") `shadow|rim|auto|off`,
#word("InactiveDim") `<percent>`, #word("Motion") `off|crisp|smooth|bouncy|playful` (default
`smooth`), #word("SelectionGlow"), #word("HoverGlow"), #word("Occlusion"),
@@ -481,8 +475,6 @@ focused pane can stand off the page: #word("Lift") `shadow|rim|auto|off`,
the GUI's; #word("InactiveDim") works everywhere, and #word("JumpTrail"),
#word("ChipShadow") and #word("ThumbFlash") are the terminal's. No effect
may lower the contrast of text, the selection or a focus indicator.
-#word("EffectCode") `<effect>` lists that effect's sources under `/virtual` when the
-build embeds them.
Resting the pointer on text for about 32 ms (`look_preview_delay_frames`,
2 frames, in `src/config.zig`; `null` turns it off) tints what #word("Look") would take, with no other effect. A terminal's or a `+Pager`'s
@@ -969,9 +961,7 @@ at 200, ending in `…`. Control characters become spaces.
zero; create, remove, rename and mode changes are refused as not
permitted (`permission denied`, EACCES through a mount); ownership is
synthetic. Linux v9fs's truncation `mtime` hint is accepted and dropped.
-- #file("/src/") (and #file("/shaders") on GUI builds) with
- `-Dembed-sources=true`; #word("EffectCode") `<effect>` lists an effect's files
- under `/virtual`.
+- #file("/src/") with `-Dembed-sources=true`.
= The pardes command <command-line>
diff --git a/docs/typ/style.typ b/docs/typ/style.typ
index e2eafc87..2f777892 100644
--- a/docs/typ/style.typ
+++ b/docs/typ/style.typ
@@ -369,7 +369,7 @@
#let everyday = ("Look", "Exec", "Save", "Undo", "Redo", "New", "Newcol", "Del", "Delcol",
"Term", "Kill", "Find", "Grep", "Recent", "Dump", "Restore", "Exit", "Help", "Tutor", "Themes", "Config")
/// Debugging and developer words, last whatever their leader path.
-#let internals = ("Debug", "EffectCode", "Lspwhy", "Messages", "DumpConfig", "DumpThemes")
+#let internals = ("Debug", "Lspwhy", "Messages", "DumpConfig", "DumpThemes")
/// The glossary's groups, in order: by the leader path's first key, the
/// way Help groups them, then settings, the words with no path, internals.
diff --git a/shaders/bloom-down.frag.glsl b/shaders/bloom-down.frag.glsl
deleted file mode 100644
index 3465926d..00000000
--- a/shaders/bloom-down.frag.glsl
+++ /dev/null
@@ -1,39 +0,0 @@
-#version 450
-
-// Bloom, down (docs/effects.md G4): one step of a dual Kawase filter, a
-// source half as big again sampled at five points, the first step over the
-// frame through a bright pass in linear light. Written to a float target.
-
-layout(set = 2, binding = 0) uniform sampler2D source;
-layout(std140, set = 3, binding = 0) uniform BloomStep {
- // xy: a source texel; zw: a target texel.
- vec4 texels;
- // x: the bright pass's threshold on a channel's linear peak (above the
- // page's own), 0 for none (a later step); y: its soft knee.
- vec4 pass;
-} u;
-
-layout(location = 0) out vec4 o_col;
-
-vec3 toLinear(vec3 c) {
- return mix(pow((c + 0.055) / 1.055, vec3(2.4)), c / 12.92, lessThanEqual(c, vec3(0.04045)));
-}
-
-vec3 tap(vec2 uv) {
- vec3 c = texture(source, uv).rgb;
- if (u.pass.x <= 0.0) return c;
- c = toLinear(c);
- float peak = max(c.r, max(c.g, c.b));
- return c * smoothstep(u.pass.x, u.pass.x + u.pass.y, peak);
-}
-
-void main() {
- vec2 uv = gl_FragCoord.xy * u.texels.zw;
- vec2 h = 0.5 * u.texels.xy;
- vec3 sum = tap(uv) * 4.0;
- sum += tap(uv - h);
- sum += tap(uv + h);
- sum += tap(uv + vec2(h.x, -h.y));
- sum += tap(uv - vec2(h.x, -h.y));
- o_col = vec4(sum / 8.0, 1.0);
-}
diff --git a/shaders/bloom-up.frag.glsl b/shaders/bloom-up.frag.glsl
deleted file mode 100644
index 368076ed..00000000
--- a/shaders/bloom-up.frag.glsl
+++ /dev/null
@@ -1,26 +0,0 @@
-#version 450
-
-// Bloom, up (docs/effects.md G4): one step of a dual Kawase filter back up,
-// a tent of eight points over the smaller level. Float target.
-
-layout(set = 2, binding = 0) uniform sampler2D source;
-layout(std140, set = 3, binding = 0) uniform BloomStep {
- vec4 texels;
- vec4 pass;
-} u;
-
-layout(location = 0) out vec4 o_col;
-
-void main() {
- vec2 uv = gl_FragCoord.xy * u.texels.zw;
- vec2 h = 0.5 * u.texels.xy;
- vec3 sum = texture(source, uv + vec2(-2.0 * h.x, 0.0)).rgb;
- sum += texture(source, uv + vec2(-h.x, h.y)).rgb * 2.0;
- sum += texture(source, uv + vec2(0.0, 2.0 * h.y)).rgb;
- sum += texture(source, uv + vec2(h.x, h.y)).rgb * 2.0;
- sum += texture(source, uv + vec2(2.0 * h.x, 0.0)).rgb;
- sum += texture(source, uv + vec2(h.x, -h.y)).rgb * 2.0;
- sum += texture(source, uv + vec2(0.0, -2.0 * h.y)).rgb;
- sum += texture(source, uv + vec2(-h.x, -h.y)).rgb * 2.0;
- o_col = vec4(sum / 12.0, 1.0);
-}
diff --git a/shaders/post.vert.glsl b/shaders/post.vert.glsl
deleted file mode 100644
index 86739a65..00000000
--- a/shaders/post.vert.glsl
+++ /dev/null
@@ -1,10 +0,0 @@
-#version 450
-
-// A post pass (docs/render-pipeline.md §6): one fullscreen triangle from
-// gl_VertexIndex, no vertex buffer. The Shadertoy fragment shader works from
-// gl_FragCoord, y down, as its fragCoord.
-
-void main() {
- vec2 p = vec2(float((gl_VertexIndex << 1) & 2), float(gl_VertexIndex & 2));
- gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
-}
diff --git a/shaders/post/bloom.glsl b/shaders/post/bloom.glsl
deleted file mode 100644
index d54a0aac..00000000
--- a/shaders/post/bloom.glsl
+++ /dev/null
@@ -1,40 +0,0 @@
-// Bloom: the brightest ink glows, a little. The glow itself is made by the
-// shell at half resolution and below (bloom-down, bloom-up: a dual Kawase
-// filter over a bright pass, in linear light) and arrives here in
-// pardesBloom; this pass adds it to the frame. Only true highlights pass
-// the threshold, and the strength stays in §8.2's budget (at most 5%) and
-// under pardesCap, so no text or selection loses contrast below its own or
-// 4.5. Tags, grips, notices and the cursor are left alone (pardesSpare).
-// It is a Shadertoy file: pardes puts its prefix before it.
-
-layout(set = 2, binding = 1) uniform sampler2D pardesBloom;
-
-float strength() { return min(pardesByLevel(0.02, 0.035, 0.05), pardesCap); }
-
-vec3 toLinear(vec3 c) {
- return mix(pow((c + 0.055) / 1.055, vec3(2.4)), c / 12.92, lessThanEqual(c, vec3(0.04045)));
-}
-
-vec3 toSrgb(vec3 c) {
- c = max(c, vec3(0.0));
- return mix(1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, c * 12.92, lessThanEqual(c, vec3(0.0031308)));
-}
-
-float ign(vec2 p) {
- return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
-}
-
-void mainImage(out vec4 fragColor, in vec2 fragCoord) {
- vec2 uv = fragCoord / iResolution.xy;
- vec4 frame = texture(iChannel0, uv);
- if (pardesSpared(fragCoord)) {
- fragColor = frame;
- return;
- }
- vec3 glow = texture(pardesBloom, uv).rgb;
- vec3 col = toLinear(frame.rgb) + glow * strength();
- vec3 srgb = toSrgb(col);
- // Dithered: a glow's long falloff never bands.
- srgb += (ign(fragCoord) - 0.5) / 255.0 * step(1e-4, dot(glow, vec3(1.0)));
- fragColor = vec4(clamp(srgb, 0.0, 1.0), frame.a);
-}
diff --git a/shaders/post/crt.glsl b/shaders/post/crt.glsl
deleted file mode 100644
index 970d61ee..00000000
--- a/shaders/post/crt.glsl
+++ /dev/null
@@ -1,85 +0,0 @@
-// Crt: a slot-mask tube's light, with nothing that moves a pixel. There is
-// no barrel: every click lands where it is drawn, rails and grips at the
-// window's edges included. What is left is light: a beam profile for the
-// scanlines, an aperture mask, a soft bloom of the brightest ink, a faint
-// vignette and the hum of a live tube. Everything is worked out in linear
-// light and dithered back into 8 bits, so the vignette never bands. It is a
-// Shadertoy file: pardes puts its prefix before it (shaders/post/prefix.glsl).
-
-const float TAU = 6.28318530718;
-// Level 3 glows wider and from dimmer ink.
-float bloomRadiusPx() { return pardesByLevel(1.75, 1.75, 3.0); }
-float bloomThreshold() { return pardesByLevel(0.6, 0.6, 0.3); } // linear-light channel peak
-const float BLOOM_SOFTNESS = 0.25;
-const float SCAN_PERIOD_PX = 3.0;
-const float MASK_PERIOD_PX = 3.0;
-const float HUM_HZ = 0.11;
-
-// Each strength at levels 1, 2 and 3 (`Crt 1`..`Crt 3`): 2 is the default,
-// 3 as strong as the old barrel CRT looked.
-float chromaPx() { return pardesByLevel(0.2, 0.35, 2.2); } // red and blue apart, at the corners
-float bloomStrength() { return pardesByLevel(0.03, 0.05, 0.3); }
-float scanStrength() { return pardesByLevel(0.035, 0.07, 0.42); }
-float maskStrength() { return pardesByLevel(0.01, 0.018, 0.12); }
-float vignetteStrength() { return pardesByLevel(0.06, 0.12, 0.42); } // at the far corners only
-float humStrength() { return pardesByLevel(0.002, 0.004, 0.012); }
-float exposure() { return pardesByLevel(1.008, 1.015, 1.1); }
-
-vec3 toLinear(vec3 c) {
- return mix(pow((c + 0.055) / 1.055, vec3(2.4)), c / 12.92, lessThanEqual(c, vec3(0.04045)));
-}
-
-vec3 toSrgb(vec3 c) {
- c = max(c, vec3(0.0));
- return mix(1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, c * 12.92, lessThanEqual(c, vec3(0.0031308)));
-}
-
-vec3 scene(vec2 uv) {
- return toLinear(texture(iChannel0, uv).rgb);
-}
-
-vec3 brightPass(vec2 uv) {
- vec3 c = scene(uv);
- float peak = max(c.r, max(c.g, c.b));
- return c * smoothstep(bloomThreshold(), bloomThreshold() + BLOOM_SOFTNESS, peak);
-}
-
-// Interleaved gradient noise: a dither with no visible pattern.
-float ign(vec2 p) {
- return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
-}
-
-void mainImage(out vec4 fragColor, in vec2 fragCoord) {
- vec2 size = iResolution.xy;
- vec2 texel = 1.0 / size;
- vec2 uv = fragCoord / size;
- vec2 cc = uv * 2.0 - 1.0;
- float r2 = dot(cc, cc);
-
- // The beam converges least at the corners: red and blue drift apart
- // there, by a third of a pixel.
- vec2 chroma = cc * (chromaPx() * r2 * 0.5) * texel;
- vec3 col = vec3(scene(uv + chroma).r, scene(uv).g, scene(uv - chroma).b);
-
- vec2 b = texel * bloomRadiusPx();
- vec3 bloom = brightPass(uv + vec2(b.x, 0.0)) + brightPass(uv - vec2(b.x, 0.0)) +
- brightPass(uv + vec2(0.0, b.y)) + brightPass(uv - vec2(0.0, b.y));
- col += bloom * (0.25 * bloomStrength());
-
- // A beam is brightest on its line and falls off between lines; the
- // mask is three phosphor stripes a triad. Both average to one, so the
- // theme keeps its brightness.
- // Periods in logical pixels: the same look at any density.
- float density = max(1.0, pardesScale);
- float line = 0.5 + 0.5 * cos(fragCoord.y * TAU / (SCAN_PERIOD_PX * density));
- col *= 1.0 - scanStrength() * (line * line - 0.375) / 0.625;
- col *= 1.0 + maskStrength() * cos(fragCoord.x * TAU / (MASK_PERIOD_PX * density) + vec3(0.0, TAU / 3.0, 2.0 * TAU / 3.0));
-
- float vignette = 1.0 - vignetteStrength() * pow(clamp(r2 * 0.5, 0.0, 1.0), 1.6);
- float hum = 1.0 + humStrength() * sin((uv.y * 1.35 - iTime * HUM_HZ) * TAU);
- col *= vignette * hum * exposure();
-
- vec3 srgb = toSrgb(col);
- srgb += (ign(fragCoord + float(iFrame % 64) * vec2(5.588238, 5.588238)) - 0.5) / 255.0;
- fragColor = vec4(clamp(srgb, 0.0, 1.0), texture(iChannel0, uv).a);
-}
diff --git a/shaders/post/grain.glsl b/shaders/post/grain.glsl
deleted file mode 100644
index 61c51492..00000000
--- a/shaders/post/grain.glsl
+++ /dev/null
@@ -1,32 +0,0 @@
-// Grain: the page's own ground takes a fine, still grain, like paper. Only
-// pixels of the page's colour (iBackgroundColor) are grained: no glyph, no
-// selection, no tag or rule, and nothing in pardesSpare. The grain averages
-// to the page, is a logical pixel big (pardesScale), and never moves, so it
-// costs no frames. At most 1.5, 3 and 5 of 255 at levels 1 to 3, and never
-// more than pardesCap, which keeps the text on it at its own contrast or 4.5.
-// It is a Shadertoy file: pardes puts its prefix before it.
-
-float amplitude() { return min(pardesByLevel(1.5, 3.0, 5.0) / 255.0, pardesCap); }
-
-// An integer hash of the grain cell: white, with no pattern to see.
-float hash(uvec2 p) {
- uint h = p.x * 1664525u + p.y * 1013904223u;
- h ^= h >> 16;
- h *= 2246822519u;
- h ^= h >> 13;
- h *= 3266489917u;
- h ^= h >> 16;
- return float(h) / 4294967295.0;
-}
-
-void mainImage(out vec4 fragColor, in vec2 fragCoord) {
- vec2 uv = fragCoord / iResolution.xy;
- vec4 frame = texture(iChannel0, uv);
- fragColor = frame;
- vec3 page = iBackgroundColor.rgb;
- if (any(greaterThan(abs(frame.rgb - page), vec3(0.75 / 255.0))) || pardesSpared(fragCoord)) return;
- uvec2 cell = uvec2(fragCoord / max(1.0, pardesScale));
- // Two hashes summed: a triangular spread, softer than a flat one.
- float n = hash(cell) + hash(cell + uvec2(7919u, 104729u)) - 1.0;
- fragColor = vec4(clamp(page + n * amplitude(), 0.0, 1.0), frame.a);
-}
diff --git a/shaders/post/prefix.glsl b/shaders/post/prefix.glsl
deleted file mode 100644
index 44c5e0f8..00000000
--- a/shaders/post/prefix.glsl
+++ /dev/null
@@ -1,101 +0,0 @@
-#version 450
-// pardes's Shadertoy prefix (docs/render-pipeline.md §6), put before every
-// post pass: a bundled one in shaders/post/ at build time, a user's file at
-// run time. The uniform names, types and std140 order are ghostty 1.3.2's
-// (src/renderer/shaders/shadertoy_prefix.glsl), so a shader written for
-// ghostty runs here; only the bindings are SDL GPU's (a fragment shader's
-// textures in set 2, its uniform blocks in set 3). Y is down everywhere, as
-// on ghostty's Metal renderer: fragCoord, iChannel0's uv and the cursor
-// rectangles share one top-left space, and iCurrentCursor is (left x,
-// BOTTOM-edge y, width, height) in framebuffer pixels.
-
-layout(set = 3, binding = 0, std140) uniform Globals {
- uniform vec3 iResolution;
- uniform float iTime;
- uniform float iTimeDelta;
- uniform float iFrameRate;
- uniform int iFrame;
- uniform float iChannelTime[4];
- uniform vec3 iChannelResolution[4];
- uniform vec4 iMouse;
- uniform vec4 iDate;
- uniform float iSampleRate;
- uniform vec4 iCurrentCursor;
- uniform vec4 iPreviousCursor;
- uniform vec4 iCurrentCursorColor;
- uniform vec4 iPreviousCursorColor;
- uniform int iCurrentCursorStyle;
- uniform int iPreviousCursorStyle;
- uniform int iCursorVisible;
- uniform float iTimeCursorChange;
- uniform float iTimeFocus;
- uniform int iFocus;
-};
-// ghostty's one block, cut in three: SDL GPU binds at most 4 KiB of a
-// uniform block (Vulkan), and the palette alone is 4 KiB. The names and
-// their order are ghostty's; each block is a slice of the same memory.
-layout(set = 3, binding = 1, std140) uniform Palette {
- uniform vec3 iPalette[256];
-};
-layout(set = 3, binding = 2, std140) uniform Colors {
- uniform vec3 iBackgroundColor;
- uniform vec3 iForegroundColor;
- uniform vec3 iCursorColor;
- uniform vec3 iCursorText;
- uniform vec3 iSelectionForegroundColor;
- uniform vec3 iSelectionBackgroundColor;
-};
-
-// pardes's own: pardesOpaque is 1 when the window is opaque, so a pass
-// cannot punch holes in it through its alpha; pardesLevel is a bundled
-// pass's strength, 1 to 3 (`Crt 3`), and 0 for a user's file; pardesScale
-// is the display's density (2 on a 2x screen), for a pass whose pattern is
-// in logical pixels. iResolution, fragCoord and iMouse stay in the display's
-// pixels, as ghostty's do. pardesCap is the most a bundled pass may do on
-// this theme and still leave its text, and its selection's, at their own
-// contrast or 4.5 (docs/effects.md); pardesSpare holds pardesSpareCount
-// rectangles (x0, y0, x1, y1 in fragCoord's pixels) a bundled pass leaves
-// alone: every tag, grip and notice, and the cursor, so no pass ever touches
-// a focus indicator.
-layout(set = 3, binding = 3, std140) uniform PardesPost {
- float pardesOpaque;
- float pardesLevel;
- float pardesScale;
- float pardesCap;
- float pardesSpareCount;
- vec4 pardesSpare[32];
-};
-
-bool pardesSpared(vec2 p) {
- for (int i = 0; i < int(pardesSpareCount); i++) {
- vec4 r = pardesSpare[i];
- if (p.x >= r.x && p.y >= r.y && p.x < r.z && p.y < r.w) return true;
- }
- return false;
-}
-
-// A bundled pass's constant at levels 1, 2 and 3.
-float pardesByLevel(float one, float two, float three) {
- return pardesLevel < 1.5 ? one : (pardesLevel < 2.5 ? two : three);
-}
-
-#define CURSORSTYLE_BLOCK 0
-#define CURSORSTYLE_BLOCK_HOLLOW 1
-#define CURSORSTYLE_BAR 2
-#define CURSORSTYLE_UNDERLINE 3
-#define CURSORSTYLE_LOCK 4
-
-layout(set = 2, binding = 0) uniform sampler2D iChannel0;
-
-layout(location = 0) out vec4 _fragColor;
-
-#define texture2D texture
-
-void mainImage(out vec4 fragColor, in vec2 fragCoord);
-void main() {
- mainImage(_fragColor, gl_FragCoord.xy);
- if (pardesOpaque > 0.5) _fragColor.a = 1.0;
-}
-
-// The shader's own lines count from 1, so glslc's errors name them.
-#line 1
diff --git a/shaders/post/vignette.glsl b/shaders/post/vignette.glsl
deleted file mode 100644
index 30dc2e0f..00000000
--- a/shaders/post/vignette.glsl
+++ /dev/null
@@ -1,38 +0,0 @@
-// Vignette: the window's corners fall a little into shade, in linear light,
-// so the eye settles on the middle. Round, whatever the window's shape;
-// nothing within half the way to a corner is touched. At most 28% at the
-// far corners (level 3), and never more than pardesCap, so text and its
-// selection keep their own contrast or 4.5. Tags, grips, notices and the
-// cursor are left alone (pardesSpare): the focus indicators never darken.
-// It is a Shadertoy file: pardes puts its prefix before it.
-
-float strength() { return min(pardesByLevel(0.10, 0.18, 0.28), pardesCap); }
-
-vec3 toLinear(vec3 c) {
- return mix(pow((c + 0.055) / 1.055, vec3(2.4)), c / 12.92, lessThanEqual(c, vec3(0.04045)));
-}
-
-vec3 toSrgb(vec3 c) {
- c = max(c, vec3(0.0));
- return mix(1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, c * 12.92, lessThanEqual(c, vec3(0.0031308)));
-}
-
-float ign(vec2 p) {
- return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
-}
-
-void mainImage(out vec4 fragColor, in vec2 fragCoord) {
- vec2 uv = fragCoord / iResolution.xy;
- vec4 frame = texture(iChannel0, uv);
- if (pardesSpared(fragCoord)) {
- fragColor = frame;
- return;
- }
- // 0 at the middle, 1 at a corner, on a circle's measure.
- vec2 half_size = 0.5 * iResolution.xy;
- float r = length(fragCoord - half_size) / length(half_size);
- float shade = strength() * pow(smoothstep(0.5, 1.0, r), 1.5);
- vec3 srgb = toSrgb(toLinear(frame.rgb) * (1.0 - shade));
- srgb += (ign(fragCoord) - 0.5) / 255.0 * step(1e-4, shade);
- fragColor = vec4(clamp(srgb, 0.0, 1.0), frame.a);
-}
diff --git a/shaders/prebuilt/bloom-down.frag.spv b/shaders/prebuilt/bloom-down.frag.spv
deleted file mode 100644
index 5ca327fe..00000000
--- a/shaders/prebuilt/bloom-down.frag.spv
+++ /dev/null
Binary files differ
diff --git a/shaders/prebuilt/bloom-up.frag.spv b/shaders/prebuilt/bloom-up.frag.spv
deleted file mode 100644
index b2c64b80..00000000
--- a/shaders/prebuilt/bloom-up.frag.spv
+++ /dev/null
Binary files differ
diff --git a/shaders/prebuilt/post-bloom.frag.spv b/shaders/prebuilt/post-bloom.frag.spv
deleted file mode 100644
index 7b71dbdd..00000000
--- a/shaders/prebuilt/post-bloom.frag.spv
+++ /dev/null
Binary files differ
diff --git a/shaders/prebuilt/post-crt.frag.spv b/shaders/prebuilt/post-crt.frag.spv
deleted file mode 100644
index fe2c3edb..00000000
--- a/shaders/prebuilt/post-crt.frag.spv
+++ /dev/null
Binary files differ
diff --git a/shaders/prebuilt/post-grain.frag.spv b/shaders/prebuilt/post-grain.frag.spv
deleted file mode 100644
index e4c893af..00000000
--- a/shaders/prebuilt/post-grain.frag.spv
+++ /dev/null
Binary files differ
diff --git a/shaders/prebuilt/post-vignette.frag.spv b/shaders/prebuilt/post-vignette.frag.spv
deleted file mode 100644
index 4dfb6125..00000000
--- a/shaders/prebuilt/post-vignette.frag.spv
+++ /dev/null
Binary files differ
diff --git a/shaders/prebuilt/post.vert.spv b/shaders/prebuilt/post.vert.spv
deleted file mode 100644
index 8a75ebb3..00000000
--- a/shaders/prebuilt/post.vert.spv
+++ /dev/null
Binary files differ
diff --git a/src/Output.zig b/src/Output.zig
index 5a774d33..3c04aff8 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -9,7 +9,6 @@ const Pardes = pardes.Pardes;
const modal = @import("modal.zig");
const limits = @import("memory.zig").limits;
const builtins = @import("builtins.zig");
-const effect_sources = @import("effect_sources.zig");
const build_options = @import("pardes_config");
const lsp = @import("lsp/lsp.zig");
const look = @import("look.zig");
@@ -1022,28 +1021,6 @@ pub fn openChangelog(p: *Pardes, id: usize) !void {
return openRead(p, id, .{ .cmd = .Changelog }, "", content);
}
-pub fn openEffectCode(p: *Pardes, id: usize, argument: []const u8) !void {
- const name = std.mem.trim(u8, argument, " \t\r\n");
- const setting = config.Runtime.find(name) orelse return error.UnknownEffect;
- switch (setting.action) {
- .transition, .scene => {},
- else => return error.NotAnEffect,
- }
- if (!setting.enabled(builtins.viewCapabilities(p))) return error.EffectUnavailable;
- // Without -Dembed-sources the paths would name nothing this build can open.
- if (!limits.embedded_sources) return error.EffectUnavailable;
- const paths = effect_sources.forSetting(setting) orelse
- return error.EffectUnavailable;
-
- var out: std.Io.Writer.Allocating = .init(p.gpa);
- errdefer out.deinit();
- try out.writer.print("EffectCode {s} ({s})\n", .{ setting.word, @tagName(effect_sources.backend) });
- try out.writer.writeByte('\n');
- for (paths) |path| try out.writer.print("/virtual/{s}\n", .{path});
- const content = try out.toOwnedSlice();
- return openRead(p, id, .{ .cmd = .EffectCode }, setting.word, content);
-}
-
pub fn openErrors(p: *Pardes, id: usize, content: []u8) !void {
return openRead(p, id, .errors, "", content);
}
diff --git a/src/ShaderBuild.zig b/src/ShaderBuild.zig
deleted file mode 100644
index 74ec6826..00000000
--- a/src/ShaderBuild.zig
+++ /dev/null
@@ -1,427 +0,0 @@
-//! The post chain's Shadertoy files as SPIR-V (docs/render-pipeline.md §6),
-//! 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
-//! chain and again whenever a save changes its bytes: the files' directories
-//! are watched (file_watch.watchShaders) and a change there has every file
-//! read and hashed, an unchanged one compiling nothing. A compile that fails
-//! keeps the last good SPIR-V and is said once, and glslc missing is said
-//! once for good.
-const std = @import("std");
-const libc = std.c;
-const pardes = @import("pardes.zig");
-const file_watch = @import("file_watch.zig");
-
-const Build = @This();
-const Chain = pardes.config.Runtime.Post;
-const Scene = pardes.config.Runtime.Scene;
-pub const max = Chain.max;
-
-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 storage
-/// until its next change.
-pub const Pass = struct {
- scene: ?Scene = null,
- level: u8 = 0,
- path: []const u8 = &.{},
- spirv: []const u8 = &.{},
- revision: u32 = 0,
- /// It moves on its own (reads the clock or the frame count), so the
- /// chain redraws while idle; a still pass draws only with a new frame.
- animated: bool = false,
-};
-
-/// The bundled passes that move on their own: the CRT's hum and dither.
-pub fn sceneAnimated(scene: Scene) bool {
- return scene == .crt;
-}
-
-/// Whether a Shadertoy source moves on its own: it reads the time
-/// (iTime, iTimeDelta and the times of a cursor move or a focus change),
-/// the frame count or the date. A mention in a comment counts too.
-pub fn readsTime(source: []const u8) bool {
- for ([_][]const u8{ "iTime", "iFrame", "iDate" }) |name| if (std.mem.indexOf(u8, source, name) != null) return true;
- return false;
-}
-
-/// Who to wake when a compile is done: the host's loop.
-pub const Wake = ?*const fn (?*anyopaque) void;
-
-const File = struct {
- path: []u8 = &.{},
- /// The hash of the source last compiled, good or not: the same bytes
- /// saved again compile nothing and say nothing twice.
- source: ?u64 = null,
- spirv: []u8 = &.{},
- revision: u32 = 0,
- animated: bool = false,
- /// Wants a compile: new to the chain, or its directory changed.
- stale: bool = true,
-};
-
-const Result = union(enum) {
- none,
- unchanged,
- missing,
- failed: struct { text: []u8, source: u64 },
- spirv: struct { bytes: []u8, source: u64, animated: bool },
-};
-
-/// One compile of the stale files, a task of its own: `deinit` cancels it
-/// (glslc's wait is a cancelation point) rather than waiting out a glslc.
-const Job = struct {
- io: std.Io,
- gpa: std.mem.Allocator,
- wake: Wake,
- paths: [max][]u8 = @splat(&.{}),
- known: [max]?u64 = @splat(null),
- results: [max]Result = @splat(.none),
- len: usize = 0,
- done: std.atomic.Value(bool) = .init(false),
- /// Set before the cancel: the files after the one it stopped are not
- /// compiled either (a cancel is said once, to the wait it lands in).
- stop: std.atomic.Value(bool) = .init(false),
- future: std.Io.Future(void) = undefined,
-};
-
-files: [max]File = @splat(.{}),
-len: usize = 0,
-/// The chain generation `files` follow; null before the first.
-generation: ?u32 = null,
-/// Moves whenever what `view` gives does: the chain or a file's SPIR-V.
-revision: u32 = 0,
-job: ?*Job = null,
-missing_said: bool = false,
-
-/// Brings the files to the chain the core holds, watches their directories,
-/// takes in a finished compile and starts the next. Each loop step, off the
-/// frame path. True when a compile was taken in: what it said wants a frame.
-pub fn sync(b: *Build, gpa: std.mem.Allocator, io: std.Io, core: *pardes.Pardes, fd: c_int, watches: *file_watch.Table, wake: Wake) bool {
- var collected = false;
- if (b.job) |job| {
- if (!job.done.load(.acquire)) return false;
- job.future.await(job.io);
- b.job = null;
- b.collect(gpa, core, job);
- collected = true;
- }
- const chain = &core.settings.post;
- if (b.generation != chain.generation) {
- b.generation = chain.generation;
- b.revision +%= 1;
- var next: [max]File = @splat(.{});
- var len: usize = 0;
- var paths: [max][]const u8 = undefined;
- for (chain.list()) |entry| {
- if (entry.scene != null) continue;
- next[len] = for (b.files[0..b.len]) |*file| {
- if (!std.mem.eql(u8, file.path, entry.path.get())) continue;
- const kept = file.*;
- file.* = .{};
- break kept;
- } else .{ .path = gpa.dupe(u8, entry.path.get()) catch continue };
- paths[len] = next[len].path;
- len += 1;
- }
- for (b.files[0..b.len]) |file| free(gpa, file);
- b.files = next;
- b.len = len;
- var bufs: [max][4096]u8 = undefined;
- var expanded: [max][]const u8 = undefined;
- 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;
- for (b.files[0..b.len]) |file| stale = stale or file.stale;
- if (!stale) return collected;
- const job = gpa.create(Job) catch return collected;
- job.* = .{ .io = io, .gpa = gpa, .wake = wake };
- for (b.files[0..b.len]) |*file| {
- if (!file.stale) continue;
- job.paths[job.len] = gpa.dupe(u8, file.path) catch continue;
- job.known[job.len] = file.source;
- job.len += 1;
- file.stale = false;
- }
- job.future = io.concurrent(compile, .{job}) catch {
- for (job.paths[0..job.len]) |path| gpa.free(path);
- gpa.destroy(job);
- return collected;
- };
- b.job = job;
- return collected;
-}
-
-/// A watched directory changed: every file is read again at the next sync.
-pub fn recheck(b: *Build) void {
- for (b.files[0..b.len]) |*file| file.stale = true;
-}
-
-/// The chain as passes, in its order.
-pub fn view(b: *const Build, chain: *const Chain, out: *[max]Pass) []const Pass {
- for (chain.list(), 0..) |entry, i| {
- out[i] = if (entry.scene) |scene| .{ .scene = scene, .level = entry.level, .animated = sceneAnimated(scene) } else for (b.files[0..b.len]) |file| {
- if (std.mem.eql(u8, file.path, entry.path.get())) break .{ .path = file.path, .spirv = file.spirv, .revision = file.revision, .animated = file.animated };
- } else .{ .path = entry.path.get() };
- }
- return out[0..chain.len];
-}
-
-pub fn deinit(b: *Build, gpa: std.mem.Allocator, fd: c_int, watches: *file_watch.Table) void {
- if (b.job) |job| {
- job.stop.store(true, .release);
- job.future.cancel(job.io);
- freeJob(gpa, job);
- }
- for (b.files[0..b.len]) |file| free(gpa, file);
- b.len = 0;
- file_watch.watchShaders(fd, watches, &.{});
-}
-
-fn free(gpa: std.mem.Allocator, file: File) void {
- gpa.free(file.path);
- gpa.free(file.spirv);
-}
-
-fn freeJob(gpa: std.mem.Allocator, job: *Job) void {
- for (job.paths[0..job.len], job.results[0..job.len]) |path, result| {
- gpa.free(path);
- switch (result) {
- .spirv => |r| gpa.free(r.bytes),
- .failed => |r| gpa.free(r.text),
- .none, .unchanged, .missing => {},
- }
- }
- gpa.destroy(job);
-}
-
-fn collect(b: *Build, gpa: std.mem.Allocator, core: *pardes.Pardes, job: *Job) void {
- defer gpa.destroy(job);
- for (job.paths[0..job.len], job.results[0..job.len]) |path, result| {
- defer gpa.free(path);
- const file = for (b.files[0..b.len]) |*file| {
- if (std.mem.eql(u8, file.path, path)) break file;
- } else null;
- var buf: [512]u8 = undefined;
- switch (result) {
- .none, .unchanged => {},
- .missing => if (!b.missing_said) {
- b.missing_said = true;
- core.setMessage(core.active, "Shader: glslc is not on PATH, so Shadertoy files do not run (Crt does)");
- },
- .failed => |r| {
- defer gpa.free(r.text);
- if (file) |f| f.source = r.source;
- // glslc's first line says where: in the file's own lines.
- const first = std.mem.sliceTo(r.text, '\n');
- core.setMessage(core.active, std.fmt.bufPrint(&buf, "Shader {s}: {s}", .{ path, first[0..@min(first.len, 400)] }) catch "Shader: compile failed");
- },
- .spirv => |r| {
- const f = file orelse {
- gpa.free(r.bytes);
- continue;
- };
- gpa.free(f.spirv);
- f.spirv = r.bytes;
- f.source = r.source;
- f.animated = r.animated;
- f.revision +%= 1;
- b.revision +%= 1;
- },
- }
- }
-}
-
-/// 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.
-fn compile(job: *Job) void {
- for (job.paths[0..job.len], 0..) |path, i| {
- if (job.stop.load(.acquire)) break;
- job.results[i] = compileOne(job.gpa, job.io, path, job.known[i]);
- }
- job.done.store(true, .release);
- 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, 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);
- if (known == source) return .unchanged;
- // The prefix and the file go to glslc on its stdin: no file of ours is
- // written anywhere. std's spawn does every allocation before fork and
- // searches PATH on the stack after it (Io/Threaded.zig spawnPosix,
- // posixExecv), so a child forked from this thread cannot wedge on a
- // lock another thread held (the forkShell hazard).
- var child = std.process.spawn(io, .{
- .argv = &.{ "glslc", "-fshader-stage=fragment", "-o", "-", "-" },
- .stdin = .pipe,
- .stdout = .pipe,
- .stderr = .pipe,
- }) catch |err| return switch (err) {
- error.FileNotFound => .missing,
- else => .{ .failed = .{ .text = std.fmt.allocPrint(gpa, "glslc did not run ({t})", .{err}) catch return .none, .source = source } },
- };
- defer child.kill(io);
- // glslc reads all of its input before it writes a byte, so writing it
- // first cannot deadlock against a full output pipe.
- {
- var stdin = child.stdin.?;
- child.stdin = null;
- defer stdin.close(io);
- var buf: [4096]u8 = undefined;
- var writer = stdin.writer(io, &buf);
- writer.interface.writeAll(prefix) catch {};
- writer.interface.writeAll(body) catch {};
- writer.interface.flush() catch {};
- }
- var streams: std.Io.File.MultiReader.Buffer(2) = undefined;
- var reader: std.Io.File.MultiReader = undefined;
- reader.init(gpa, io, streams.toStreams(), &.{ child.stdout.?, child.stderr.? });
- defer reader.deinit();
- const failed = struct {
- fn of(a: std.mem.Allocator, text: []const u8, hash: u64) Result {
- return .{ .failed = .{ .text = a.dupe(u8, text) catch return .none, .source = hash } };
- }
- }.of;
- while (reader.fill(64, .none)) |_| {
- if (reader.reader(0).buffered().len > 16 << 20 or reader.reader(1).buffered().len > 64 << 10)
- return failed(gpa, "glslc said too much", source);
- } else |err| switch (err) {
- error.EndOfStream => {},
- else => return failed(gpa, "reading glslc failed", source),
- }
- const term = child.wait(io) catch return failed(gpa, "glslc did not finish", source);
- const clean = switch (term) {
- .exited => |code| code == 0,
- else => false,
- };
- if (clean) return .{ .spirv = .{ .bytes = reader.toOwnedSlice(0) catch return .none, .source = source, .animated = readsTime(body) } };
- const said = reader.toOwnedSlice(1) catch return .none;
- // glslc calls its input <stdin>; the file is what a person knows.
- defer gpa.free(said);
- const named = std.mem.replaceOwned(u8, gpa, said, "<stdin>", path) catch return failed(gpa, "glslc failed", source);
- return .{ .failed = .{ .text = named, .source = source } };
-}
-
-test "ghostty's test shaders compile behind the prefix, and its invalid one fails with glslc's words" {
- const gpa = std.testing.allocator;
- const io = std.testing.io;
- // ghostty's own test shaders, from its package in zig-pkg.
- var pkg = std.Io.Dir.cwd().openDir(io, "zig-pkg", .{ .iterate = true }) catch return error.SkipZigTest;
- defer pkg.close(io);
- var it = pkg.iterate();
- const ghostty = while (it.next(io) catch null) |entry| {
- if (std.mem.startsWith(u8, entry.name, "ghostty-")) break entry.name;
- } else return error.SkipZigTest;
- var buf: [512]u8 = undefined;
- for ([_][]const u8{ "crt", "focus", "invalid" }) |name| {
- const path = try std.fmt.bufPrint(&buf, "zig-pkg/{s}/src/renderer/shaders/test_shadertoy_{s}.glsl", .{ ghostty, name });
- switch (compileOne(gpa, io, path, null)) {
- .missing => return error.SkipZigTest, // no glslc here
- .spirv => |r| {
- defer gpa.free(r.bytes);
- try std.testing.expect(!std.mem.eql(u8, name, "invalid"));
- // SPIR-V's magic number, little-endian.
- try std.testing.expectEqual(@as(u32, 0x07230203), std.mem.readInt(u32, r.bytes[0..4], .little));
- // The same bytes again compile nothing.
- try std.testing.expectEqual(Result.unchanged, compileOne(gpa, io, path, r.source));
- },
- .failed => |r| {
- defer gpa.free(r.text);
- try std.testing.expectEqualStrings("invalid", name);
- // Named by the file, not by glslc's <stdin>.
- try std.testing.expect(std.mem.indexOf(u8, r.text, path) != null);
- try std.testing.expect(std.mem.indexOf(u8, r.text, "<stdin>") == null);
- },
- .none, .unchanged => return error.TestUnexpectedResult,
- }
- }
-}
-
-test "a save that changes a file compiles it again, a failed one keeps the last good SPIR-V and is said once" {
- const gpa = std.testing.allocator;
- const io = std.testing.io;
- const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 });
- defer core.deinit();
- _ = try core.newShell(1, "");
- const pane = core.panes[core.active].?;
- var tmp = std.testing.tmpDir(.{});
- defer tmp.cleanup();
- var dir_buf: [4096]u8 = undefined;
- const dir = dir_buf[0..try tmp.dir.realPath(io, &dir_buf)];
- var path_buf: [4200]u8 = undefined;
- const path = try std.fmt.bufPrint(&path_buf, "{s}/wave.glsl", .{dir});
- const good = "void mainImage(out vec4 o, in vec2 p) { o = texture(iChannel0, p / iResolution.xy); }\n";
- try tmp.dir.writeFile(io, .{ .sub_path = "wave.glsl", .data = good });
- try std.testing.expect(core.settings.post.set(null, path, true));
-
- const fd = file_watch.init(true);
- defer if (fd >= 0) {
- _ = libc.close(fd);
- };
- var watches: file_watch.Table = @splat(null);
- var b: Build = .{};
- 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, 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, null);
- }
- }
- }.run;
- settle(&b, core, fd, &watches);
- if (b.missing_said) return error.SkipZigTest; // no glslc here
- var out: [max]Pass = undefined;
- const first = b.view(&core.settings.post, &out)[0];
- try std.testing.expect(first.spirv.len != 0);
- if (file_watch.supported) try std.testing.expect(watches[file_watch.shader_slot] != null);
-
- // Unchanged bytes: nothing moves.
- const at = b.revision;
- b.recheck();
- settle(&b, core, fd, &watches);
- try std.testing.expectEqual(at, b.revision);
-
- // A bad save: the last good SPIR-V stays, the error is said, and the
- // same bad bytes again say nothing more.
- try tmp.dir.writeFile(io, .{ .sub_path = "wave.glsl", .data = "void mainImage(" });
- pane.msg_len = 0;
- b.recheck();
- settle(&b, core, fd, &watches);
- try std.testing.expectEqual(at, b.revision);
- try std.testing.expect(std.mem.startsWith(u8, pane.msg[0..pane.msg_len], "Shader "));
- pane.msg_len = 0;
- b.recheck();
- settle(&b, core, fd, &watches);
- try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
-
- // A good save again: new SPIR-V, a new revision.
- try tmp.dir.writeFile(io, .{ .sub_path = "wave.glsl", .data = "// saved again\n" ++ good });
- b.recheck();
- settle(&b, core, fd, &watches);
- const second = b.view(&core.settings.post, &out)[0];
- try std.testing.expect(second.revision != first.revision and b.revision != at);
-}
-
-test "a pass animates when it reads the clock or the frame count, and only the CRT of the bundled ones" {
- try std.testing.expect(readsTime("o = vec4(sin(iTime));"));
- try std.testing.expect(readsTime("float f = float(iFrame % 64);"));
- try std.testing.expect(readsTime("x = iTimeCursorChange;"));
- try std.testing.expect(!readsTime("o = texture(iChannel0, p / iResolution.xy);"));
- for (std.enums.values(Scene)) |scene| try std.testing.expectEqual(scene == .crt, sceneAnimated(scene));
-}
diff --git a/src/builtins.zig b/src/builtins.zig
index 0295130d..c7b427f5 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -18,7 +18,6 @@ const limits = @import("memory.zig").limits;
pub const frontend: config.Runtime.Capabilities = .{
.font_picker = pardes.font_picker,
.panel_transitions = true,
- .scene_shaders = pardes.platform == .gui or pardes.platform == .macos,
// The tty's font belongs to its emulator.
.tagline_font_size = pardes.platform != .tui,
.window_opacity = pardes.platform == .gui or pardes.platform == .macos,
@@ -35,8 +34,8 @@ pub const frontend: config.Runtime.Capabilities = .{
/// its own frontend does (`viewCapabilities`), so a terminal's replica of a
/// window's session steps as the window's own does, and back.
pub const desktop = pardes.platform == .tui or pardes.platform == .gui;
-const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .panel_transitions = true, .scene_shaders = true, .tagline_font_size = true, .window_opacity = true, .window_blur = false, .ligatures = true, .lift = true };
-const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .panel_transitions = true, .scene_shaders = false, .tagline_font_size = false, .window_opacity = false, .window_blur = false, .ligatures = false, .lift = false };
+const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .panel_transitions = true, .tagline_font_size = true, .window_opacity = true, .window_blur = false, .ligatures = true, .lift = true };
+const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .panel_transitions = true, .tagline_font_size = false, .window_opacity = false, .window_blur = false, .ligatures = false, .lift = false };
/// The words this build has: a desktop build's are the window's.
pub const capabilities: config.Runtime.Capabilities = if (desktop) window_capabilities else frontend;
@@ -245,8 +244,8 @@ pub const registry = struct {
if (@backingInt(b) == i) return switch (setting.action) {
// a switch flips bare, a choice steps, and DumpDir and Shell bare
// are the default
- .toggle, .transition, .scene, .dump_dir, .choice, .lift, .shader_animation, .motion, .shell => false,
- .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .shader, .inactive_dim, .grip_width => true,
+ .toggle, .transition, .dump_dir, .choice, .lift, .motion, .shell => false,
+ .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .inactive_dim, .grip_width => true,
// bare, it says the current value (exec.applySettingBuiltin)
.tab, .callstack_depth, .search_rows => false,
};
@@ -277,14 +276,12 @@ pub const registry = struct {
}
};
-test "capabilities exactly gate setting and effect-source builtins" {
+test "capabilities exactly gate setting builtins" {
const Builtin = registry.Builtin();
for (config.Runtime.settings) |setting| {
const registered = std.meta.stringToEnum(Builtin, setting.word) != null;
try std.testing.expectEqual(setting.enabled(capabilities), registered);
}
- const effect_code_registered = std.meta.stringToEnum(Builtin, "EffectCode") != null;
- try std.testing.expectEqual(EffectCode.enabled, effect_code_registered);
}
test "a builtin's scope is the pane unless it says session, and every setting is the session's" {
@@ -1635,20 +1632,6 @@ pub const Changelog = struct {
}
};
-/// Open the source of a panel transition or post shader, by name.
-pub const EffectCode = struct {
- pub const scope: Scope = .session;
- pub const takes_arg = true;
- pub const requires_arg = true;
- pub const enabled = capabilities.panel_transitions or capabilities.scene_shaders;
- pub const gui_only = true;
- pub const output: OutputTraits = .{ .name = config.effect_code_buffer };
- pub fn run(c: Ctx) void {
- panes.Output.openEffectCode(c.p, c.id, c.arg orelse return) catch |err|
- c.p.reportError(c.id, "effect code", err);
- }
-};
-
/// An optional SDL workspace-tag companion; never consumes input or text cells.
pub const Pet = struct {
pub const scope: Scope = .session;
diff --git a/src/config.zig b/src/config.zig
index b12630e9..9394f912 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -193,15 +193,6 @@ pub const leader_path = paths: {
table.set(.PanelScramble, "ar");
table.set(.PanelType, "at");
}
- if (builtins.capabilities.scene_shaders) {
- table.set(.Crt, "tr");
- table.set(.Bloom, null);
- table.set(.Vignette, null);
- table.set(.Grain, null);
- table.set(.Shader, null);
- table.set(.ShaderAnimation, null);
- }
- if (builtins.EffectCode.enabled) table.set(.EffectCode, null);
if (builtins.TreeContext.enabled) table.set(.TreeContext, null);
table.set(.ThemeFile, null);
table.set(.DumpThemes, null);
@@ -544,7 +535,6 @@ pub const pipe_marker = " |";
pub const search_buffer = "+Search";
pub const help_buffer = "+Help";
pub const dump_config_buffer = "+DumpConfig";
-pub const effect_code_buffer = "+EffectCode";
pub const jumps_buffer = "+Jumps";
pub const preview_buffer = "+Preview";
pub const unsaved_buffer = "+Unsaved";
@@ -825,12 +815,6 @@ pub const Runtime = struct {
} = .{},
panel_transition: animation.Transition = .off,
- /// The post chain (docs/render-pipeline.md §6), in the order it runs.
- post: Post = .{},
- /// When the chain redraws on its own, past the frames it post-processes:
- /// never, while the window has the focus, or always (ghostty's
- /// custom-shader-animation).
- shader_animation: ShaderAnimation = .on,
/// What a terminal's shell pages through (host_io.ChildEnv): `pardes`,
/// PAGER and GIT_PAGER set to `pardes -`, a +Pager pane, where the
/// user's environment set neither; `off`, the environment as it is.
@@ -860,7 +844,6 @@ pub const Runtime = struct {
/// +Preview with): it never resizes itself after.
search_rows: u16 = 8,
- pub const ShaderAnimation = enum { off, on, always };
pub const Pager = enum { pardes, off };
pub const TermImages = enum { real, petscii };
pub const JumpScope = enum { file, all };
@@ -879,81 +862,6 @@ pub const Runtime = struct {
/// sets 35), not so much that they stop being worth reading.
pub const auto_dim: u8 = 30;
- /// Each pass the bundled Crt or a Shadertoy file.
- pub const Post = struct {
- pub const max = 8;
- pub const Entry = struct {
- scene: ?Scene = null,
- path: Text(limits.host_path_cap) = .{},
- /// A bundled pass's strength, 1 to `max_level`; 0 for a file.
- level: u8 = 0,
- };
- pub const max_level = 3;
- /// What `on` and a bare word turn a bundled pass on at.
- pub const default_level = 2;
- entries: [max]Entry = @splat(.{}),
- len: u8 = 0,
- /// Bumped on every change: a shell compiles the chain again when it
- /// moves.
- generation: u32 = 0,
-
- pub fn list(post: *const Post) []const Entry {
- return post.entries[0..post.len];
- }
-
- pub fn has(post: *const Post, scene: Scene) bool {
- return post.level(scene) != 0;
- }
-
- /// A bundled pass's level; 0 when it is not in the chain.
- pub fn level(post: *const Post, scene: Scene) u8 {
- for (post.list()) |entry| if (entry.scene == scene) return entry.level;
- return 0;
- }
-
- /// Sets a bundled pass's level: 0 takes it out, anything else puts it
- /// in at the end or changes it where it is.
- pub fn setLevel(post: *Post, scene: Scene, to: u8) bool {
- std.debug.assert(to <= max_level);
- if (to == 0) return post.set(scene, "", false);
- for (post.entries[0..post.len]) |*entry| if (entry.scene == scene) {
- if (entry.level != to) post.generation +%= 1;
- entry.level = to;
- return true;
- };
- if (!post.set(scene, "", true)) return false;
- post.entries[post.len - 1].level = to;
- return true;
- }
-
- /// Puts the pass in the chain, at its end, or takes it out; `want`
- /// null flips it. False when the chain is full or the path too long.
- pub fn set(post: *Post, scene: ?Scene, path: []const u8, want: ?bool) bool {
- const at: ?usize = for (post.list(), 0..) |entry, i| {
- if (entry.scene == scene and std.mem.eql(u8, entry.path.get(), path)) break i;
- } else null;
- const on = want orelse (at == null);
- if (on == (at != null)) return true;
- post.generation +%= 1;
- if (at) |i| {
- std.mem.copyForwards(Entry, post.entries[i .. post.len - 1], post.entries[i + 1 .. post.len]);
- post.len -= 1;
- return true;
- }
- if (post.len == max) return false;
- post.entries[post.len] = .{ .scene = scene };
- if (!post.entries[post.len].path.set(path)) return false;
- post.len += 1;
- return true;
- }
-
- pub fn clear(post: *Post) void {
- if (post.len == 0) return;
- post.len = 0;
- post.generation +%= 1;
- }
- };
-
pub const tagline_percent_min: u8 = 1;
pub const tagline_percent_max: u8 = 100;
@@ -1012,7 +920,6 @@ pub const Runtime = struct {
pub const Capabilities = struct {
font_picker: bool,
panel_transitions: bool,
- scene_shaders: bool,
tagline_font_size: bool,
window_opacity: bool = false,
window_blur: bool = false,
@@ -1028,9 +935,6 @@ pub const Runtime = struct {
pub const MessageTime = enum { linger, fall, dissolve };
pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, selection_glow, hover_glow, occlusion, parallax, jump_trail, chip_shadow, thumb_flash, program_esc };
- /// A bundled post pass, a Shadertoy file in shaders/post/: the CRT, and
- /// G4's bloom, vignette and grain (docs/effects.md).
- pub const Scene = enum { crt, bloom, vignette, grain };
pub const Action = union(enum) {
toggle: Toggle,
@@ -1053,11 +957,6 @@ pub const Runtime = struct {
callstack_depth,
search_rows,
transition: animation.Transition,
- scene: Scene,
- /// A Shadertoy file into the post chain or out of it; `off` empties
- /// it of files.
- shader,
- shader_animation,
choice: Choice,
};
@@ -1084,7 +983,6 @@ pub const Runtime = struct {
.window_opacity => .window_opacity,
.window_blur => .window_blur,
.transition => .panel_transitions,
- .scene, .shader, .shader_animation => .scene_shaders,
.lift, .grip_width => .lift,
.toggle => |field| switch (field) {
.ligatures => .ligatures,
@@ -1141,12 +1039,6 @@ pub const Runtime = struct {
.{ .word = "PanelCurtain", .action = .{ .transition = .curtain }, .doc = "Panes open and close like a curtain, on or off." },
.{ .word = "PanelScramble", .action = .{ .transition = .scramble }, .doc = "Panes open and close through scrambled text, on or off." },
.{ .word = "PanelType", .action = .{ .transition = .typewriter }, .doc = "Panes type themselves in as they open, on or off." },
- .{ .word = "Crt", .action = .{ .scene = .crt }, .doc = "The bundled CRT post pass over the window, on or off." },
- .{ .word = "Bloom", .action = .{ .scene = .bloom }, .doc = "The brightest ink glows a little: a level, 0 (off) through 3." },
- .{ .word = "Vignette", .action = .{ .scene = .vignette }, .doc = "The window's corners fall into shade: a level, 0 (off) through 3." },
- .{ .word = "Grain", .action = .{ .scene = .grain }, .doc = "The page takes a fine, still grain, like paper: a level, 0 (off) through 3." },
- .{ .word = "Shader", .action = .shader, .doc = "A Shadertoy file into the post chain, or out of it, compiled again when saved; off empties the chain." },
- .{ .word = "ShaderAnimation", .action = .shader_animation, .doc = "When the post chain animates on its own: off, on (while focused) or always." },
.{ .word = "Pager", .action = .{ .choice = .pager }, .doc = "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it." },
.{ .word = "PagerColor", .action = .{ .toggle = .pager_color }, .doc = "A +Pager keeps its program's colours, on or off; for the next text paged." },
.{ .word = "TermImages", .action = .{ .choice = .term_images }, .doc = "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art." },
@@ -1191,12 +1083,6 @@ pub const Runtime = struct {
if (actionCount(.{ .transition = effect }) != expected)
@compileError("non-off panel transition must occur exactly once: " ++ @tagName(effect));
}
- for (std.enums.values(Scene)) |effect| {
- if (actionCount(.{ .scene = effect }) != 1)
- @compileError("scene effect must occur exactly once: " ++ @tagName(effect));
- }
- if (actionCount(.shader) != 1 or actionCount(.shader_animation) != 1)
- @compileError("Shader and ShaderAnimation must each occur exactly once");
}
pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool {
@@ -1254,35 +1140,6 @@ pub const Runtime = struct {
state.panel_transition = .off;
}
},
- .scene => |effect| {
- // A level, 0 (off) to 3; `on` is the default level, `off` 0,
- // and bare flips between the two.
- const text = std.mem.trim(u8, argument orelse "", " \t\r\n");
- const to: u8 = if (text.len == 0)
- (if (state.post.has(effect)) 0 else Post.default_level)
- else if (std.mem.eql(u8, text, "on"))
- Post.default_level
- else if (std.mem.eql(u8, text, "off"))
- 0
- else
- std.fmt.parseInt(u8, text, 10) catch return false;
- if (to > Post.max_level) return false;
- return state.post.setLevel(effect, to);
- },
- .shader => {
- const path = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- if (path.len == 0) return false;
- if (std.mem.eql(u8, path, "off")) {
- var i: usize = 0;
- while (i < state.post.len) {
- const entry = state.post.entries[i];
- if (entry.scene == null) _ = state.post.set(null, entry.path.get(), false) else i += 1;
- }
- return true;
- }
- return state.post.set(null, path, null);
- },
- .shader_animation => state.shader_animation = stepped(ShaderAnimation, state.shader_animation, argument) orelse return false,
// Bare, it steps to the next word, as a tag word should.
.choice => |which| switch (which) {
inline else => |field| {
@@ -1328,8 +1185,6 @@ pub const Runtime = struct {
},
.lift => "on, " ++ comptime words.of(LiftStyle),
.motion => comptime words.of(animation.Motion.Flavour),
- .scene => std.fmt.comptimePrint("on, off, 0-{d}", .{Post.max_level}),
- .shader_animation => comptime words.of(ShaderAnimation),
else => null,
};
}
@@ -1347,7 +1202,6 @@ pub const Runtime = struct {
.message_ms => std.fmt.comptimePrint("0-{d} (milliseconds)", .{message_ms_max}),
.shell => "a path of at most 255 bytes; bare, $SHELL, else /bin/sh",
.dump_dir => std.fmt.comptimePrint("an absolute or ~ path of at most {d} bytes, to a directory that may be written; bare, the default", .{limits.host_path_cap}),
- .shader => "a Shadertoy file's path, or off",
.font => "a name or path, :8 to :72 after it (Mono:14)",
else => null,
};
@@ -1463,19 +1317,6 @@ pub const Runtime = struct {
.tagline_size => try out.print("{s} {d}\n", .{ setting.word, state.font.tagline_percent }),
// Each a switch of its own, the one in use on.
.transition => |transition| try out.print("{s} {s}\n", .{ setting.word, onOff(state.panel_transition == transition) }),
- .scene => |effect| {
- const level = state.post.level(effect);
- if (level == 0) try out.print("{s} off\n", .{setting.word}) else try out.print("{s} {d}\n", .{ setting.word, level });
- },
- .shader => {
- var files: usize = 0;
- for (state.post.list()) |entry| if (entry.scene == null) {
- try out.print("{s} {s}\n", .{ setting.word, entry.path.get() });
- files += 1;
- };
- if (files == 0) try out.print("{s} off\n", .{setting.word});
- },
- .shader_animation => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.shader_animation) }),
.choice => |which| switch (which) {
inline else => |field| try out.print("{s} {s}\n", .{ setting.word, @tagName(@field(state, @tagName(field))) }),
},
@@ -1517,7 +1358,7 @@ pub const Runtime = struct {
try out.print("# Pet: {s}\n", .{@tagName(state.pet)});
}
- test "panel and scene effects flip bare and are set by on and off" {
+ test "panel effects flip bare and are set by on and off" {
var state: Runtime = .{};
const slide = findAction(.{ .transition = .slide }).?;
const zoom = findAction(.{ .transition = .zoom }).?;
@@ -1530,10 +1371,6 @@ pub const Runtime = struct {
try std.testing.expect(apply(&state, slide, null));
try std.testing.expectEqual(animation.Transition.off, state.panel_transition);
try std.testing.expect(!apply(&state, slide, "yes"));
- const scene = findAction(.{ .scene = std.enums.values(Scene)[0] }).?;
- try std.testing.expect(apply(&state, scene, "on"));
- try std.testing.expect(apply(&state, scene, "on"));
- try std.testing.expect(state.post.has(std.enums.values(Scene)[0]));
}
test "a toggle flips when bare and sets when told on or off" {
@@ -1569,53 +1406,6 @@ pub const Runtime = struct {
try std.testing.expectEqual(animation.Transition.ascii, state.panel_transition);
try std.testing.expect(apply(&state, find("PanelAscii").?, null));
try std.testing.expectEqual(animation.Transition.off, state.panel_transition);
- try std.testing.expect(apply(&state, find("Crt").?, null));
- try std.testing.expect(state.post.has(.crt));
- }
-
- test "the post chain runs in the order its passes were put in, and Shader off empties it of files" {
- var state: Runtime = .{};
- try std.testing.expect(apply(&state, find("Shader").?, " ~/a.glsl\n"));
- try std.testing.expect(apply(&state, find("Crt").?, "on"));
- try std.testing.expect(apply(&state, find("Shader").?, "/b.glsl"));
- const chain = state.post.list();
- try std.testing.expectEqual(@as(usize, 3), chain.len);
- try std.testing.expectEqualStrings("~/a.glsl", chain[0].path.get());
- try std.testing.expectEqual(Scene.crt, chain[1].scene.?);
- try std.testing.expectEqualStrings("/b.glsl", chain[2].path.get());
- const moved = state.post.generation;
- // A file named again leaves; the others keep their order.
- try std.testing.expect(apply(&state, find("Shader").?, "~/a.glsl"));
- try std.testing.expect(state.post.generation != moved);
- try std.testing.expectEqual(Scene.crt, state.post.list()[0].scene.?);
- try std.testing.expect(apply(&state, find("Shader").?, "off"));
- try std.testing.expectEqual(@as(usize, 1), state.post.len);
- try std.testing.expect(!apply(&state, find("Shader").?, null));
- try std.testing.expect(apply(&state, find("ShaderAnimation").?, "always"));
- try std.testing.expectEqual(ShaderAnimation.always, state.shader_animation);
- try std.testing.expect(!apply(&state, find("ShaderAnimation").?, "sometimes"));
- }
-
- test "a bundled pass takes a level: on is the default, 0 and off take it out, and the old words still flip" {
- var state: Runtime = .{};
- const crt = find("Crt").?;
- try std.testing.expect(apply(&state, crt, "on"));
- try std.testing.expectEqual(@as(u8, Post.default_level), state.post.level(.crt));
- try std.testing.expect(apply(&state, find("Shader").?, "/after.glsl"));
- const moved = state.post.generation;
- try std.testing.expect(apply(&state, crt, "3"));
- try std.testing.expectEqual(@as(u8, 3), state.post.level(.crt));
- // A new level keeps its place in the chain.
- try std.testing.expectEqual(Scene.crt, state.post.list()[0].scene.?);
- try std.testing.expect(state.post.generation != moved);
- try std.testing.expect(!apply(&state, crt, "4"));
- try std.testing.expect(!apply(&state, crt, "loud"));
- try std.testing.expect(apply(&state, crt, "0"));
- try std.testing.expect(!state.post.has(.crt));
- try std.testing.expect(apply(&state, crt, null));
- try std.testing.expectEqual(@as(u8, Post.default_level), state.post.level(.crt));
- try std.testing.expect(apply(&state, crt, "off"));
- try std.testing.expectEqual(@as(u8, 0), state.post.level(.crt));
}
test "Lift takes a style, on is auto, and bare flips it off and back to auto" {
@@ -1732,7 +1522,6 @@ pub const Runtime = struct {
.capabilities = .{
.font_picker = true,
.panel_transitions = true,
- .scene_shaders = true,
.tagline_font_size = true,
.window_opacity = true,
.window_blur = true,
@@ -1742,13 +1531,12 @@ pub const Runtime = struct {
.state = &state,
};
const values = [_][2][]const u8{
- .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
- .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
- .{ "DumpDir", "~/dumps" }, .{ "Crt", "3" }, .{ "Shader", "~/crt.glsl" },
- .{ "ShaderAnimation", "always" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
- .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Lift", "rim" },
- .{ "Motion", "playful" }, .{ "InactiveDim", "35" }, .{ "GripWidth", "200" },
- .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" },
+ .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
+ .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
+ .{ "DumpDir", "~/dumps" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
+ .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Lift", "rim" },
+ .{ "Motion", "playful" }, .{ "InactiveDim", "35" }, .{ "GripWidth", "200" },
+ .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" },
};
for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1]));
try std.testing.expect(state.font.requested_name.set("Wanted Mono"));
@@ -1785,7 +1573,6 @@ pub const Runtime = struct {
defaults_context.capabilities = .{
.font_picker = false,
.panel_transitions = true,
- .scene_shaders = false,
.tagline_font_size = false,
};
defaults_context.state = &defaults;
@@ -1793,7 +1580,7 @@ pub const Runtime = struct {
try writeReport(&out, defaults_context);
const defaults_report = storage[0..out.end];
// A setting this shell does not have reads so, as a comment.
- for ([_][]const u8{ "# WindowOpacity unsupported\n", "# WindowBlur unsupported\n", "# Font unsupported\n", "# Crt unsupported\n", "# TaglineSize unsupported\n", "# Ligatures unsupported\n" }) |expected|
+ for ([_][]const u8{ "# WindowOpacity unsupported\n", "# WindowBlur unsupported\n", "# Font unsupported\n", "# TaglineSize unsupported\n", "# Ligatures unsupported\n" }) |expected|
try std.testing.expect(std.mem.indexOf(u8, defaults_report, expected) != null);
try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font in use") == null);
// Every line before the blank one is a ctl word and its value, or a
diff --git a/src/effect_sources.zig b/src/effect_sources.zig
deleted file mode 100644
index 39d86a1d..00000000
--- a/src/effect_sources.zig
+++ /dev/null
@@ -1,98 +0,0 @@
-const std = @import("std");
-const build_config = @import("pardes_config");
-const config = @import("config.zig");
-const filesystem = @import("fs.zig");
-
-const shader_dir = "shaders/";
-const ui_vertex_path = shader_dir ++ "ui.vert.glsl";
-const ui_fragment_path = shader_dir ++ "ui.frag.glsl";
-const image_vertex_path = shader_dir ++ "image.vert.glsl";
-const image_fragment_path = shader_dir ++ "image.frag.glsl";
-const post_vertex_path = shader_dir ++ "post.vert.glsl";
-// The bundled post pass as compiled: the prefix and the pass together.
-const post_crt_path = shader_dir ++ "post-crt.frag.glsl";
-const post_bloom_path = shader_dir ++ "post-bloom.frag.glsl";
-const post_vignette_path = shader_dir ++ "post-vignette.frag.glsl";
-const post_grain_path = shader_dir ++ "post-grain.frag.glsl";
-const bloom_down_path = shader_dir ++ "bloom-down.frag.glsl";
-const bloom_up_path = shader_dir ++ "bloom-up.frag.glsl";
-
-pub const Backend = @TypeOf(build_config.platform);
-pub const backend: Backend = build_config.platform;
-
-pub const files = switch (backend) {
- .tui => [_]filesystem.Source{
- .{ .path = "src/tui/panel_compositor.zig", .contents = @embedFile("tui/panel_compositor.zig") },
- },
- .gui => [_]filesystem.Source{
- .{ .path = "src/gui/gui.zig", .contents = @embedFile("gui/gui.zig") },
- .{ .path = "src/gui/Post.zig", .contents = @embedFile("gui/Post.zig") },
- .{ .path = ui_vertex_path, .contents = @embedFile("effect-source-ui.vert.glsl") },
- .{ .path = ui_fragment_path, .contents = @embedFile("effect-source-ui.frag.glsl") },
- .{ .path = image_vertex_path, .contents = @embedFile("effect-source-image.vert.glsl") },
- .{ .path = image_fragment_path, .contents = @embedFile("effect-source-image.frag.glsl") },
- .{ .path = post_vertex_path, .contents = @embedFile("effect-source-post.vert.glsl") },
- .{ .path = post_crt_path, .contents = @embedFile("effect-source-post-crt.frag.glsl") },
- .{ .path = post_bloom_path, .contents = @embedFile("effect-source-post-bloom.frag.glsl") },
- .{ .path = post_vignette_path, .contents = @embedFile("effect-source-post-vignette.frag.glsl") },
- .{ .path = post_grain_path, .contents = @embedFile("effect-source-post-grain.frag.glsl") },
- .{ .path = bloom_down_path, .contents = @embedFile("effect-source-bloom-down.frag.glsl") },
- .{ .path = bloom_up_path, .contents = @embedFile("effect-source-bloom-up.frag.glsl") },
- },
- .macos => [_]filesystem.Source{
- .{ .path = "src/macos/Sources/PardesView.swift", .contents = @embedFile("macos/Sources/PardesView.swift") },
- .{ .path = "src/macos/Sources/ScenePostprocessor.swift", .contents = @embedFile("macos/Sources/ScenePostprocessor.swift") },
- .{ .path = "shaders/crt.ci.metal", .contents = @embedFile("effect-source-crt.ci.metal") },
- },
-};
-
-pub fn forSetting(setting: config.Runtime.Setting) ?[]const []const u8 {
- return switch (setting.action) {
- .transition => switch (backend) {
- .tui => &.{ "src/layout.zig", "src/pardes.zig", "src/tui/panel_compositor.zig" },
- .gui => &.{ "src/layout.zig", "src/pardes.zig", "src/gui/gui.zig", ui_vertex_path, ui_fragment_path, image_vertex_path, image_fragment_path },
- .macos => &.{ "src/layout.zig", "src/pardes.zig", "src/macos/Sources/PardesView.swift", "src/macos/Sources/ScenePostprocessor.swift", "shaders/crt.ci.metal" },
- },
- .scene => |effect| switch (backend) {
- .gui => switch (effect) {
- .crt => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, post_crt_path },
- .bloom => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, bloom_down_path, bloom_up_path, post_bloom_path },
- .vignette => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, post_vignette_path },
- .grain => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, post_grain_path },
- },
- .macos => &.{ "src/macos/Sources/PardesView.swift", "src/macos/Sources/ScenePostprocessor.swift", "shaders/crt.ci.metal" },
- .tui => null,
- },
- else => null,
- };
-}
-
-test "EffectCode paths resolve uniquely to this backend's archived inputs" {
- if (!@import("memory.zig").limits.embedded_sources) return error.SkipZigTest;
- for (config.Runtime.settings) |setting| {
- const available = switch (setting.action) {
- .transition => backend == .tui or backend == .gui or backend == .macos,
- .scene => backend == .gui or backend == .macos,
- else => false,
- };
- const paths = forSetting(setting);
- try std.testing.expectEqual(available, paths != null);
- if (paths) |listed| for (listed, 0..) |path, i| {
- const bytes = filesystem.sourceBytes(path) orelse return error.MissingEffectSource;
- try std.testing.expect(bytes.len > 0);
- for (listed[0..i]) |previous| try std.testing.expect(!std.mem.eql(u8, path, previous));
- };
- }
- for (files) |file| {
- const archived = filesystem.sourceBytes(file.path) orelse return error.MissingEffectSource;
- try std.testing.expectEqualStrings(file.contents, archived);
- var matches: usize = 0;
- for (filesystem.sources) |source| if (std.mem.eql(u8, source.path, file.path)) {
- matches += 1;
- };
- try std.testing.expectEqual(@as(usize, 1), matches);
- }
- try std.testing.expectEqual(backend == .tui, filesystem.sourceBytes("src/tui/panel_compositor.zig") != null);
- try std.testing.expectEqual(backend == .gui, filesystem.sourceBytes("src/gui/gui.zig") != null);
- try std.testing.expectEqual(backend == .macos, filesystem.sourceBytes("src/macos/Sources/PardesView.swift") != null);
-}
diff --git a/src/exec.zig b/src/exec.zig
index 0c559382..b258549e 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -302,11 +302,11 @@ pub fn withArg(p: *Pardes, txt: []const u8, arg: ?[]const u8) []const u8 {
const a = std.mem.trim(u8, arg orelse return txt, " \t\r\n");
if (a.len == 0) return txt;
const t = std.mem.trim(u8, txt, " \t\r\n");
- // A switch (Verbose, PanelSlide, Crt) clicked with some other text
+ // A switch (Verbose, PanelSlide) clicked with some other text
// selected flips, as it does bare: only `on` or `off` is an argument
// for it. What a ctl write gives it is checked strictly instead.
if (config.Runtime.find(commandText(t))) |setting| switch (setting.action) {
- .toggle, .transition, .scene => if (!std.mem.eql(u8, a, "on") and !std.mem.eql(u8, a, "off")) return txt,
+ .toggle, .transition => if (!std.mem.eql(u8, a, "on") and !std.mem.eql(u8, a, "off")) return txt,
else => {},
};
return std.fmt.allocPrint(p.scratch.allocator(), "{s} {s}", .{ t, a }) catch txt;
diff --git a/src/file_watch.zig b/src/file_watch.zig
index ea8115bc..a75383e1 100644
--- a/src/file_watch.zig
+++ b/src/file_watch.zig
@@ -71,11 +71,7 @@ pub const Watch = struct {
/// Sharing the table also shares directory descriptors correctly when a user
/// happens to open that .zon as an ordinary document.
pub const theme_slot = pardes.MAX_PANES;
-/// After it, one slot a post chain file (ShaderBuild.zig): marked only so
-/// a save there wakes the host, which has the files read again; no
-/// generation of theirs is kept here.
-pub const shader_slot = theme_slot + 1;
-pub const Table = [shader_slot + pardes.config.Runtime.Post.max]?Watch;
+pub const Table = [theme_slot + 1]?Watch;
/// Whether this OS has a watcher at all. Off it every entry point below
/// returns the inert answer: `watchPane` installs nothing, so `watches` stays
@@ -424,13 +420,6 @@ pub fn unwatchAll(fd: c_int, watches: *Table) void {
for (0..pardes.MAX_PANES) |id| watchPane(fd, watches, @intCast(id), null, 0, .{ .text = 0 });
}
-/// Mark the post chain files' directories, one slot each, dropping the
-/// marks of files no longer in it.
-pub fn watchShaders(fd: c_int, watches: *Table, paths: []const []const u8) void {
- for (0..pardes.config.Runtime.Post.max) |i|
- watchPane(fd, watches, shader_slot + i, if (i < paths.len) paths[i] else null, 0, .{ .text = 0 });
-}
-
/// Reconcile one marked pane. A true result requests an immediate second pass:
/// the PDF pathname changed between the stat before MuPDF reopened it and the
/// stat after, so committing either identity would lose a generation.
diff --git a/src/fs.zig b/src/fs.zig
index ae614cd7..4afc17bd 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -35,10 +35,7 @@ pub const os_node: u64 = 1 << 62;
pub const name_capacity: usize = 255;
pub const Source = struct { path: []const u8, contents: []const u8 };
-pub const sources: []const Source = if (limits.embedded_sources)
- &(source_files ++ @import("effect_sources.zig").files)
-else
- &.{};
+pub const sources: []const Source = if (limits.embedded_sources) &source_files else &.{};
const source_files = [_]Source{
.{ .path = "src/pardes.zig", .contents = @embedFile("pardes.zig") },
.{ .path = "src/panes.zig", .contents = @embedFile("panes.zig") },
diff --git a/src/gui/Post.zig b/src/gui/Post.zig
deleted file mode 100644
index 19b10c52..00000000
--- a/src/gui/Post.zig
+++ /dev/null
@@ -1,653 +0,0 @@
-//! The post chain (docs/render-pipeline.md §6): Shadertoy passes over the
-//! 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 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
-//! here. Their clock is the shell's and moves only when the chain draws:
-//! with a frame of the core's, or on its own while ShaderAnimation asks for
-//! it (redraw level A, §5.5: the chain alone, over the retained frame).
-const std = @import("std");
-const libc = std.c;
-const ghostty_vt = @import("ghostty-vt");
-const pardes = @import("../pardes.zig");
-const gui = @import("gui.zig");
-const c = gui.c;
-
-const Post = @This();
-const Scene = pardes.config.Runtime.Scene;
-const Chain = pardes.config.Runtime.Post;
-const Pipeline = c.SDL_GPUGraphicsPipeline;
-pub const max = Chain.max;
-
-const prefix = @embedFile("post-prefix.glsl");
-const Built = @import("../ShaderBuild.zig").Pass;
-const vert_spv = @embedFile("post.vert.spv");
-const bundled_spv = std.EnumArray(Scene, []const u8).init(.{
- .crt = @embedFile("post-crt.frag.spv"),
- .bloom = @embedFile("post-bloom.frag.spv"),
- .vignette = @embedFile("post-vignette.frag.spv"),
- .grain = @embedFile("post-grain.frag.spv"),
-});
-const bloom_down_spv = @embedFile("bloom-down.frag.spv");
-const bloom_up_spv = @embedFile("bloom-up.frag.spv");
-/// Bloom's steps below the frame, at levels 1 to 3: a half, a quarter, ...
-const bloom_steps = [_]u8{ 3, 4, 5 };
-const bloom_format = c.SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT;
-/// Every pass writes its target whole: no blending.
-const no_blend = std.mem.zeroes(c.SDL_GPUColorTargetBlendState);
-
-/// pardes's own block (shaders/post/prefix.glsl PardesPost), std140.
-pub const Own = extern struct {
- opaque_window: f32 = 1,
- level: f32 = 0,
- scale: f32 = 1,
- cap: f32 = 0,
- spare_count: f32 = 0,
- _pad: [3]f32 = @splat(0),
- spare: [max_spare][4]f32 = @splat(@splat(0)),
-};
-pub const max_spare = 32;
-
-/// ghostty's Shadertoy uniform block, member for member in the GLSL block's
-/// order and std140 layout (shaders/post/prefix.glsl). Filled by the GLSL
-/// names: ghostty's own Zig mirror calls the second-to-last slot
-/// selection_background, so there the two selection colours arrive swapped
-/// (docs §6, open point 1); here each is what its GLSL name says.
-pub const Uniforms = extern struct {
- resolution: [3]f32 align(16) = .{ 0, 0, 1 },
- time: f32 align(4) = 0,
- time_delta: f32 align(4) = 0,
- frame_rate: f32 align(4) = 60,
- frame: i32 align(4) = 0,
- channel_time: [4][4]f32 align(16) = @splat(@splat(0)),
- channel_resolution: [4][4]f32 align(16) = @splat(@splat(0)),
- mouse: [4]f32 align(16) = @splat(0),
- date: [4]f32 align(16) = @splat(0),
- sample_rate: f32 align(4) = 44100,
- current_cursor: [4]f32 align(16) = @splat(0),
- previous_cursor: [4]f32 align(16) = @splat(0),
- current_cursor_color: [4]f32 align(16) = @splat(0),
- previous_cursor_color: [4]f32 align(16) = @splat(0),
- current_cursor_style: i32 align(4) = 0,
- previous_cursor_style: i32 align(4) = 0,
- cursor_visible: i32 align(4) = 0,
- cursor_change_time: f32 align(4) = 0,
- time_focus: f32 align(4) = 0,
- focus: i32 align(4) = 1,
- palette: [256][4]f32 align(16) = @splat(@splat(0)),
- background_color: [4]f32 align(16) = @splat(0),
- foreground_color: [4]f32 align(16) = @splat(0),
- cursor_color: [4]f32 align(16) = @splat(0),
- cursor_text: [4]f32 align(16) = @splat(0),
- selection_foreground_color: [4]f32 align(16) = @splat(0),
- selection_background_color: [4]f32 align(16) = @splat(0),
-};
-
-pub const Pass = struct {
- scene: ?Scene = null,
- /// A bundled pass's strength (pardesLevel); 0 for a file.
- level: u8 = 0,
- /// A user's file, owned; empty for a bundled pass.
- path: []u8 = &.{},
- pipeline: ?*Pipeline = null,
- /// The SPIR-V revision `pipeline` was made from (ShaderBuild.Pass).
- revision: u32 = 0,
- /// It moves on its own (ShaderBuild.Pass).
- animated: bool = false,
-};
-
-passes: [max]Pass = @splat(.{}),
-len: usize = 0,
-/// The chain key `passes` follow (sync); null before the first.
-key: ?u32 = null,
-bundled: std.EnumArray(Scene, ?*Pipeline) = .initFill(null),
-ping: [2]?*c.SDL_GPUTexture = .{ null, null },
-ping_w: u32 = 0,
-ping_h: u32 = 0,
-uniforms: Uniforms = .{},
-/// The display's density, for a pass whose pattern is in logical pixels
-/// (pardesScale); the shell sets it.
-scale: f32 = 1,
-/// What a bundled pass may do on this theme (pardesCap), each scene's, and
-/// the rectangles every bundled pass leaves alone (pardesSpare): both from
-/// the last frame described.
-caps: std.EnumArray(Scene, f32) = .initFill(0),
-spare: [max_spare][4]f32 = @splat(@splat(0)),
-spare_len: usize = 0,
-/// Bloom's float chain, a half the frame and down, and its two steps.
-bloom_tex: [bloom_steps[bloom_steps.len - 1]]?*c.SDL_GPUTexture = @splat(null),
-bloom_w: u32 = 0,
-bloom_h: u32 = 0,
-bloom_down: ?*Pipeline = null,
-bloom_up: ?*Pipeline = null,
-started_ns: ?u64 = null,
-last_ns: u64 = 0,
-
-/// Brings the passes to the chain a shell was given (ShaderBuild.zig: a
-/// local core's, or an attached session's over the wire), whose `key` moves
-/// whenever the chain or a file's SPIR-V does. A file whose SPIR-V has not
-/// moved keeps its pipeline; one the GPU refuses keeps its last, and is said
-/// to `core`, or logged where there is none. Each loop step, off the frame
-/// path.
-pub fn sync(post: *Post, gpa: std.mem.Allocator, device: *c.SDL_GPUDevice, format: c.SDL_GPUTextureFormat, chain: []const Built, key: u32, core: ?*pardes.Pardes) void {
- if (post.key == key) return;
- post.key = key;
- var next: [max]Pass = @splat(.{});
- for (chain, 0..) |entry, i| {
- if (entry.scene) |scene| {
- if (post.bundled.get(scene) == null) post.bundled.set(scene, gui.makePipeline(device, format, vert_spv, bundled_spv.get(scene), if (scene == .bloom) 2 else 1, 4, null, no_blend) catch null);
- if (scene == .bloom and post.bloom_down == null) {
- post.bloom_down = gui.makePipeline(device, bloom_format, vert_spv, bloom_down_spv, 1, 1, null, no_blend) catch null;
- post.bloom_up = gui.makePipeline(device, bloom_format, vert_spv, bloom_up_spv, 1, 1, null, no_blend) catch null;
- }
- next[i] = .{ .scene = scene, .level = entry.level, .pipeline = post.bundled.get(scene), .animated = entry.animated };
- continue;
- }
- // A file already in the chain keeps its pipeline and its path.
- for (post.passes[0..post.len]) |*pass| {
- if (pass.scene != null or !std.mem.eql(u8, pass.path, entry.path)) continue;
- next[i] = pass.*;
- pass.* = .{};
- break;
- } else next[i] = .{ .path = gpa.dupe(u8, entry.path) catch &.{} };
- const pass = &next[i];
- pass.animated = entry.animated;
- if (pass.revision == entry.revision or entry.spirv.len == 0) continue;
- pass.revision = entry.revision;
- const made = gui.makePipeline(device, format, vert_spv, entry.spirv, 1, 4, null, no_blend) catch {
- var buf: [512]u8 = undefined;
- const text = std.fmt.bufPrint(&buf, "Shader {s}: the GPU refused it", .{entry.path}) catch "Shader: the GPU refused it";
- if (core) |p| p.setMessage(p.active, text) else std.log.err("{s}", .{text});
- continue;
- };
- if (pass.pipeline) |old| c.SDL_ReleaseGPUGraphicsPipeline(device, old);
- pass.pipeline = made;
- }
- for (post.passes[0..post.len]) |pass| {
- if (pass.scene == null) if (pass.pipeline) |pipeline| c.SDL_ReleaseGPUGraphicsPipeline(device, pipeline);
- gpa.free(pass.path);
- }
- post.passes = next;
- post.len = chain.len;
- // An emptied chain's clock starts again with the next pass put in it.
- if (post.len == 0) {
- post.started_ns = null;
- post.last_ns = 0;
- post.uniforms.frame = 0;
- }
-}
-
-/// A pass is ready to draw.
-pub fn ready(post: *const Post) bool {
- for (post.passes[0..post.len]) |pass| if (pass.pipeline != null) return true;
- return false;
-}
-
-/// The chain redraws on its own (level A) as ShaderAnimation says.
-/// Only a pass that moves on its own (ShaderBuild.Pass.animated) asks for
-/// frames while idle: a still one (Bloom, Vignette, Grain, a file that reads
-/// no clock) is drawn again only with a frame of the core's.
-pub fn animating(post: *const Post, mode: pardes.config.Runtime.ShaderAnimation) bool {
- const moving = for (post.passes[0..post.len]) |pass| {
- if (pass.pipeline != null and pass.animated) break true;
- } else false;
- return moving and switch (mode) {
- .off => false,
- .on => post.uniforms.focus != 0,
- .always => true,
- };
-}
-
-/// What a frame of the core's tells the passes: where its cursor is drawn
-/// and in what, and the theme's colours.
-pub const Frame = struct {
- pub const Cursor = struct { x0: f32, y0: f32, x1: f32, y1: f32, rgb: [3]u8, text: [3]u8, bar: bool };
- cursor: ?Cursor,
- /// What a bundled pass leaves alone, in framebuffer pixels: the tags,
- /// grips and notices (and the cursor, added here).
- spare: []const [4]f32 = &.{},
- background: [3]u8,
- foreground: [3]u8,
- selection_foreground: [3]u8,
- selection_background: [3]u8,
-};
-
-fn rgba(rgb: [3]u8) [4]f32 {
- return .{ @as(f32, @floatFromInt(rgb[0])) / 255, @as(f32, @floatFromInt(rgb[1])) / 255, @as(f32, @floatFromInt(rgb[2])) / 255, 1 };
-}
-
-/// Takes in a frame of the core's. The cursor's rectangle is (left, BOTTOM
-/// edge, width, height) in framebuffer pixels, y down; a move or a new
-/// colour makes the old one the previous and stamps the change.
-pub fn describe(post: *Post, frame: Frame) void {
- const u = &post.uniforms;
- post.caps = capsOf(frame);
- post.spare_len = 0;
- for (frame.spare) |rect| post.addSpare(rect);
- if (frame.cursor) |cursor| post.addSpare(.{ cursor.x0, cursor.y0, cursor.x1, cursor.y1 });
- u.background_color = rgba(frame.background);
- u.foreground_color = rgba(frame.foreground);
- u.selection_foreground_color = rgba(frame.selection_foreground);
- u.selection_background_color = rgba(frame.selection_background);
- if (u.palette[1][3] == 0) for (&u.palette, 0..) |*slot, i| {
- const color = ghostty_vt.color.default[i];
- slot.* = rgba(.{ color.r, color.g, color.b });
- };
- u.cursor_visible = @intFromBool(frame.cursor != null);
- const cursor = frame.cursor orelse return;
- const rect: [4]f32 = .{ cursor.x0, cursor.y1, cursor.x1 - cursor.x0, cursor.y1 - cursor.y0 };
- const style: i32 = if (cursor.bar) 2 else 0;
- const color = rgba(cursor.rgb);
- u.cursor_color = color;
- u.cursor_text = rgba(cursor.text);
- if (std.meta.eql(rect, u.current_cursor) and std.meta.eql(color, u.current_cursor_color) and style == u.current_cursor_style) return;
- u.previous_cursor = u.current_cursor;
- u.previous_cursor_color = u.current_cursor_color;
- u.previous_cursor_style = u.current_cursor_style;
- u.current_cursor = rect;
- u.current_cursor_color = color;
- u.current_cursor_style = style;
- u.cursor_change_time = u.time;
-}
-
-/// A rectangle a bundled pass leaves alone; past `max_spare` the last one
-/// grows to cover the rest (sparing more, never less).
-fn addSpare(post: *Post, rect: [4]f32) void {
- if (rect[2] <= rect[0] or rect[3] <= rect[1]) return;
- if (post.spare_len < max_spare) {
- post.spare[post.spare_len] = rect;
- post.spare_len += 1;
- return;
- }
- const last = &post.spare[max_spare - 1];
- last.* = .{ @min(last[0], rect[0]), @min(last[1], rect[1]), @max(last[2], rect[2]), @max(last[3], rect[3]) };
-}
-
-/// sRGB's relative luminance (WCAG) and a pair's contrast.
-fn luminance(rgb: [3]f32) f32 {
- var sum: f32 = 0;
- for (rgb, [3]f32{ 0.2126, 0.7152, 0.0722 }) |v, weight|
- sum += weight * (if (v <= 0.04045) v / 12.92 else std.math.pow(f32, (v + 0.055) / 1.055, 2.4));
- return sum;
-}
-fn contrastOf(a: f32, b: f32) f32 {
- return (@max(a, b) + 0.05) / (@min(a, b) + 0.05);
-}
-fn unit(rgb: [3]u8) [3]f32 {
- return .{ @as(f32, @floatFromInt(rgb[0])) / 255, @as(f32, @floatFromInt(rgb[1])) / 255, @as(f32, @floatFromInt(rgb[2])) / 255 };
-}
-
-/// Each bundled pass's ceiling on this theme (pardesCap, docs/effects.md):
-/// the most it may do while the text on the page, and the selection's text
-/// on its own ground, keep min(their contrast, 4.5). Bloom adds light to
-/// both of a pair (linear, as a share of full white); a vignette darkens
-/// both (a share); grain moves the page alone, either way (sRGB units).
-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;
- for (pairs) |pair| {
- const a = luminance(pair[0]);
- const b = luminance(pair[1]);
- const light = @max(a, b);
- const dark = @min(a, b);
- 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)));
- }
- // 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));
- const page = unit(frame.background);
- const target = @min(contrastOf(ink, luminance(page)), 4.5);
- var grain: f32 = 0;
- var step: f32 = 0.25 / 255.0;
- while (step <= 8.0 / 255.0) : (step += 0.25 / 255.0) {
- var up = page;
- var down = page;
- for (&up, &down) |*u, *d| {
- u.* = @min(1, u.* + step);
- d.* = @max(0, d.* - step);
- }
- if (contrastOf(ink, luminance(up)) < target - 1e-4 or contrastOf(ink, luminance(down)) < target - 1e-4) break;
- grain = step;
- }
- var caps: std.EnumArray(Scene, f32) = .initFill(1);
- caps.set(.bloom, bloom);
- caps.set(.vignette, shade);
- caps.set(.grain, grain);
- return caps;
-}
-
-test "no bundled pass at its ceiling takes a native theme's text or selection below its contrast or 4.5" {
- for (pardes.themes[0..pardes.colors.native_count]) |*theme| {
- const frame: Frame = .{ .cursor = null, .background = theme.bg orelse .{ 18, 18, 18 }, .foreground = theme.fg orelse .{ 204, 204, 204 }, .selection_foreground = theme.sel_fg, .selection_background = theme.sel_bg };
- const caps = capsOf(frame);
- for ([_][2][3]u8{ .{ frame.foreground, frame.background }, .{ frame.selection_foreground, frame.selection_background } }, 0..) |pair, i| {
- const a = luminance(unit(pair[0]));
- const b = luminance(unit(pair[1]));
- const target = @min(contrastOf(a, b), 4.5) - 1e-3;
- // Bloom at its ceiling, over both.
- const e = @min(caps.get(.bloom), 0.05);
- try std.testing.expect(contrastOf(a + e, b + e) >= target);
- // The vignette at its ceiling, over both.
- const k = 1 - @min(caps.get(.vignette), 0.28);
- try std.testing.expect(contrastOf(a * k, b * k) >= target);
- // Grain moves the page alone.
- if (i == 0) {
- var up = unit(pair[1]);
- for (&up) |*v| v.* = @min(1, v.* + caps.get(.grain));
- try std.testing.expect(contrastOf(a, luminance(up)) >= target);
- }
- }
- }
-}
-
-/// The window gained or lost the focus.
-pub fn focus(post: *Post, focused: bool) void {
- if (focused and post.uniforms.focus == 0) post.uniforms.time_focus = post.uniforms.time;
- post.uniforms.focus = @intFromBool(focused);
-}
-
-/// The pointer, in framebuffer pixels: Shadertoy's iMouse, xy where it is,
-/// zw where the last press was, negative once released.
-pub fn mouse(post: *Post, x: f32, y: f32, press: ?bool) void {
- const m = &post.uniforms.mouse;
- m[0] = x;
- m[1] = y;
- if (press) |down| {
- if (down) {
- m[2] = x;
- m[3] = y;
- } else {
- m[2] = -@abs(m[2]);
- m[3] = -@abs(m[3]);
- }
- }
-}
-
-/// Runs the passes over `source`, the finished frame, into `target`: each
-/// reads the one before, the ones between write two ping-pong textures that
-/// start cleared, and iTime and iFrame move by this one draw.
-pub fn draw(post: *Post, device: *c.SDL_GPUDevice, cmd: *c.SDL_GPUCommandBuffer, sampler: *c.SDL_GPUSampler, format: c.SDL_GPUTextureFormat, source: *c.SDL_GPUTexture, target: *c.SDL_GPUTexture, w: u32, h: u32, now_ns: u64, opaque_window: bool) !void {
- var live: usize = 0;
- for (post.passes[0..post.len]) |pass| live += @intFromBool(pass.pipeline != null);
- if (live == 0) return;
- if (live > 1 and (post.ping[0] == null or post.ping_w != w or post.ping_h != h)) {
- for (&post.ping) |*texture| {
- if (texture.*) |old| c.SDL_ReleaseGPUTexture(device, old);
- texture.* = gui.texture2d(device, format, c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER, w, h) orelse return error.GpuCreate;
- }
- post.ping_w = w;
- post.ping_h = h;
- }
- const u = &post.uniforms;
- const started = post.started_ns orelse now_ns;
- post.started_ns = started;
- const elapsed = @as(f64, @floatFromInt(now_ns -| started)) / std.time.ns_per_s;
- const delta: f32 = if (post.last_ns == 0) 0 else @floatCast(@as(f64, @floatFromInt(now_ns -| post.last_ns)) / std.time.ns_per_s);
- post.last_ns = now_ns;
- u.time = @floatCast(elapsed);
- u.time_delta = delta;
- u.frame_rate = if (delta > 0) 1 / delta else 60;
- u.resolution = .{ @floatFromInt(w), @floatFromInt(h), 1 };
- u.channel_resolution[0] = .{ @floatFromInt(w), @floatFromInt(h), 1, 0 };
- // UTC: the year, the month from 0, the day, the second of the day.
- var wall: libc.timespec = undefined;
- if (libc.clock_gettime(.REALTIME, &wall) != 0) wall.sec = 0;
- const epoch: std.time.epoch.EpochSeconds = .{ .secs = @intCast(@max(0, wall.sec)) };
- const day = epoch.getEpochDay().calculateYearDay();
- const month = day.calculateMonthDay();
- u.date = .{ @floatFromInt(day.year), @floatFromInt(month.month.numeric() - 1), @floatFromInt(month.day_index + 1), @floatFromInt(epoch.getDaySeconds().secs) };
-
- var input = source;
- var index: usize = 0;
- for (post.passes[0..post.len]) |pass| {
- const pipeline = pass.pipeline orelse continue;
- index += 1;
- const last = index == live;
- const output = if (last) target else post.ping[index % 2].?;
- var info = std.mem.zeroes(c.SDL_GPUColorTargetInfo);
- info.texture = output;
- info.load_op = if (last) c.SDL_GPU_LOADOP_DONT_CARE else c.SDL_GPU_LOADOP_CLEAR;
- info.store_op = c.SDL_GPU_STOREOP_STORE;
- // Bloom's glow first, from this pass's input, at half size and down.
- // A chain that could not be made adds no glow, and the pass is the
- // frame as it was.
- const glow = if (pass.scene == .bloom) post.bloomChain(device, cmd, sampler, input, w, h, pass.level) catch null else null;
- const pass_rp = c.SDL_BeginGPURenderPass(cmd, &info, 1, null);
- c.SDL_BindGPUGraphicsPipeline(pass_rp, pipeline);
- const bindings = [2]c.SDL_GPUTextureSamplerBinding{ .{ .texture = input, .sampler = sampler }, .{ .texture = glow orelse input, .sampler = sampler } };
- c.SDL_BindGPUFragmentSamplers(pass_rp, 0, &bindings, if (pass.scene == .bloom) 2 else 1);
- pushUniforms(cmd, u);
- var own: Own = .{
- .opaque_window = @floatFromInt(@intFromBool(opaque_window)),
- .level = @floatFromInt(pass.level),
- .scale = post.scale,
- // A user's file has no ceiling of ours, and no spared rectangles.
- .cap = if (pass.scene) |scene| (if (scene == .bloom and glow == null) 0 else post.caps.get(scene)) else 1,
- .spare_count = if (pass.scene != null) @floatFromInt(post.spare_len) else 0,
- };
- if (pass.scene != null) @memcpy(own.spare[0..post.spare_len], post.spare[0..post.spare_len]);
- c.SDL_PushGPUFragmentUniformData(cmd, 3, &own, @sizeOf(Own));
- c.SDL_DrawGPUPrimitives(pass_rp, 3, 1, 0, 0);
- c.SDL_EndGPURenderPass(pass_rp);
- input = output;
- }
- u.frame +%= 1;
-}
-
-/// ghostty's block as the prefix cuts it (SDL GPU binds at most 4 KiB of a
-/// block): the globals up to the palette, the palette, the colours after it,
-/// each a slice of the one struct, at set 3 bindings 0 to 2.
-fn pushUniforms(cmd: *c.SDL_GPUCommandBuffer, u: *const Uniforms) void {
- const bytes = std.mem.asBytes(u);
- const palette = @offsetOf(Uniforms, "palette");
- const colors = @offsetOf(Uniforms, "background_color");
- c.SDL_PushGPUFragmentUniformData(cmd, 0, bytes.ptr, @intCast(palette));
- c.SDL_PushGPUFragmentUniformData(cmd, 1, bytes.ptr + palette, @intCast(colors - palette));
- c.SDL_PushGPUFragmentUniformData(cmd, 2, bytes.ptr + colors, @intCast(@sizeOf(Uniforms) - colors));
-}
-
-test "each slice of the uniforms fits the 4 KiB SDL GPU binds of a block" {
- try std.testing.expect(@offsetOf(Uniforms, "palette") <= 4096);
- try std.testing.expect(@offsetOf(Uniforms, "background_color") - @offsetOf(Uniforms, "palette") <= 4096);
- try std.testing.expect(@sizeOf(Uniforms) - @offsetOf(Uniforms, "background_color") <= 4096);
- try std.testing.expect(@sizeOf(Own) <= 4096);
-}
-
-/// Bloom's glow of `input` (w x h): a bright pass and dual Kawase steps
-/// down to 1/2^n of the frame and back up to a half, in float textures;
-/// the half-size result, for the composite (shaders/post/bloom.glsl).
-fn bloomChain(post: *Post, device: *c.SDL_GPUDevice, cmd: *c.SDL_GPUCommandBuffer, sampler: *c.SDL_GPUSampler, input: *c.SDL_GPUTexture, w: u32, h: u32, level: u8) !*c.SDL_GPUTexture {
- const down = post.bloom_down orelse return error.GpuCreate;
- const up = post.bloom_up orelse return error.GpuCreate;
- const steps = bloom_steps[std.math.clamp(level, 1, 3) - 1];
- if (post.bloom_tex[0] == null or post.bloom_w != w or post.bloom_h != h) {
- for (&post.bloom_tex, 0..) |*texture, i| {
- if (texture.*) |old| c.SDL_ReleaseGPUTexture(device, old);
- texture.* = gui.texture2d(device, bloom_format, c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER, @max(1, w >> @intCast(i + 1)), @max(1, h >> @intCast(i + 1))) orelse return error.GpuCreate;
- }
- post.bloom_w = w;
- post.bloom_h = h;
- }
- const Step = extern struct { texels: [4]f32, pass: [4]f32 };
- const size = struct {
- fn of(full: u32, i: usize) f32 {
- return @floatFromInt(if (i == 0) full else @max(1, full >> @intCast(i)));
- }
- };
- // Down: the frame (0) to 1, 1 to 2, ...; the first through the bright
- // pass (a channel's linear peak over 0.6 to 0.75, by level).
- const threshold: f32 = switch (std.math.clamp(level, 1, 3)) {
- 1 => 0.75,
- 2 => 0.7,
- else => 0.6,
- };
- // Only what is brighter than the page glows: on a light page, where the
- // ground itself would pass, nothing does.
- const page_peak = peak: {
- var peak: f32 = 0;
- for (post.uniforms.background_color[0..3]) |v| peak = @max(peak, if (v <= 0.04045) v / 12.92 else std.math.pow(f32, (v + 0.055) / 1.055, 2.4));
- break :peak peak;
- };
- for (0..steps) |i| {
- const from = if (i == 0) input else post.bloom_tex[i - 1].?;
- const to = post.bloom_tex[i].?;
- const params: Step = .{
- .texels = .{ 1 / size.of(w, i), 1 / size.of(h, i), 1 / size.of(w, i + 1), 1 / size.of(h, i + 1) },
- .pass = .{ if (i == 0) @max(threshold, page_peak + 0.15) else 0, 0.25, 0, 0 },
- };
- bloomStep(cmd, down, sampler, from, to, &params, @sizeOf(Step));
- }
- // Up: each level into the one above it, back to the half.
- var i: usize = steps - 1;
- while (i > 0) : (i -= 1) {
- const params: Step = .{
- .texels = .{ 1 / size.of(w, i + 1), 1 / size.of(h, i + 1), 1 / size.of(w, i), 1 / size.of(h, i) },
- .pass = @splat(0),
- };
- bloomStep(cmd, up, sampler, post.bloom_tex[i].?, post.bloom_tex[i - 1].?, &params, @sizeOf(Step));
- }
- return post.bloom_tex[0].?;
-}
-
-fn bloomStep(cmd: *c.SDL_GPUCommandBuffer, pipeline: *Pipeline, sampler: *c.SDL_GPUSampler, from: *c.SDL_GPUTexture, to: *c.SDL_GPUTexture, params: *const anyopaque, len: u32) void {
- var info = std.mem.zeroes(c.SDL_GPUColorTargetInfo);
- info.texture = to;
- info.load_op = c.SDL_GPU_LOADOP_DONT_CARE;
- info.store_op = c.SDL_GPU_STOREOP_STORE;
- const rp = c.SDL_BeginGPURenderPass(cmd, &info, 1, null);
- c.SDL_BindGPUGraphicsPipeline(rp, pipeline);
- const binding = c.SDL_GPUTextureSamplerBinding{ .texture = from, .sampler = sampler };
- c.SDL_BindGPUFragmentSamplers(rp, 0, &binding, 1);
- c.SDL_PushGPUFragmentUniformData(cmd, 0, params, len);
- c.SDL_DrawGPUPrimitives(rp, 3, 1, 0, 0);
- c.SDL_EndGPURenderPass(rp);
-}
-
-pub fn deinit(post: *Post, gpa: std.mem.Allocator, device: *c.SDL_GPUDevice) void {
- for (post.bloom_tex) |texture| if (texture) |t| c.SDL_ReleaseGPUTexture(device, t);
- for ([_]?*Pipeline{ post.bloom_down, post.bloom_up }) |pipeline| if (pipeline) |p| c.SDL_ReleaseGPUGraphicsPipeline(device, p);
- for (post.passes[0..post.len]) |pass| {
- if (pass.scene == null) if (pass.pipeline) |pipeline| c.SDL_ReleaseGPUGraphicsPipeline(device, pipeline);
- gpa.free(pass.path);
- }
- for (post.bundled.values) |pipeline| if (pipeline) |p| c.SDL_ReleaseGPUGraphicsPipeline(device, p);
- for (post.ping) |texture| if (texture) |t| c.SDL_ReleaseGPUTexture(device, t);
-}
-
-/// ghostty 1.4.0's Uniforms (src/renderer/shadertoy.zig), copied: the offsets
-/// ours must match. Its last two names are swapped against its own GLSL.
-const GhosttyUniforms = extern struct {
- resolution: [3]f32 align(16),
- time: f32 align(4),
- time_delta: f32 align(4),
- frame_rate: f32 align(4),
- frame: i32 align(4),
- channel_time: [4][4]f32 align(16),
- channel_resolution: [4][4]f32 align(16),
- mouse: [4]f32 align(16),
- date: [4]f32 align(16),
- sample_rate: f32 align(4),
- current_cursor: [4]f32 align(16),
- previous_cursor: [4]f32 align(16),
- current_cursor_color: [4]f32 align(16),
- previous_cursor_color: [4]f32 align(16),
- current_cursor_style: i32 align(4),
- previous_cursor_style: i32 align(4),
- cursor_visible: i32 align(4),
- cursor_change_time: f32 align(4),
- time_focus: f32 align(4),
- focus: i32 align(4),
- palette: [256][4]f32 align(16),
- background_color: [4]f32 align(16),
- foreground_color: [4]f32 align(16),
- cursor_color: [4]f32 align(16),
- cursor_text: [4]f32 align(16),
- selection_background_color: [4]f32 align(16),
- selection_foreground_color: [4]f32 align(16),
-};
-
-test "the uniform block is ghostty's, offset for offset, and the prefix names it in that order" {
- const ours = @typeInfo(Uniforms).@"struct";
- const theirs = @typeInfo(GhosttyUniforms).@"struct";
- try std.testing.expectEqual(theirs.field_names.len, ours.field_names.len);
- try std.testing.expectEqual(@sizeOf(GhosttyUniforms), @sizeOf(Uniforms));
- inline for (ours.field_names, ours.field_types, theirs.field_names, theirs.field_types) |a, a_type, b, b_type| {
- try std.testing.expectEqual(@offsetOf(GhosttyUniforms, b), @offsetOf(Uniforms, a));
- try std.testing.expectEqual(b_type, a_type);
- }
- // By NAME: iSelectionForegroundColor sits where ghostty's Zig says
- // selection_background, which is where its GLSL puts the foreground.
- try std.testing.expectEqual(@offsetOf(GhosttyUniforms, "selection_background_color"), @offsetOf(Uniforms, "selection_foreground_color"));
- // The prefix's block, member by member, in ghostty's GLSL names and types.
- const glsl = [_]struct { []const u8, []const u8 }{
- .{ "vec3", "iResolution" }, .{ "float", "iTime" }, .{ "float", "iTimeDelta" },
- .{ "float", "iFrameRate" }, .{ "int", "iFrame" }, .{ "float", "iChannelTime[4]" },
- .{ "vec3", "iChannelResolution[4]" }, .{ "vec4", "iMouse" }, .{ "vec4", "iDate" },
- .{ "float", "iSampleRate" }, .{ "vec4", "iCurrentCursor" }, .{ "vec4", "iPreviousCursor" },
- .{ "vec4", "iCurrentCursorColor" }, .{ "vec4", "iPreviousCursorColor" }, .{ "int", "iCurrentCursorStyle" },
- .{ "int", "iPreviousCursorStyle" }, .{ "int", "iCursorVisible" }, .{ "float", "iTimeCursorChange" },
- .{ "float", "iTimeFocus" }, .{ "int", "iFocus" }, .{ "vec3", "iPalette[256]" },
- .{ "vec3", "iBackgroundColor" }, .{ "vec3", "iForegroundColor" }, .{ "vec3", "iCursorColor" },
- .{ "vec3", "iCursorText" }, .{ "vec3", "iSelectionForegroundColor" }, .{ "vec3", "iSelectionBackgroundColor" },
- };
- try std.testing.expectEqual(ours.field_names.len, glsl.len);
- // Its three blocks (Globals, Palette, Colors) read as one, in order.
- const start = std.mem.indexOf(u8, prefix, "uniform Globals {").?;
- const end = std.mem.indexOf(u8, prefix, "uniform PardesPost {").?;
- var lines = std.mem.tokenizeScalar(u8, prefix[start..end], '\n');
- var n: usize = 0;
- while (lines.next()) |line| {
- if (!std.mem.startsWith(u8, line, " uniform ")) continue;
- var words = std.mem.tokenizeAny(u8, line, " ;");
- try std.testing.expectEqualStrings("uniform", words.next().?);
- try std.testing.expectEqualStrings(glsl[n][0], words.next().?);
- try std.testing.expectEqualStrings(glsl[n][1], words.next().?);
- n += 1;
- }
- try std.testing.expectEqual(glsl.len, n);
- // Each block starts where its first member is in the one struct.
- try std.testing.expect(std.mem.indexOf(u8, prefix, "uniform Palette {\n uniform vec3 iPalette[256];\n};") != null);
-}
-
-test "a moved cursor becomes the previous one, stamped with the time of the move" {
- var post: Post = .{};
- const frame: Frame = .{ .cursor = .{ .x0 = 10, .y0 = 20, .x1 = 11, .y1 = 40, .rgb = .{ 255, 0, 0 }, .text = .{ 0, 0, 0 }, .bar = true }, .background = .{ 0, 0, 0 }, .foreground = .{ 255, 255, 255 }, .selection_foreground = .{ 1, 2, 3 }, .selection_background = .{ 4, 5, 6 } };
- post.uniforms.time = 1.5;
- post.describe(frame);
- // Left, BOTTOM edge, width, height, in framebuffer pixels, y down.
- try std.testing.expectEqual([4]f32{ 10, 40, 1, 20 }, post.uniforms.current_cursor);
- try std.testing.expectEqual(@as(i32, 2), post.uniforms.current_cursor_style);
- try std.testing.expectEqual(@as(f32, 1.5), post.uniforms.cursor_change_time);
- post.uniforms.time = 2;
- post.describe(frame);
- try std.testing.expectEqual(@as(f32, 1.5), post.uniforms.cursor_change_time);
- var moved = frame;
- moved.cursor.?.x0 = 20;
- moved.cursor.?.x1 = 21;
- post.describe(moved);
- try std.testing.expectEqual([4]f32{ 10, 40, 1, 20 }, post.uniforms.previous_cursor);
- try std.testing.expectEqual(@as(f32, 2), post.uniforms.cursor_change_time);
- try std.testing.expectEqual([4]f32{ 1.0 / 255.0, 2.0 / 255.0, 3.0 / 255.0, 1 }, post.uniforms.selection_foreground_color);
-}
-
-test "a still pass asks for no idle frames; one that reads the clock does" {
- var post: Post = .{};
- const fake: *Pipeline = @ptrFromInt(0x1000);
- post.passes[0] = .{ .scene = .bloom, .level = 2, .pipeline = fake };
- post.len = 1;
- try std.testing.expect(!post.animating(.on) and !post.animating(.always));
- post.passes[1] = .{ .scene = .crt, .level = 2, .pipeline = fake, .animated = true };
- post.len = 2;
- try std.testing.expect(post.animating(.on) and post.animating(.always) and !post.animating(.off));
- // Unfocused, `on` rests.
- post.uniforms.focus = 0;
- try std.testing.expect(!post.animating(.on) and post.animating(.always));
-}
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 28f5e695..2c2f53c4 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -12,9 +12,7 @@ const config = @import("../config.zig");
const look = @import("../look.zig");
const message = pardes.Messages.Message;
const file_watch = @import("../file_watch.zig");
-const ShaderBuild = @import("../ShaderBuild.zig");
const deck = @import("deck.zig");
-const Post = @import("Post.zig");
const pet = @import("pet.zig");
const fonts = @import("../fonts.zig"); // the fallback faces
const selection_pipe = @import("../selection_pipe.zig");
@@ -806,7 +804,7 @@ const Pty = struct {
const Queue = host_io.Inbox;
/// Wakes a blocking SDL_WaitEventTimeout from another thread: a push to
-/// the queue, a link's message, a post chain's compile done (ShaderBuild).
+/// the queue, a link's message.
fn sdlWake(_: ?*anyopaque) void {
var sev = std.mem.zeroes(c.SDL_Event);
sev.type = c.SDL_EVENT_USER;
@@ -1181,13 +1179,6 @@ const Gui = struct {
blink_due: bool = false,
no_blink: bool = false,
cursor_quad_alpha: f32 = 0,
- scene_tex: ?*c.SDL_GPUTexture = null,
- scene_tex_w: u32 = 0,
- scene_tex_h: u32 = 0,
- scene_failures: u8 = 0,
- scene_target_failed: bool = false,
- /// The post chain, run over the frame in scene_tex.
- post: Post = .{},
pointer_present: bool = false,
arrow_cursor: ?*c.SDL_Cursor = null,
link_cursor: ?*c.SDL_Cursor = null,
@@ -1237,8 +1228,8 @@ const Gui = struct {
};
/// The Gui's fields that are each window's own, one a view (views.zig):
-/// the window and its presenting, its scroll and glide, its scene and post
-/// chain, its pointer, its blink, its images as presented, its capture. The
+/// the window and its presenting, its scroll and glide, its pointer, its
+/// blink, its images as presented, its capture. The
/// device, the atlas, the font and the pipelines are every window's. The
/// Gui holds the live window's; the others wait in `Shell.windows`.
const window_fields = [_][:0]const u8{
@@ -1247,8 +1238,7 @@ const window_fields = [_][:0]const u8{
"scroll_body_h", "scroll_held_px", "scroll_col", "scroll_row", "scroll_delta",
"scroll_lag", "scroll_edge", "scroll_edge_len", "scroll_notch", "program_wheel",
"glide", "pace_ns", "sel_glow", "hover_glow", "frame_arrival_ns",
- "blink_due", "cursor_quad_alpha", "scene_tex", "scene_tex_w", "scene_tex_h",
- "scene_failures", "scene_target_failed", "post", "pointer_present", "pointer_shape",
+ "blink_due", "cursor_quad_alpha", "pointer_present", "pointer_shape",
"pointer_cell", "presented_images", "prepared_images", "touch",
"live_ctrl", "live_alt", "applied_window_opacity", "capture_tex", "capture_tex_w",
"capture_tex_h", "capture_xfer", "capture_xfer_size", "captured", "capture_dir",
@@ -1288,10 +1278,8 @@ fn freshWindow(g: *Gui) void {
/// What a window held of its own let go (closeWindow lets the window go).
fn releaseWindowParts(g: *Gui, gpa: std.mem.Allocator) void {
- if (g.scene_tex) |texture| c.SDL_ReleaseGPUTexture(g.device, texture);
if (g.capture_tex) |texture| c.SDL_ReleaseGPUTexture(g.device, texture);
if (g.capture_xfer) |transfer| c.SDL_ReleaseGPUTransferBuffer(g.device, transfer);
- g.post.deinit(gpa, g.device);
g.glide.deinit(gpa);
gpa.free(g.scroll_edge);
g.presented_images.deinit(gpa);
@@ -1903,7 +1891,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
if (g.vxfer) |transfer| c.SDL_ReleaseGPUTransferBuffer(device, transfer);
if (g.image_vbuf) |buffer| c.SDL_ReleaseGPUBuffer(device, buffer);
if (g.image_vxfer) |transfer| c.SDL_ReleaseGPUTransferBuffer(device, transfer);
- if (g.scene_tex) |texture| c.SDL_ReleaseGPUTexture(device, texture);
if (g.capture_tex) |texture| c.SDL_ReleaseGPUTexture(device, texture);
if (g.capture_xfer) |transfer| c.SDL_ReleaseGPUTransferBuffer(device, transfer);
if (g.gamepad) |pad| c.SDL_CloseGamepad(pad);
@@ -1920,7 +1907,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
g.prepared_images.deinit(gpa);
g.cover.deinit(gpa);
g.decor.deinit(gpa);
- g.post.deinit(gpa, device);
}
defer c.SDL_ReleaseGPUGraphicsPipeline(device, image_pipeline);
defer if (g.font_bytes.len != 0) gpa.free(g.font_bytes); // set by Font, if it ran
@@ -2082,7 +2068,6 @@ fn localSession(
.test_hz = if (std.c.getenv("PARDES_TEST_HZ")) |hz| @max(1, std.fmt.parseInt(u64, std.mem.span(hz), 10) catch 60) else 60,
};
defer shell.shutdownPtys();
- defer shell.shaders.deinit(gpa, inotify_fd, &watches);
// A virtual clock never blinks: goldens and feel series hold still.
g.no_blink = shell.test_clock != null;
frame_probe = &core.frames;
@@ -2388,7 +2373,6 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
.test_mode = test_mode,
.remote = &client,
};
- defer shell.shaders.deinit(gpa, -1, &watches);
g.no_blink = test_mode;
defer g.hit_core = null;
_ = c.SDL_StartTextInput(g.window);
@@ -2421,10 +2405,6 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
while (!link.quit) {
core.frames.period_ns = refreshNs(g);
syncLigatures(g, core);
- {
- var passes: [Post.max]ShaderBuild.Pass = undefined;
- g.post.sync(gpa, g.device, g.swapchain_format, shell.shaders.view(&core.settings.post, &passes), shell.shaders.revision, core);
- }
var own: OwnView = .{ .g = g, .in = &in, .s = &shell, .pointer = drew };
r.within(&own, OwnView.run);
client.feed();
@@ -2859,16 +2839,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
},
else => {},
}
- // What the post chain sees of the pointer and the focus.
switch (sev.type) {
- c.SDL_EVENT_MOUSE_MOTION => {
- const at = windowPointToPixels(windowGeometry(g.window), sev.motion.x, sev.motion.y);
- g.post.mouse(at.x, at.y, null);
- },
- c.SDL_EVENT_MOUSE_BUTTON_DOWN, c.SDL_EVENT_MOUSE_BUTTON_UP => {
- const at = windowPointToPixels(windowGeometry(g.window), sev.button.x, sev.button.y);
- g.post.mouse(at.x, at.y, sev.button.down);
- },
c.SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED => {
updateDisplayScale(g.window);
// Underlines are drawn into the glyphs a logical pixel thick.
@@ -2877,8 +2848,6 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
r.link.dirty = true;
} else in.core.needs_frame = true;
},
- c.SDL_EVENT_WINDOW_FOCUS_GAINED => g.post.focus(true),
- c.SDL_EVENT_WINDOW_FOCUS_LOST => g.post.focus(false),
else => {},
}
switch (sev.type) {
@@ -3216,10 +3185,9 @@ test "tagline pointer mapping retains physical grips and carries logical text co
try std.testing.expectEqual(pardes.TagKind.workspace, topbar.tag_hit.?.kind);
}
-test "a click at the window's corner lands in the corner cell with a post chain on" {
+test "a click at the window's corner lands in the corner cell" {
const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
defer core.deinit();
- try std.testing.expect(core.settings.post.set(.crt, "", true));
var g = testGui(10, 20, 6, 12);
const geometry: WindowGeometry = .{ .window_w = 400, .window_h = 240, .pixel_w = 800, .pixel_h = 480 };
const last = mouseCellWithGeometry(&g, core, 399.9, 239.9, geometry);
@@ -3230,9 +3198,6 @@ test "a click at the window's corner lands in the corner cell with a post chain
try std.testing.expectEqual(@as(u16, 0), first.row);
}
-/// Where a window point lands: the cell drawn under it. Input is identity:
-/// no post pass moves a pixel (the bundled Crt has no barrel), so a click
-/// is exactly where it looks.
/// A wheel turned over grid cell `mc` (SDL's sign: up positive): the
/// part of dispatch after the pointer is placed, so a test can turn it.
fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void {
@@ -3448,8 +3413,6 @@ const Shell = struct {
pipe_tasks: *PipeTasks,
inotify_fd: c_int,
watches: *file_watch.Table,
- /// The post chain's files as SPIR-V.
- shaders: ShaderBuild = .{},
threads_ok: bool = false,
test_mode: bool = false,
feed: StdinFeed = .{},
@@ -3901,7 +3864,6 @@ const Shell = struct {
.window => if (s.gui != null) s.openAnotherWindow(null) else s.openTheWindow(),
.adopted => |a| s.adoptions.adoptShell(s.core, a.pid, a.fd),
};
- if (check_files) s.shaders.recheck();
if (check_files and file_watch.reloadChanged(s.core, s.io, s.gpa, s.watches))
s.queue.push(.files_changed);
}
@@ -3931,20 +3893,14 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void {
// shell's queue raises for a terminal's output, a completion, a file
// system request. What the shell moves or times itself polls every
// frame: a smooth scroll, a gamepad's sticks, the test stdin feed,
- // a post chain that moves on its own (ShaderAnimation), a present
- // to retry. A minimized window sleeps through the core's animation
+ // a present to retry. A minimized window sleeps through the core's animation
// too: nothing shows it, and it is caught up at once when the window
// is back.
- const polls = g.scroll_lag != 0 or g.scroll_delta != 0 or g.scroll_notch != 0 or g.glide.moving() or g.gamepad != null or s.test_mode or core.needs_frame or
- g.post.animating(core.settings.shader_animation);
+ const polls = g.scroll_lag != 0 or g.scroll_delta != 0 or g.scroll_notch != 0 or g.glide.moving() or g.gamepad != null or s.test_mode or core.needs_frame;
const minimized = !s.test_mode and c.SDL_GetWindowFlags(g.window) & (c.SDL_WINDOW_MINIMIZED | c.SDL_WINDOW_OCCLUDED) != 0;
// A latency trace is fed on stdin, whose poll below paces the loop:
// waiting here too would make every tick cost two frames.
- // A chain that moves on its own wakes once a display refresh.
- const poll_ms: c_int = if (g.post.animating(core.settings.shader_animation))
- @intCast(@max(1, refreshNs(g) / std.time.ns_per_ms))
- else
- 16;
+ const poll_ms: c_int = 16;
const waited: c_int = if (latency_fd >= 0) 0 else if (minimized) -1 else if (timeout_ms != 0) @min(@as(c_int, @intCast(@min(timeout_ms, std.math.maxInt(c_int)))), if (polls) poll_ms else std.math.maxInt(c_int)) else if (polls) poll_ms else -1;
// The cursor's blink is the shell's to time (Chrome.cursor_idle_ms):
// a frame a loop through an edge, else a wake at the next one; none
@@ -4161,17 +4117,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, 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);
- }
if (s.test_mode) writeTestStatus(g, core, s.presented);
- // Between the core's frames, a chain that moves on its own redraws
- // alone, once a refresh of the display the window is on (a millisecond
- // early is on time: the wait that paces it is in whole milliseconds).
- if (g.post.animating(core.settings.shader_animation) and !core.needs_frame and s.presented and
- c.SDL_GetTicksNS() -| g.post.last_ns + std.time.ns_per_ms >= refreshNs(g)) redrawPost(g, s.gpa);
// A blink edge: the last frame again, the cursor's alpha moved on.
if (g.blink_due and !core.needs_frame and s.presented) if (s.surface) |frame| {
g.blink_due = false;
@@ -4350,8 +4296,6 @@ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) void {
const frame = surface;
s.surface = frame;
g.frame_arrival_ns = monoNs();
- const scene_requested = g.post.ready();
- if (!scene_requested) g.scene_failures = 0;
s.presented = renderFrame(g, s.gpa, core, frame) catch |err| blk: {
log.err("render: {t}", .{err});
break :blk false;
@@ -4360,16 +4304,6 @@ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) void {
// the next event. A few retries only: a minimized window never gets one.
s.skipped_presents = if (s.presented) 0 else s.skipped_presents +| 1;
if (!s.presented and s.skipped_presents <= 3) core.present_skipped = true;
- if (g.scene_target_failed) {
- g.scene_failures +|= 1;
- log.err("scene target unavailable (attempt {d}/3)", .{g.scene_failures});
- if (g.scene_failures >= 3) {
- // ponytail: a client's window keeps asking (its core is the
- // session's to change).
- if (s.remote == null) core.disableSceneEffects();
- g.scene_failures = 0;
- }
- } else if (scene_requested and s.presented) g.scene_failures = 0;
}
fn postPresent(ctx: ?*anyopaque) void {
@@ -5852,7 +5786,6 @@ fn renderFrame(
};
if (cursor) |value| _ = c.SDL_SetCursor(value);
}
- g.scene_target_failed = false;
g.words.memo = .{}; // positional, and this frame's cells are new
const cmd = c.SDL_AcquireGPUCommandBuffer(g.device) orelse return false;
var command_consumed = false;
@@ -5870,15 +5803,6 @@ fn renderFrame(
const win_w: f32 = @floatFromInt(sw);
const win_h: f32 = @floatFromInt(sh);
- // The post chain runs from the scene texture, over a local frame or an
- // attached session's alike.
- var scene_on = g.post.ready();
- if (scene_on) ensureSceneTexture(g, sw, sh) catch {
- g.scene_target_failed = true;
- scene_on = false;
- };
- const scene: *c.SDL_GPUTexture = if (scene_on) g.scene_tex.? else target;
-
// The frame's CPU side: groups, decor, cover and every instance, up to
// their upload.
const build_zone = tracy.zone(@src(), "gui frame build");
@@ -5962,7 +5886,7 @@ fn renderFrame(
const page = chrome.page orelse bg_default;
const background_opacity = backgroundOpacity(g.applied_window_opacity);
var color_target = std.mem.zeroes(c.SDL_GPUColorTargetInfo);
- color_target.texture = scene;
+ color_target.texture = target;
color_target.clear_color = .{
.r = @as(f32, @floatFromInt(page[0])) / 255.0 * background_opacity,
.g = @as(f32, @floatFromInt(page[1])) / 255.0 * background_opacity,
@@ -6276,25 +6200,6 @@ fn renderFrame(
drawOverlayGpu(g, cmd, rp, overlay_count);
c.SDL_EndGPURenderPass(rp);
- if (scene_on) {
- var boxes: [max_cursors]CursorBox = undefined;
- const cursors = if (cursors_shown) cursorBoxes(g, surface, layout, win_h, &boxes) else 0;
- var spare: [Post.max_spare][4]f32 = undefined;
- g.post.describe(.{
- .cursor = if (cursors > 0) boxes[0] else null,
- .spare = spare[0..postSpare(surface, layout, &spare)],
- .background = chrome.page orelse bg_default,
- .foreground = chrome.fg orelse fg_default,
- .selection_foreground = core.theme().sel_fg,
- .selection_background = core.theme().sel_bg,
- });
- const chain_zone = tracy.zone(@src(), "post chain");
- defer chain_zone.end();
- g.post.scale = display_scale;
- g.post.draw(g.device, cmd, g.linear_sampler, g.swapchain_format, g.scene_tex.?, target, sw, sh, c.SDL_GetTicksNS(), background_opacity >= 1) catch {
- g.scene_target_failed = true;
- };
- }
command_consumed = true;
const shown = try finishFrame(g, gpa, cmd, frame_target, if (groups.tracks != 0) groups.items[1].track.?.frame else null);
if (shown and groups.tracks == 0) rememberPresentedImages(g, gpa, surface);
@@ -6340,26 +6245,6 @@ fn finishFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, ta
return c.SDL_SubmitGPUCommandBuffer(cmd);
}
-/// Redraw level A (docs §5.5): the post chain alone, over the frame the core
-/// last drew, for a pass that moves on its own. No core render, no cell.
-fn redrawPost(g: *Gui, gpa: std.mem.Allocator) void {
- const scene = g.scene_tex orelse return;
- const cmd = c.SDL_AcquireGPUCommandBuffer(g.device) orelse return;
- const target = (acquireTarget(g, cmd, g.scene_tex_w, g.scene_tex_h) catch null) orelse {
- _ = c.SDL_SubmitGPUCommandBuffer(cmd);
- return;
- };
- // A window the retained frame no longer fits waits for the core's.
- if (target.w != g.scene_tex_w or target.h != g.scene_tex_h) {
- _ = c.SDL_SubmitGPUCommandBuffer(cmd);
- return;
- }
- const zone = tracy.zone(@src(), "post chain redraw");
- g.post.draw(g.device, cmd, g.linear_sampler, g.swapchain_format, scene, target.texture, target.w, target.h, c.SDL_GetTicksNS(), backgroundOpacity(g.applied_window_opacity) >= 1) catch {};
- zone.end();
- _ = finishFrame(g, gpa, cmd, target, null) catch {};
-}
-
const ResolvedCell = struct {
slot: Slot,
fg: [3]u8,
@@ -8105,15 +7990,6 @@ pub fn texture2d(device: *c.SDL_GPUDevice, format: c.SDL_GPUTextureFormat, usage
return c.SDL_CreateGPUTexture(device, &info);
}
-fn ensureSceneTexture(g: *Gui, width: u32, height: u32) !void {
- if (g.scene_tex != null and g.scene_tex_w == width and g.scene_tex_h == height) return;
- const next = texture2d(g.device, g.swapchain_format, c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER, width, height) orelse return error.GpuCreate;
- if (g.scene_tex) |texture| c.SDL_ReleaseGPUTexture(g.device, texture);
- g.scene_tex = next;
- g.scene_tex_w = width;
- g.scene_tex_h = height;
-}
-
fn ensureCaptureTexture(g: *Gui, width: u32, height: u32) !void {
if (g.capture_tex != null and g.capture_tex_w == width and g.capture_tex_h == height) return;
const next = texture2d(g.device, g.swapchain_format, c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, width, height) orelse return error.GpuCreate;
@@ -9925,47 +9801,7 @@ test "a body tells its first line, and lapis's dots under it move a quarter as f
try std.testing.expectEqual(@as(f32, 0), decor.parallaxAt(900, 10));
}
-/// What a bundled post pass leaves alone (Post.Frame.spare), in window
-/// pixels: every tag with its grip, the column and workspace tags, and the
-/// notices, the chrome the focus indicators live in. A grip, the gap after
-/// it and the tag beside it are one rectangle; past the list's end the last
-/// grows to cover the rest.
-fn postSpare(surface: *const pardes.Surface, layout: CellLayout, out: *[Post.max_spare][4]f32) usize {
- var n: usize = 0;
- for (surface.regionList()) |region| {
- switch (region.kind) {
- .grip, .tag, .notice, .column_grip, .column_tag, .workspace_tag => {},
- else => continue,
- }
- if (region.rect.w == 0 or region.rect.h == 0) continue;
- const rect: [4]f32 = .{
- @as(f32, @floatFromInt(region.rect.x)) * layout.w,
- @as(f32, @floatFromInt(region.rect.y)) * layout.h,
- @as(f32, @floatFromInt(region.rect.x + region.rect.w)) * layout.w,
- @as(f32, @floatFromInt(region.rect.y + region.rect.h)) * layout.h,
- };
- const joined = for (out[0..n]) |*other| {
- // The same rows, a gap cell or two apart (a grip, the gap after
- // it, its tag): one band.
- const gap = 2 * layout.w + 0.5;
- if (other[1] == rect[1] and other[3] == rect[3] and rect[0] <= other[2] + gap and other[0] <= rect[2] + gap) {
- other.* = .{ @min(other[0], rect[0]), rect[1], @max(other[2], rect[2]), rect[3] };
- break true;
- }
- } else false;
- if (joined) continue;
- if (n == out.len) {
- const last = &out[n - 1];
- last.* = .{ @min(last[0], rect[0]), @min(last[1], rect[1]), @max(last[2], rect[2]), @max(last[3], rect[3]) };
- continue;
- }
- out[n] = rect;
- n += 1;
- }
- return n;
-}
-
-const CursorBox = Post.Frame.Cursor;
+const CursorBox = struct { x0: f32, y0: f32, x1: f32, y1: f32, rgb: [3]u8, bar: bool };
const max_cursors = 1 + pardes.MAX_PANES + pardes.MAX_TAG_LAYERS;
/// Where the frame draws the focused caret, its top in grid rows: from its
@@ -9996,7 +9832,6 @@ fn caretRide(g: *const Gui, surface: *const pardes.Surface) f32 {
/// is an eighth of its cell wide, a block the whole cell.
fn cursorBoxes(g: *const Gui, surface: *const pardes.Surface, layout: CellLayout, win_h: f32, out: *[max_cursors]CursorBox) usize {
const chrome = &surface.chrome;
- const page = chrome.page orelse bg_default;
var n: usize = 0;
if (surface.cursor) |cursor| {
if (cursor.x < surface.cols and cursor.y < surface.rows and bodyLayerIn(surface.bodyLayers(), cursor.x, cursor.y) == null and tagLayerIn(surface.tagLayers(), cursor.x, cursor.y) == null) {
@@ -10006,7 +9841,7 @@ fn cursorBoxes(g: *const Gui, surface: *const pardes.Surface, layout: CellLayout
const height = std.math.clamp(if (role == .tagline) @as(f32, @floatFromInt(g.tagline_height)) else layout.h, 1.0, layout.h);
const x0 = @as(f32, @floatFromInt(cursor.x)) * layout.w;
const y0 = @as(f32, @floatFromInt(cursor.y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(cursor.y, win_h, @intFromFloat(layout.h), @intFromFloat(height))));
- out[n] = .{ .x0 = x0, .y0 = y0, .x1 = x0 + if (cursor.bar) @max(dp(1), width / 8.0) else width, .y1 = y0 + height, .rgb = cursorColor(chrome, cell, role), .text = page, .bar = cursor.bar };
+ out[n] = .{ .x0 = x0, .y0 = y0, .x1 = x0 + if (cursor.bar) @max(dp(1), width / 8.0) else width, .y1 = y0 + height, .rgb = cursorColor(chrome, cell, role), .bar = cursor.bar };
n += 1;
}
}
@@ -10023,7 +9858,7 @@ fn cursorBoxes(g: *const Gui, surface: *const pardes.Surface, layout: CellLayout
const width: f32 = if (role == .tagline) @floatFromInt(g.tagline_width) else layout.w;
const x = left + @as(f32, @floatFromInt(cursor.x)) * width;
const cell = &layer.cells[@as(usize, cursor.y) * layer.cols + cursor.x];
- out[n] = .{ .x0 = x, .y0 = top, .x1 = x + if (cursor.bar) @max(dp(1), width / 8) else width, .y1 = @min(bottom, top + height), .rgb = cursorColor(chrome, cell, role), .text = page, .bar = cursor.bar };
+ out[n] = .{ .x0 = x, .y0 = top, .x1 = x + if (cursor.bar) @max(dp(1), width / 8) else width, .y1 = @min(bottom, top + height), .rgb = cursorColor(chrome, cell, role), .bar = cursor.bar };
n += 1;
}
for (surface.tagLayers()) |*layer| {
@@ -10034,7 +9869,7 @@ fn cursorBoxes(g: *const Gui, surface: *const pardes.Surface, layout: CellLayout
const span = layer.caretSpan(cursor.x, layout.w, width, if (cursor.bar) @max(dp(1), width / 8) else width);
const y = layer.viewport.y + cursor.y;
const top = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, win_h, g.cell_h, g.tagline_height)));
- out[n] = .{ .x0 = span[0], .y0 = top, .x1 = span[1], .y1 = top + @as(f32, @floatFromInt(g.tagline_height)), .rgb = cursorColor(chrome, &layer.cells[@as(usize, cursor.y) * layer.cols + cursor.x], .tagline), .text = page, .bar = cursor.bar };
+ out[n] = .{ .x0 = span[0], .y0 = top, .x1 = span[1], .y1 = top + @as(f32, @floatFromInt(g.tagline_height)), .rgb = cursorColor(chrome, &layer.cells[@as(usize, cursor.y) * layer.cols + cursor.x], .tagline), .bar = cursor.bar };
n += 1;
}
return n;
diff --git a/src/main.zig b/src/main.zig
index 4a3fbe8d..777673bf 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1082,7 +1082,6 @@ test {
_ = @import("locations.zig");
_ = @import("fs.zig");
_ = @import("wire.zig");
- _ = @import("ShaderBuild.zig");
_ = @import("vaxis_input.zig");
_ = @import("daemon.zig");
_ = @import("9p_io.zig");
diff --git a/src/pardes.zig b/src/pardes.zig
index db5c0c25..415424b3 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -603,13 +603,6 @@ test "startup config runs builtin lines in order and isolates bad lines" {
};
}
-test "a post chain keeps no core clock running: the shell animates it" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- try std.testing.expect(p.settings.post.set(.crt, "", true));
- try std.testing.expect(!p.animationActive());
-}
-
test "topbar hover highlights exactly the executable word" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 });
defer p.deinit();
@@ -6759,14 +6752,6 @@ pub const Pardes = struct {
look.cancelLookHover(p);
}
- /// A native post pass proved unavailable: the chain is emptied, which
- /// DumpConfig then reports.
- pub fn disableSceneEffects(p: *Pardes) void {
- const taped = tape.enter(p, .disable_scene_effects);
- defer tape.leave(p, taped);
- p.settings.post.clear();
- }
-
/// The window's answer to a WindowOpacity: done, or `failure` says why
/// not, `applied` the opacity it keeps.
pub fn windowOpacityDone(p: *Pardes, applied: u8, failure: ?[]const u8) void {
diff --git a/src/tape.zig b/src/tape.zig
index 3723537e..380cf14e 100644
--- a/src/tape.zig
+++ b/src/tape.zig
@@ -75,7 +75,6 @@ pub const Input = union(enum) {
observe_font: Font,
acknowledge_font: Font,
reject_font,
- disable_scene_effects,
window_opacity_done: struct { applied: u8, failure: ?[]const u8 },
pub const Font = struct { name: []const u8, size: u16, unit: pardes.config.Runtime.FontSizeUnit };
@@ -632,7 +631,6 @@ pub const Tape = struct {
.observe_font => |f| _ = p.observeFont(f.name, f.size, f.unit),
.acknowledge_font => |f| _ = p.acknowledgeFont(f.name, f.size, f.unit),
.reject_font => p.rejectFont(),
- .disable_scene_effects => p.disableSceneEffects(),
.window_opacity_done => |w| p.windowOpacityDone(w.applied, w.failure),
}
t.finishInput();
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index c4d93419..4b0245d2 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -257,16 +257,14 @@ test "settings: every on/off setting the root ctl reads flips when its word is w
const word, const was = .{ line[0..space], line[space + 1 ..] };
const on = std.mem.eql(u8, was, "on");
if (!on and !std.mem.eql(u8, was, "off")) continue;
- // Shader's and Pet's `off` say they have no file and no pet; each takes
- // a name, not a flip.
- if (std.mem.eql(u8, word, "Shader") or std.mem.eql(u8, word, "Pet")) continue;
+ // Pet's `off` says it has no pet; it takes a name, not a flip.
+ if (std.mem.eql(u8, word, "Pet")) continue;
s.write("/ctl", s.at("{s}\n", .{word})) catch |err| {
std.debug.print("a bare {s} (was {s}) was refused\n", .{ word, was });
return err;
};
// A bare word moves the setting: a toggle to its other side, one with
- // more states (Lift's auto, Crt's level, ShaderAnimation's always) to
- // the next, never nowhere.
+ // more states (Lift's auto) to the next, never nowhere.
const after = try setting(&s, word);
try std.testing.expect(std.mem.startsWith(u8, after, word));
try std.testing.expect(!std.mem.eql(u8, after, line));
diff --git a/test/output.zig b/test/output.zig
index eb4da9b3..e998ac66 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -549,50 +549,7 @@ test "Config with no startup file opens a pane of its name, and Save makes its d
try std.testing.expectEqual(std.Io.File.Kind.directory, made.kind);
}
-test "EffectCode lists readable virtual sources used by this backend" {
- if (comptime !builtins.EffectCode.enabled) return;
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
-
- if (!pardes.memory.limits.embedded_sources) {
- const before = p.active;
- try std.testing.expect(p.executeBuiltinLine(0, "EffectCode PanelSlide"));
- try std.testing.expectEqual(before, p.active);
- return error.SkipZigTest;
- }
- try std.testing.expect(p.executeBuiltinLine(0, "EffectCode PanelSlide"));
- const out = p.panes[p.active].?.file.?;
- try std.testing.expectEqualStrings(config.effect_code_buffer, std.fs.path.basename(out.path));
- try std.testing.expectEqual(panes.Output.Origin{ .cmd = .EffectCode }, out.output.?.from);
- try std.testing.expectEqualStrings("PanelSlide", out.output.?.arg());
- try std.testing.expect(out.content.len < 1024);
- try std.testing.expect(std.mem.indexOf(u8, out.content, "/virtual/src/layout.zig\n") != null);
- const backend_source = switch (platform) {
- .tui => "/virtual/src/tui/panel_compositor.zig",
- .gui => "/virtual/shaders/ui.vert.glsl",
- .macos => "/virtual/src/macos/Sources/ScenePostprocessor.swift",
- };
- try std.testing.expect(std.mem.indexOf(u8, out.content, backend_source) != null);
- var paths = std.mem.tokenizeScalar(u8, out.content, '\n');
- var count: usize = 0;
- while (paths.next()) |path| {
- if (!std.mem.startsWith(u8, path, "/virtual/")) continue;
- const expected = pardes.filesystem.sourceBytes(path["/virtual/".len..]) orelse return error.MissingEffectSource;
- const bytes = try pardes.filesystem.read(p, path);
- defer p.gpa.free(bytes);
- try std.testing.expectEqualStrings(expected, bytes);
- count += 1;
- }
- try std.testing.expect(count >= 3);
- const report = p.active;
- pardes.look.lookAt(p, report, backend_source);
- try std.testing.expect(p.active != report);
- const source = p.panes[p.active].?.file.?;
- try std.testing.expectEqualStrings(backend_source, source.path);
- try std.testing.expectEqualStrings(pardes.filesystem.sourceBytes(backend_source["/virtual/".len..]).?, source.content);
-}
-
-test "a window's setting builtins (TaglineSize, Font, transitions, scene passes) reach the report DumpConfig writes" {
+test "a window's setting builtins (TaglineSize, Font, transitions) reach the report DumpConfig writes" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -629,7 +586,7 @@ test "a window's setting builtins (TaglineSize, Font, transitions, scene passes)
try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig"));
const report = p.panes[p.active].?.file.?.content;
// The toggles, Theme and Shell are test/behaviour/settings.zig's, through
- // the root ctl; what is left is a window's (fonts, transitions, passes).
+ // the root ctl; what is left is a window's (fonts, transitions).
const transition = if (!builtins.viewCapabilities(p).panel_transitions)
"PanelSlide unsupported\n"
else if (p.settings.panel_transition == .off)
@@ -637,12 +594,6 @@ test "a window's setting builtins (TaglineSize, Font, transitions, scene passes)
else
try std.fmt.bufPrint(&buf, "{s} on\n", .{config.Runtime.findAction(.{ .transition = p.settings.panel_transition }).?.word});
try std.testing.expect(std.mem.indexOf(u8, report, transition) != null);
- // A bare word turns a bundled pass on at its default level.
- const scene_status = if (builtins.viewCapabilities(p).scene_shaders) "2" else "unsupported";
- for ([_][]const u8{"Crt"}) |name| {
- const line = try std.fmt.bufPrint(&buf, "{s} {s}\n", .{ name, scene_status });
- try std.testing.expect(std.mem.indexOf(u8, report, line) != null);
- }
const tagline = if (!builtins.viewCapabilities(p).tagline_font_size)
"TaglineSize unsupported\n"
else
diff --git a/test/process/window.zig b/test/process/window.zig
index 1fe2fd2e..40d2e6a6 100644
--- a/test/process/window.zig
+++ b/test/process/window.zig
@@ -30,13 +30,12 @@ fn paneWith(f: *process.Files, word: []const u8) !u32 {
const motions = [_][]const u8{ "off", "crisp", "smooth", "bouncy", "playful" };
const lifts = [_][]const u8{ "off", "shadow", "rim", "auto" };
-const blooms = [_][]const u8{ "0", "2" };
const themes = [_][]const u8{ "lapis", "lapis_plain", "forge", "acme", "dusk", "daybreak" };
-/// test/gui_monkey.py's: each Motion x Lift x Bloom gets a random burst,
-/// then must settle with its process alive and no crash record. Two
+/// test/gui_monkey.py's: each Motion x Lift gets a random burst, then
+/// must settle with its process alive and no crash record. Two
/// combinations and 30 steps in process-test; PARDES_GUI_MONKEY=all runs
-/// all 40 (`zig build monkey-gui`), PARDES_GUI_MONKEY_SEED and _STEPS
+/// all 20 (`zig build monkey-gui`), PARDES_GUI_MONKEY_SEED and _STEPS
/// choose the rest.
fn monkey(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
try process.only(.gui);
@@ -45,20 +44,20 @@ fn monkey(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
const steps = try std.fmt.parseInt(usize, envOr("PARDES_GUI_MONKEY_STEPS", if (all) "60" else "30"), 10);
var failed: usize = 0;
var n: usize = 0;
- for (motions) |m| for (lifts) |l| for (blooms) |b| {
+ for (motions) |m| for (lifts) |l| {
defer n += 1;
// The smoke run: the quietest combination and the busiest.
- if (!all and n != 0 and n != motions.len * lifts.len * blooms.len - 1) continue;
- if (!try monkeyOne(gpa, exe, m, l, b, seed * 1000 + n, steps)) failed += 1;
+ if (!all and n != 0 and n != motions.len * lifts.len - 1) continue;
+ if (!try monkeyOne(gpa, exe, m, l, seed * 1000 + n, steps)) failed += 1;
};
if (failed > 0) return error.MonkeyFailed;
}
-fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift: []const u8, bloom: []const u8, seed: u64, steps: usize) !bool {
+fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift: []const u8, seed: u64, steps: usize) !bool {
var arena = std.heap.ArenaAllocator.init(gpa);
defer arena.deinit();
const a = arena.allocator();
- const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nLift {s}\nBloom {s}\nPanelSlide\nSelectionGlow on\nHoverGlow on\n", .{ motion, lift, bloom });
+ const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nLift {s}\nPanelSlide\nSelectionGlow on\nHoverGlow on\n", .{ motion, lift });
var d = try process.Detached.start(gpa, exe, "monkey", .{ .init = init, .grid = .{ 80, 28 }, .env = &.{
.{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "0" },
} });
@@ -102,7 +101,7 @@ fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift
};
} else |_| {}
const ok = std.mem.eql(u8, verdict, "ok");
- if (!ok) std.debug.print("monkey {s}-{s}-bloom{s} (seed {d}): {s}\n{s}", .{ motion, lift, bloom, seed, verdict, log.items });
+ if (!ok) std.debug.print("monkey {s}-{s} (seed {d}): {s}\n{s}", .{ motion, lift, seed, verdict, log.items });
return ok;
}