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: [SDL2] simplify what to redraw to prevent tearing #8685

Merged
merged 1 commit into from Feb 17, 2021

Conversation

TrueBrain
Copy link
Member

Motivation / Problem

When scrolling around on the map, on SDL2 there often is some vertical tearing going on, mostly on the right side of the screen. If you move the map slowly, this is very visible on for example my system, but others reported it too.

JGRPP solves this problem with this: JGRennison/OpenTTD-patches@5147733

With the eye on the OpenGL branch, I went for a slightly different approach but with a similar effect.

Description

When there are a lot of rects to redraw, of which one of the last
ones is almost the full screen, visual tearing happens over the
vertical axis. This is most visible when scrolling the map.

This can be prevented by using less rects. To simplify the situation,
and as solutions like OpenGL need this anyway, keep a single rect
that shows the biggest size that updates everything correctly.

Although this means it needs a bit more time redrawing where it
is strictly seen not needed, it also means less commands have
to be executed in the backend. In the end, this is a trade-off,
and from experiments it seems the approach of this commit gives
a better result.

Limitations

  • I need a few people testing this out on their hardware, to see if there is any regression because of this.

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')

@TrueBrain TrueBrain force-pushed the sdl-tearing branch 4 times, most recently from e345410 to 50a626b Compare February 17, 2021 19:53
When there are a lot of rects to redraw, of which one of the last
ones is almost the full screen, visual tearing happens over the
vertical axis. This is most visible when scrolling the map.

This can be prevented by using less rects. To simplify the situation,
and as solutions like OpenGL need this anyway, keep a single rect
that shows the biggest size that updates everything correctly.

Although this means it needs a bit more time redrawing where it
is strictly seen not needed, it also means less commands have
to be executed in the backend. In the end, this is a trade-off,
and from experiments it seems the approach of this commit gives
a better result.
@TrueBrain TrueBrain merged commit 8e0d48a into OpenTTD:master Feb 17, 2021
@TrueBrain TrueBrain deleted the sdl-tearing branch February 17, 2021 20:19
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