Skip to content

Conversation

@cgutman
Copy link
Collaborator

@cgutman cgutman commented Feb 1, 2026

Description

The following sequence of renderer commands is currently broken on D3D9:

SDL_RenderTexture(renderer, yuv_texture, NULL, NULL);
SDL_FlushRenderer(renderer);
SDL_RenderTexture(renderer, rgb_texture, NULL, NULL);

The problem is that when SDL_FlushRenderer() calls D3D_InvalidateCachedState(), the renderer forgets that it still has the YUV shader and U/V planes bound. SetDrawState() then thinks it only needs to update texture 0 before rendering. The result is that the area where the RGB texture is supposed to go is instead drawn with the YUV shader with RGB texture as the Y plane and the U/V planes from the last YUV texture.

This PR fixes the issue by adding a new texture_state_dirty member which forces SetDrawState() to update the bound textures and shader. It also fixes the case where an app might have bound their own textures or shader after SDL_FlushRenderer() and not unbound them before calling into SDL again.

Existing Issue(s)

@slouken slouken merged commit 4743f97 into libsdl-org:main Feb 1, 2026
45 checks passed
@slouken
Copy link
Collaborator

slouken commented Feb 1, 2026

Merged, thanks!

@slouken slouken added this to the 3.4.2 milestone Feb 1, 2026
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.

2 participants