Skip to content
Snippets Groups Projects
Unverified Commit 31ee6db2 authored by Clayton Craft's avatar Clayton Craft :speech_balloon:
Browse files

Render 3 times when using hw accel for drivers with triple buffering (MR 98)

parent 401e7984
No related branches found
Tags 0.59
1 merge request!98Improve performance when typing passwords
Pipeline #186324 passed
......@@ -200,6 +200,9 @@ int main(int argc, char **args)
exit(EXIT_FAILURE);
}
SDL_RendererInfo rendererInfo;
SDL_GetRendererInfo(renderer, &rendererInfo);
// Start drawing keyboard when main loop starts
SDL_PushEvent(&renderEvent);
......@@ -298,19 +301,28 @@ int main(int argc, char **args)
} // switch event.type
// Render event handler
if (event.type == EVENT_RENDER) {
/* NOTE ON DOUBLE BUFFERING / RENDERING TWICE:
/* NOTE ON MULTI BUFFERING / RENDERING MULTIPLE TIMES:
We only re-schedule render events during animation, otherwise
we render once and then do nothing for a long while.
A single render may however never reach the screen, since
SDL_RenderCopy() page flips and with double buffering that
may just fill the hidden backbuffer.
SDL_RenderCopy() page flips and with multi buffering that
may just fill the hidden backbuffer(s).
Therefore, we need to render multiple times if not during
animation to make sure it actually shows on screen during
lengthy pauses.
For software rendering (directfb backend), rendering twice
seems to be the sweet spot.
Therefore, we need to render two times if not during animation
to make sure it actually shows on screen during lengthy pauses.
For accelerated rendering, we render 3 times to make sure
updates show on screen for drivers that use
triple buffering
*/
int render_times = 0;
while (render_times < 2) { // double-flip so it reaches screen
int max_render_times = (rendererInfo.flags & SDL_RENDERER_ACCELERATED) ? 3 : 2;
while (render_times < max_render_times) {
render_times++;
SDL_RenderCopy(renderer, wallpaperTexture, nullptr, nullptr);
// Hide keyboard if unlock luks thread is running
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment