| Summary: | SDL_SetRenderTarget unnecessarily changes target when current target is the native texture of the passed in texture | ||
|---|---|---|---|
| Product: | SDL | Reporter: | michaeljosephmaltese |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sezeroz |
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | All | ||
Fixed, thanks! https://hg.libsdl.org/SDL/rev/beac59a42e37 |
Suggested patch: ```diff --- 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) { @@ -1900,6 +1894,13 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) texture = texture->native; } } + + if (texture == renderer->target) { + /* Nothing to do! */ + return 0; + } + + FlushRenderCommands(renderer); /* time to send everything to the GPU! */ SDL_LockMutex(renderer->target_mutex); ```