From 88cb4962cda589c04f8046e81be35a565bd52e52 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 9 Dec 2020 06:42:31 -0800 Subject: [PATCH] Fixed bug 5291 - SDL_SetRenderTarget unnecessarily changes target when current target is the native texture of the passed in texture --- src/render/SDL_render.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 71604bc4a..c9b195a4e 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1879,12 +1879,6 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) if (!SDL_RenderTargetSupported(renderer)) { return SDL_Unsupported(); } - if (texture == renderer->target) { - /* Nothing to do! */ - return 0; - } - - FlushRenderCommands(renderer); /* time to send everything to the GPU! */ /* texture == NULL is valid and means reset the target to the window */ if (texture) { @@ -1901,6 +1895,13 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) } } + if (texture == renderer->target) { + /* Nothing to do! */ + return 0; + } + + FlushRenderCommands(renderer); /* time to send everything to the GPU! */ + SDL_LockMutex(renderer->target_mutex); if (texture && !renderer->target) {