- Joined
- Aug 17, 2015
- Messages
- 65
- Reaction score
- 19
- First Language
- English
- Primarily Uses
- RMVXA
I know there's a Graphics.frame_rate member; I'm not talking about that (at least not directly). I'm trying to figure out how VX Ace prevents itself from calling Scene_Base.update much faster than 60 fps. Looking at the code in Scene_Base.main, update is called in an unconstrained while loop:
Inside that update() call, we just call Graphics.update, Input.update and update_all_windows in sequence then return. In order to restrict the game to 60 fps, somebody needs to be doing a sleep before that update method returns.
The docs under help talk a little bit about frame limiting in the Graphics module section, so my working hypothesis is that perhaps Graphics.update is doing that sleep internally and won't return until the right amount of time has passed? But, I can't verify that because that module is in the compiled dll, I believe. Does anyone know where the sleep is happening that ensures the game's frame rate is limited?
Why I care
I've noticed that a completely unmodified default project (in that empty initial level) has incredibly choppy framerates on certain laptops (like on a version of the MS Surface I have). Even on my relatively powerful desktop, there will pretty consistently be frame hitches.
Looking at the CPU utilization, even on the hitchy laptop, shows no core on the machine ever getting above 15 or 20% usage. I've written a per-frame profiler to try and see if there's expensive work being done on some frames, but it doesn't seem like there's a smoking gun there (not surprising since most of the VX Ace code base just does brute force updating of all game state on every frame... there's not really much deferred work).
So, given that the CPU isn't utilized and I haven't discovered some occasional expensive operation, I'm wondering if something in the frame limiting code is working incorrectly on that laptop. It's not clear I can _do_ anything about it (if it's in the maker dll) but at least knowing where the problem is would save me a bunch of time writing ever more sophisticated profilers
And, if I know where the issue is, there's always the possibility I could come up with some esoteric workaround.
update until scene_changing?
Inside that update() call, we just call Graphics.update, Input.update and update_all_windows in sequence then return. In order to restrict the game to 60 fps, somebody needs to be doing a sleep before that update method returns.
The docs under help talk a little bit about frame limiting in the Graphics module section, so my working hypothesis is that perhaps Graphics.update is doing that sleep internally and won't return until the right amount of time has passed? But, I can't verify that because that module is in the compiled dll, I believe. Does anyone know where the sleep is happening that ensures the game's frame rate is limited?
Why I care
I've noticed that a completely unmodified default project (in that empty initial level) has incredibly choppy framerates on certain laptops (like on a version of the MS Surface I have). Even on my relatively powerful desktop, there will pretty consistently be frame hitches.
Looking at the CPU utilization, even on the hitchy laptop, shows no core on the machine ever getting above 15 or 20% usage. I've written a per-frame profiler to try and see if there's expensive work being done on some frames, but it doesn't seem like there's a smoking gun there (not surprising since most of the VX Ace code base just does brute force updating of all game state on every frame... there's not really much deferred work).
So, given that the CPU isn't utilized and I haven't discovered some occasional expensive operation, I'm wondering if something in the frame limiting code is working incorrectly on that laptop. It's not clear I can _do_ anything about it (if it's in the maker dll) but at least knowing where the problem is would save me a bunch of time writing ever more sophisticated profilers


