Skip to content
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

Fix #10079: don't render at 1000fps if HW acceleration + vsync is requested but not active #12067

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Feb 11, 2024

Motivation / Problem

Fixes #10079.

When you enable HW acceleration in-game, you get told to restart. But if you don't ....... you can also enable vsync, and the game actually tries to align with vsync. But there is no vsync in non-HW accelerated backends. So it just goes to 1000fps.

Description

Query the driver to know whether it is hw-accelerated.

Sadly, this information was currently only available in the DriverFactoryBase, so it had to be duplicated into the VideoDriver to be available (in quick way) for GetDrawInterval.

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Copy link
Contributor

@rubidium42 rubidium42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the vtable is too slow, one can always consider making it an instance variable of VideoDriver and setting that in the constructor.

@TrueBrain
Copy link
Member Author

When the vtable is too slow, one can always consider making it an instance variable of VideoDriver and setting that in the constructor.

Not sure that is actually an improvement, but for visibility, pushed it nevertheless.

@TrueBrain TrueBrain merged commit bad31f2 into OpenTTD:master Feb 12, 2024
20 checks passed
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.

[Bug]: High CPU usage when Vsync is enabled on Win32 videodriver
2 participants