a73x

d236646a

Migrate runDrawSmokeTest to FrameLoop

a73x   2026-04-16 11:26

Commit message
Migrate runDrawSmokeTest to FrameLoop

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

src/main.zig
Old New
@@ -2697,27 +2697,30 @@ fn runDrawSmokeTest(alloc: std.mem.Allocator) !void {
2697 try ctx.uploadInstances(&instances); 2697 try ctx.uploadInstances(&instances);
2698 std.debug.print("instances uploaded, rendering for ~15 seconds at 60fps...\n", .{}); 2698 std.debug.print("instances uploaded, rendering for ~15 seconds at 60fps...\n", .{});
2699 2699
2700 var i: u32 = 0; 2700 var frame_loop = frame_loop_mod.FrameLoop.init(
2701 while (i < 900) : (i += 1) { 2701 window.displayOps(conn.display),
2702 // Non-blocking Wayland event read: prepare + read + dispatch. 2702 window.surfaceStateView(),
2703 // The Vulkan WSI (FIFO) needs wl_buffer.release events from the compositor 2703 );
2704 // to be read off the socket before it can release an acquire slot. 2704 defer frame_loop.deinit();
2705 _ = conn.display.flush(); 2705 window.frame_loop = &frame_loop;
2706 if (conn.display.prepareRead()) { 2706 defer window.frame_loop = null;
2707 _ = conn.display.readEvents(); 2707
2708 } 2708 const deadline_ns = @as(i128, std.time.nanoTimestamp()) + 15 * std.time.ns_per_s;
2709 _ = conn.display.dispatchPending(); 2709 while (std.time.nanoTimestamp() < deadline_ns and !window.should_close) {
2710 try frame_loop.waitForWork(&.{}, 16);
2711 if (!frame_loop.canRender()) continue;
2712
2710 const baseline_coverage = renderer.coverageVariantParams(.baseline); 2713 const baseline_coverage = renderer.coverageVariantParams(.baseline);
2711 ctx.drawCells(1, .{ cell_w, cell_h }, .{ 0.0, 0.0, 0.0, 1.0 }, baseline_coverage) catch |err| switch (err) { 2714 ctx.drawCells(1, .{ cell_w, cell_h }, .{ 0.0, 0.0, 0.0, 1.0 }, baseline_coverage) catch |err| switch (err) {
2712 error.OutOfDateKHR => { 2715 error.OutOfDateKHR => {
2713 _ = try ctx.vkd.deviceWaitIdle(ctx.device); 2716 _ = try ctx.vkd.deviceWaitIdle(ctx.device);
2714 try ctx.recreateSwapchain(window.width, window.height); 2717 try ctx.recreateSwapchain(window.width, window.height);
2718 frame_loop.forceArm();
2715 continue; 2719 continue;
2716 }, 2720 },
2717 else => return err, 2721 else => return err,
2718 }; 2722 };
2719 _ = conn.display.flush(); 2723 try frame_loop.commitRender();
2720 std.Thread.sleep(16 * std.time.ns_per_ms);
2721 } 2724 }
2722 2725
2723 _ = try ctx.vkd.deviceWaitIdle(ctx.device); 2726 _ = try ctx.vkd.deviceWaitIdle(ctx.device);