a73x

d236646a

Migrate runDrawSmokeTest to FrameLoop

a73x   2026-04-16 11:26

Replaces the fixed 900-iteration + manual event-pump pattern with
FrameLoop pacing. Uses a 15-second wall-clock deadline instead of a
frame count.

diff --git a/src/main.zig b/src/main.zig
index 0293d64..04cb502 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2697,27 +2697,30 @@ fn runDrawSmokeTest(alloc: std.mem.Allocator) !void {
    try ctx.uploadInstances(&instances);
    std.debug.print("instances uploaded, rendering for ~15 seconds at 60fps...\n", .{});

    var i: u32 = 0;
    while (i < 900) : (i += 1) {
        // Non-blocking Wayland event read: prepare + read + dispatch.
        // The Vulkan WSI (FIFO) needs wl_buffer.release events from the compositor
        // to be read off the socket before it can release an acquire slot.
        _ = conn.display.flush();
        if (conn.display.prepareRead()) {
            _ = conn.display.readEvents();
        }
        _ = conn.display.dispatchPending();
    var frame_loop = frame_loop_mod.FrameLoop.init(
        window.displayOps(conn.display),
        window.surfaceStateView(),
    );
    defer frame_loop.deinit();
    window.frame_loop = &frame_loop;
    defer window.frame_loop = null;

    const deadline_ns = @as(i128, std.time.nanoTimestamp()) + 15 * std.time.ns_per_s;
    while (std.time.nanoTimestamp() < deadline_ns and !window.should_close) {
        try frame_loop.waitForWork(&.{}, 16);
        if (!frame_loop.canRender()) continue;

        const baseline_coverage = renderer.coverageVariantParams(.baseline);
        ctx.drawCells(1, .{ cell_w, cell_h }, .{ 0.0, 0.0, 0.0, 1.0 }, baseline_coverage) catch |err| switch (err) {
            error.OutOfDateKHR => {
                _ = try ctx.vkd.deviceWaitIdle(ctx.device);
                try ctx.recreateSwapchain(window.width, window.height);
                frame_loop.forceArm();
                continue;
            },
            else => return err,
        };
        _ = conn.display.flush();
        std.Thread.sleep(16 * std.time.ns_per_ms);
        try frame_loop.commitRender();
    }

    _ = try ctx.vkd.deviceWaitIdle(ctx.device);