Comments (6)
Since vsync is not always on, you'd need an additional framerate limiter just prior to the frame presentation step, which can absorb any remaining time to reach the target frametime.
FWIW, this was actually the initial design of this plugin.
0ms -----------------------
Estimate how long the next frame will take, minus a small margin to give us space if it takes longer
Sleep for this duration. (Forward estimation)
8ms Start of event loop. Get input. Do stuff.
11.8ms See how close our estimate was to the requested frame time, sleep if required to get the frametime just right
12ms Send to GPU, present frame (input is 4ms out of date)
16ms ----------------------
That was taken from my comments in the initial discussion that spawned this plugin: bevyengine/bevy#3317
However, in practice I had a lot of trouble getting good results from it. This may have predated my use of spin_sleep
, so it may be worth revisiting that approach.
from bevy_framepace.
@MatthewScholefield a comprehensive rework of this crate is blocked by bevy's render code, which doesn't currently expose timing information for presenting frames.
from bevy_framepace.
However, in practice I had a lot of trouble getting good results from it. This may have predated my use of spin_sleep, so it may be worth revisiting that approach.
Yeah you'd essentially need to duplicate the framepace PID controller for the framerate limiter. You need very accurate sleep times.
from bevy_framepace.
Yup, I did play around with writing a PID controller, but I may have been limited by platform sleep time accuracy/variance. Definitely worth revisiting this, I appreciate your deep-dive.
from bevy_framepace.
Appreciate the investigation into this. Would be great to get this improved. I can replicate frequent stutters on my machine under Wayland.
from bevy_framepace.
Unfortunately that is the case. I can take another look at the PID impl if I get the time, but it's low on my priority list as I expect improvements will be minor until we can properly measure vblanks.
from bevy_framepace.
Related Issues (20)
- Store frame time, not frame rate HOT 1
- Clarify ordering for framerate_limiter system
- Consistency pass for methods on FramepacePlugin
- `pre` variable name in `get_display_refresh_rate` is unhelpful
- Logic in get_display_refresh_rate is extremely convoluted
- Subtracting 1 from the frame time is surprising and undocumented
- Flooring frame rate at 1 FPS is surprising and undocumented
- Handle errors more gracefully in get_display_refresh_rate
- Unnecessary features in Cargo.toml HOT 2
- Bevy v0.10 HOT 1
- RenderExtractApp not added in wasm32 on bevy 0.10
- PID controller for sleep error HOT 1
- WASM: Limiter::from_framerate(30.0) not working HOT 1
- Can't use the crate in headless mode HOT 1
- dbg! in production HOT 1
- Refresh rate detection doesn't work when using multiple screens with different refresh rate HOT 2
- Unnessary allocation in `Limiter` `Display`
- Unable to build for wasm target on bevy 0.13 that does not export `pipelined_rendering` module
- Thread parking
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bevy_framepace.