New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add frame presentation modes (#953, #1167, #1197, #1228, #1363, #1159) #1596
Conversation
For those testing on Linux, I noticed ibus-daemon was able to micro-stall DOSBox Staging (and the gnome-shell) due to an excessive CPU usage bug. You can safely kill/uninstall/delete the |
Comparing [sdl]
fullscreen = true
output = opengl
vsync = true
vsync_skip = 0
[render]
scaler = none
glshader = none
[cpu]
core = dynamic
cycles = max
[dosbox]
startup_verbosity = quiet
[mixer]
nosound = true DoomBefore: After: Chris's 3D BenchmarkBefore: After: QuakeBefore: After: What's going on here? The On real hardware, these benchmarks scale with system speed - they're not bottlenecked by vsync. That's how the PR lets them run: by only presenting frames to the host in the fraction of time just before vsync period. Even thought the host is vsync-blocked at 60 Hz, the PR still lets the DOS side behave as if it's running at a full 70 Hz, despite only ever being able to show 60 FPS. |
a8f7599
to
75d7535
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see any obvious problems with the code changes. Ran my usual tests of this branch and found no regressions either. Don't have a variable refresh rate monitor, so if there are any issues there I wouldn't be able to test. Overall a very large set of changes. Nice work!
These member variables and functions allow for the setting, getting, and overriding of the DOS refresh rate.
This is a pre-requisite to moving to period-based constant and variable frame rate presentation, where time periods are used to control if presentation is performed.
Fixes a couple uninitialized member warnings.
SDL only provides the host rate as an integer, which is too coarse for our needs. This commit adds an enum and functions to refine the host rate.
These routines perform a single task per backend-method: - Surface frame buffer update and presentation - Texture frame buffer update and presentation - OpenGL frame buffer update and presentation Four presentation modes are added: - CFR: constant frame rate - VFR: variable frame rate - SYNCED_CFR: constant frame rate at host timing - THROTTLED_VFR: variable frame rate not exceeding the host's benchmarked max presentation rate.
This commit calls the setup_presentation_mode() routine during DOS video mode changes and during fullscreen-to- window toggles. These are the points where the properties about both the DOS and host video modes can change, and therefore are where we should reassess which presentation mode to employ. Finally, the selected presentation mode is call in GFX_EndUpdate().
75d7535
to
4ffc515
Compare
PRs been up for a week. If anyone plans to help more with this - be it testing, code review, or general feedback - please let me know! If not, will plan to merge in the next day or so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a complete refinement over the original one. The code looks good and I do not notice any obvious problems either. I don't personally have a VRR monitor to test though, but it has apparently tested by others who have such a monitor.
Thanks for the review, @Wengier ! |
Let's merge ; thanks everyone for all the feedback and help testing this! |
Fixes #1559 |
Background: DOSBox (and thus Staging) presents a new frame to the host at the end of the DOS video mode's vblank period, provided new DOS screen content is present. Satisfying both conditions means the effective frame rate can be as low as 0 FPS (if the screen content isn't changing) and as fast as the DOS rate (often up to ~70 Hz). We'll call this existing presentation mode: Variable Frame Rate or VFR.
This PR adds some more presentation modes:
Given these modes either show duplicate frames or may drop frames, why would we want them?
By default, this PR inspects real-time conditions and picks the optimal presentation mode and frame period. For power-users, these conditions are configurable:
[sdl] presentation_mode = auto / cfr / vfr
[sdl] host_rate = auto / sdi / vrr / custom
[dosbox] dos_rate = default / host / custom
These are described in the updated config file, which can be written with:
Z:\> config -wc
.Contributors to this PR include:
Linked issues: