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: [OpenGL] Increase timeout when waiting for the GPU to be done with the drawing buffer. #9282

Merged
merged 1 commit into from May 23, 2021

Conversation

michicc
Copy link
Member

@michicc michicc commented May 19, 2021

Motivation / Problem

Screen refresh could glitch if v-sync was enabled with lower refresh rates.

Description

Increase the buffer sync timeout to make sure we definitely wait longer than the screen refresh.

Limitations

If the GPU is extremely busy, the new timeout will make stutter more likely but graphical glitches a lot less likely.

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 affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

…th the drawing buffer.

The old timeout could be too short if v-sync was on on lower refresh rates.
@@ -1174,7 +1174,7 @@ uint8 *OpenGLBackend::GetAnimBuffer()
if (this->anim_pbo == 0) return nullptr;

#ifndef NO_GL_BUFFER_SYNC
if (this->sync_anim_mapping != nullptr) _glClientWaitSync(this->sync_anim_mapping, GL_SYNC_FLUSH_COMMANDS_BIT, 10000000);
if (this->sync_anim_mapping != nullptr) _glClientWaitSync(this->sync_anim_mapping, GL_SYNC_FLUSH_COMMANDS_BIT, 100000000); // 100ms timeout.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe 100 * 1000 * 1000 to make us count less zeros? Feel free to say no :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey, I did add a comment 😀

@michicc michicc merged commit 9772293 into OpenTTD:master May 23, 2021
@michicc michicc deleted the pr/gl_sync_time branch May 23, 2021 10:23
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.

None yet

3 participants