From 16536b73befacf131065ff8eb97179433f24f3d1 Mon Sep 17 00:00:00 2001 From: s-ol Date: Mon, 22 Sep 2025 17:31:24 +0200 Subject: log fps every 64 frames --- src/main.zig | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main.zig b/src/main.zig index aeae96e..6d70a14 100644 --- a/src/main.zig +++ b/src/main.zig @@ -117,6 +117,7 @@ pub fn main() !void { const control = try ctrl.ControlServer.init(cfg_allocator, progress, &cache, &config, &constants); defer control.destroy(); + var loops: u8 = 0; while (c.glfwWindowShouldClose(window) == c.GL_FALSE) { c.glfwMakeContextCurrent(window); @@ -134,12 +135,24 @@ pub fn main() !void { // control.reload_requested = false; // } - fbo.bind(); - c.glClear(c.GL_COLOR_BUFFER_BIT); + { + c.glFinish(); + var timer = try std.time.Timer.start(); - main_program.bind(); - constants.normalized_quad.draw(); - fbo.unbind(); + fbo.bind(); + c.glClear(c.GL_COLOR_BUFFER_BIT); + + main_program.bind(); + constants.normalized_quad.draw(); + fbo.unbind(); + + c.glFinish(); + const fps = timer.read(); // ns + loops = (loops + 1) % 64; + if (loops == 0) { + std.debug.print("\rrendered in {d:.2}ms\n", .{@as(f64, @floatFromInt(fps)) / std.time.ns_per_ms}); + } + } for (outputs.items, 0..) |output, i| { const close = output.update(fbo.texture_id); -- cgit v1.2.3