summaryrefslogtreecommitdiff
path: root/test/veil.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:01:02 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit30a603341e3b23da6e5ab5995b060c8e4ec52242 (patch)
tree9a24941b147a5265e6b0726285e9501cd7b61c6d /test/veil.zig
parentafc60e735274b0de5423ac375a9ea582f64b516f (diff)
downloadpardes-30a603341e3b23da6e5ab5995b060c8e4ec52242.tar.gz
pardes-30a603341e3b23da6e5ab5995b060c8e4ec52242.zip
test: the GPU move's gates, sharper: a window the harness starts runs under PARDES_TEST_WRAP when it names a command (perf stat, a script), given the window's argv, its binary made absolute; a test window's series keeps its frames as PAM (P7 RGB_ALPHA), so the corpus sees the alpha a blend writes (latest.ppm and every other capture stay RGB); the corpus adds a translucent addon picture, test/veil.zig (zig build veil: a GPU pass that clears to half alpha and draws nothing), for the addon pipeline's colour factor, which the snake's opaque picture never showed; the snake's window ends with its pane gone and at rest, so it ends having drawn as many frames every run
Diffstat (limited to 'test/veil.zig')
-rw-r--r--test/veil.zig37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/veil.zig b/test/veil.zig
new file mode 100644
index 00000000..ed49e1c3
--- /dev/null
+++ b/test/veil.zig
@@ -0,0 +1,37 @@
+//! A test addon whose GPU picture is translucent: its pass draws nothing
+//! and clears to a premultiplied half-alpha colour, so the window's addon
+//! pipeline blends it over the pane (the frame corpus's case for the
+//! pipeline's colour factor, which an opaque picture never shows).
+const std = @import("std");
+const addon = @import("addon");
+const scene = @import("gpu_scene");
+
+pub const Veil = extern struct {
+ painted: u32,
+
+ pub const head: addon.Head = .{ .name = "veil", .version = 1, .words = &.{
+ .{ .name = "Veil", .opens = true, .doc = "a translucent GPU picture over the pane (a test addon)" },
+ } };
+
+ pub fn open(v: *Veil, _: ?[]const u8, _: ?[]const u8) void {
+ v.painted = 0;
+ }
+
+ pub fn paint(_: *const Veil, w: addon.Window, out: addon.Paint) void {
+ w.put(0, 0, "veil over this", .{});
+ const width: u32 = @min(4096, @max(1, @as(u32, w.cols) * w.cell_w));
+ const height: u32 = @min(4096, @max(1, @as(u32, w.rows) * w.cell_h));
+ var buffer: [256]u8 = undefined;
+ var writer: std.Io.Writer = .fixed(&buffer);
+ scene.encode(&writer, .{ .image = .none, .width = width, .height = height, .clear = .{ 0.30, 0.10, 0.20, 0.5 }, .pipelines = &.{}, .draws = &.{} }) catch return;
+ _ = out.gpu(writer.buffered());
+ }
+
+ pub const dump = addon.dumpBytes;
+ pub const load = addon.loadBytes;
+};
+
+pub const pardes_addon = addon.ops(Veil);
+comptime {
+ addon.exportLib(&pardes_addon);
+}