diff options
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/core/Core.zig b/core/Core.zig index 398d5973..0e37f945 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -282,8 +282,12 @@ theme_file_loaded: config.Runtime.Text(limits.host_path_cap) = .{}, theme_file_generation: u32 = 0, theme_file_pane: u8 = 0, chrome: colors.ChromeTheme = colors.initial_chrome, -/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES). -frames: FrameStats = .{}, +/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES): +/// its runner's (`Options.frames`), which its frontend writes as it draws +/// and reads input, never the core's memory; a core with no runner (a +/// test's) has its own. +frames: *FrameStats = undefined, +own_frames: FrameStats = .{}, quit: bool = false, /// A detached session with no frontend attached: nothing renders, so /// no input ever dismisses a message (Messages.expireUnattended). @@ -334,9 +338,6 @@ boot: Boot = .shell, /// Is there a frame worth drawing? Cleared once one is presented, set by /// anything that can change what is on screen. The first frame always is. needs_frame: bool = true, -/// Set by a shell whose present was skipped (no swapchain image): the -/// frame is still owed, and the next pump draws it again. -present_skipped: bool = false, clock: Clock = .{}, /// Builtins announce themselves on the message row. Off while startup /// configuration is applied: those lines are nobody clicking, and should @@ -388,6 +389,9 @@ restore_req: ?[]const u8 = null, restore_buf: [1024]u8 = @splat(0), surface: Surface = .{}, +/// What a frontend reads beside the frame's cells (surface.Facts), filled +/// as it is placed (draw.place); the frame points at it. +facts: pardes.Facts = .{}, /// A replica's predicted echo (core/term/echo.zig), drawn over its terminals: /// presentation, its own, in no digest and no rollback copy. Null on a /// session's own core. @@ -427,9 +431,11 @@ diff_output: pardes.ansi.DiffOutput = .{}, pub const replica = .{ .local = .{ // A frame, and the timings that make it. - "surface", "frames", "chrome", + "surface", "facts", "frames", + "own_frames", + "chrome", "frame_arena", "scratch", "needs_frame", - "present_skipped", "echo", + "echo", // Drained by every pump before its digest; a replica's queues // are its own. "effects", @@ -522,6 +528,7 @@ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes { .fallback = .{ .gpa = gpa }, .db = .{ .kind = opts.state }, }; + p.frames = opts.frames orelse &p.own_frames; errdefer p.deinit(); p.fs.started = ctlfs.events.now(); for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); @@ -1499,23 +1506,23 @@ pub fn pump(p: *Pardes, host: Host) !void { if (v.watched) |f| if (!f(h.ctx)) return; // The one view this process shows (a replica client's is its own // process's to draw), drawn as it is if another's is live. + // Not shown by the frontend (Host.present): owed. + var skipped = false; const shown = Views.shown(p); if (shown != p.live) { - if (shown) |k| try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present }); + if (shown) |k| skipped = !try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present }); } else { _ = p.frame_arena.reset(.{ .retain_with_limit = memory.limits.frame_kept }); p.frames.mark_update = FrameStats.nowNs(); p.frames.view = if (p.panes[p.view().active]) |pane| pane.scroll() else 0; const surface = try p.render(p.frame_arena.allocator()); p.frames.mark_render = FrameStats.nowNs(); - if (v.present) |f| f(h.ctx, surface); + if (v.present) |f| skipped = !f(h.ctx, surface); Stream.askAhead(p); } // Settled before post_present: a shell ticks there, and what that // tick moves owes the next frame. - const skipped = p.present_skipped; - p.needs_frame = p.present_skipped; - p.present_skipped = false; + p.needs_frame = skipped; if (v.post_present) |f| f(h.ctx); // Still moving: the next frame is owed a period from now. const owed = if (p.nextWake()) |due| due <= p.clock.stepped_ns + frame_ns else false; @@ -2234,7 +2241,9 @@ pub const Boot = enum { }; pub const Options = struct { - pub const replica = .{ .local = .{"distrusted"} }; + /// Not taped: the client's list of distrusted kinds, and where its + /// runner keeps its frame statistics. + pub const replica = .{ .local = .{ "distrusted", "frames" } }; tty_only: bool = false, /// The first view's frontend is a window (`Pardes.frontend`), as a /// window's build says: an option, taped with the rest, so that a @@ -2285,6 +2294,8 @@ pub const Options = struct { /// Where each frame's Surface text is built. Hosts pass a purpose-built /// stack-fallback arena; null means the general allocator. frame_allocator: ?std.mem.Allocator = null, + /// The runner's frame statistics (`Pardes.frames`); null: the core's own. + frames: ?*FrameStats = null, cols: u16 = 80, rows: u16 = 24, }; @@ -2715,8 +2726,9 @@ test "a frame no one watches is not drawn, and is drawn once someone does" { var presents: usize = 0; var seen = false; const vtable: Host.VTable = .{ .present = present, .watched = watched }; - fn present(_: ?*anyopaque, _: *const Surface) void { + fn present(_: ?*anyopaque, _: *const Surface) bool { presents += 1; + return true; } fn watched(_: ?*anyopaque) bool { return seen; |
