(Windows) Use framelimiter only when needed #1168
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change makes use of the
IDXGIOutputDuplication::AcquireNextFrameto wait for next frames instead of using additional sleep-based framelimiter.Additionally, a new framelimiter has been introduced to work with the
IDXGIOutputDuplication::AcquireNextFrameto skip the frames when we actually need to (when streaming at lower FPS than what is being rendered).More details
I have been chasing random "jumpy camera movement" for months. The problem is how random it all is.

You can have a very smooth framerate:
and then out of nowhere it just starts jerking (going into the game menu makes it go away, until it comes back):

It's not always noticeable, until the camera starts jumping. By jumping I mean stuttering, but in a very uniform manner, as if the FPS has dropped to 20 FPS or something.
I have managed to procure a 3 minute test run in Cyberpunk 2077, at the end of which the jerkiness occurs. I then have managed to track it down to the additional sleep/wait that is being done before the
AcquireNextFrameis called. Once removed, theAcquireNextFramedoes the waiting. Since then, I have yet to experience that uni-formally jumpy camera action.So, I have removed the wait/sleep code block and introduced another framelimiter that kicks in if stream FPS < render FPS.
Overall the frametime seems to have improved a little in heavy-load games. Take Hogwarts Legacy for example (here I am standing in the same place and spinning around).
BEFORE:


AFTER:


Type of Change
.github/...)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.