Smoother on Xorg and Live Starfield: draw one frame ahead, cache a backdrop's unchanging start
CI / test (push) Successful in 2m33s
CI / test (push) Successful in 2m33s
Tested on a Vast GTX 1650 rig (8-core Xeon E5-2620 v4, NVIDIA Xorg, --x11 --fullscreen): GPU detection says hardware (nvidia), CHANDRA_RENDER=software switches. - Frame pacing: at most one frame is drawn ahead of the output instead of waiting until the output is ready. Waiting serialised drawing with the X server's copy of the last frame; overview on Xorg went from 24-27 fps to 41-48 fps (before the first round: 16-17 fps). - MoonBit host: a backdrop whose ops change every frame but begin the same (a desktop module: Live Starfield's sky and nebulae under moving stars) keeps that common start as cached pixels and draws only the rest over a copy of it. Starfield raster 13 -> 1.7 ms a frame and CPU 46% -> 11% in the cloud; it no longer clears, redraws and re-saves the whole backdrop every frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hkTQp5uN5FtwpzrXUA
This commit is contained in:
3 files changed
+74
-16
No files matched your search
@@ -317,9 +317,9 @@ pub fn run(args : Array[String]) -> Int {
|
||||
k.set_cursor_shape(comp.desired_cursor())
|
||||
// The host draws; only a changed desktop is sent, and the frame is shown by the host
|
||||
// straight from its framebuffer.
|
||||
// Draw only when the display can take the frame (no page flip in flight): a frame
|
||||
// drawn meanwhile would never be seen, and drawing it costs a whole frame's CPU.
|
||||
let changed = if k.frame_ready() || comp.screen_off || pacer.overdue() {
|
||||
// Draw at most one frame ahead of the display: while a drawn frame waits for the
|
||||
// page flip in flight, another one would never be seen and costs a whole frame's CPU.
|
||||
let changed = if !need_present || k.frame_ready() || comp.screen_off || pacer.overdue() {
|
||||
draw_frame(comp, trace, pacer)
|
||||
} else {
|
||||
false
|
||||
@@ -404,8 +404,8 @@ pub fn run(args : Array[String]) -> Int {
|
||||
comp.handle_input(ev, now_ms)
|
||||
}
|
||||
n.set_cursor_shape(comp.desired_cursor())
|
||||
// As on a display: draw when the host compositor can take the frame.
|
||||
if (n.frame_ready() || pacer.overdue()) && draw_frame(comp, trace, pacer) {
|
||||
// As on a display: at most one drawn frame waits for the host compositor.
|
||||
if (!need_present || n.frame_ready() || pacer.overdue()) && draw_frame(comp, trace, pacer) {
|
||||
need_present = true
|
||||
busy = true
|
||||
}
|
||||
@@ -445,7 +445,7 @@ pub fn run(args : Array[String]) -> Int {
|
||||
comp.handle_input(ev, now_ms)
|
||||
}
|
||||
x.set_cursor_shape(comp.desired_cursor())
|
||||
if (x.frame_ready() || pacer.overdue()) && draw_frame(comp, trace, pacer) {
|
||||
if (!need_present || x.frame_ready() || pacer.overdue()) && draw_frame(comp, trace, pacer) {
|
||||
need_present = true
|
||||
busy = true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user