Skip to content

Run the game update without a drawn frame - #1076

Draft
Reveares wants to merge 1 commit into
Try:masterfrom
Reveares:fix/background-tick
Draft

Reveares wants to merge 1 commit into
Try:masterfrom
Reveares:fix/background-tick

Conversation

@Reveares

Copy link
Copy Markdown
Contributor

#1065, needs Try/Tempest#145.

The game update runs only inside render, and render waits for the next swapchain image without a bound. A window that gets no image updates at the compositor's pace, about once a second when covered or minimized on X11, and a window that gets no render at all, minimized on Windows, does not update.

render now waits for an image with Swapchain::tryAcquire only until the next update is due, 33 ms after the last one: about 30 updates a second, under tick's 50 ms step. A drawn frame still follows an update in the same pass, so there are updates without a frame and no frame without an update.

MainWindow::setRunInBackground(bool) starts a 33 ms timer that runs the update when no render ran it since the timer's last firing. It is off by default and nothing calls it here. It is the engine-level switch for a multiplayer client.

The bounded wait also applies with the setter off. A covered or minimized game on X11 then runs at full speed where it ran at a twentieth, and is drawn whenever the compositor hands out an image, as in GNOME's overview. On a display slower than 30 Hz there are two updates per frame.

Run on Linux under GNOME (Xwayland) and on Windows. Covered and minimized on X11 it updates 31 times a second and presents once a second. Minimized on Windows it updates 30 times a second with the setter on and not at all with it off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant