SDL: Fixed building with SDL_LEAN_AND_MEAN (3225d)

From 3225d316794dbf64a787c155d47e08c4590de392 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 18 Mar 2025 09:54:29 -0700
Subject: [PATCH] Fixed building with SDL_LEAN_AND_MEAN

Fixes https://github.com/libsdl-org/SDL/issues/12578

(cherry picked from commit 82335fd0e911239214e0034aee81836f7d59b6ea)
---
 src/render/direct3d/SDL_render_d3d.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index f70b56170bae8..1d395f137c416 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1033,27 +1033,30 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
         data->drawstate.texture = texture;
     } else if (texture) {
         D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
-        UpdateDirtyTexture(data->device, &texturedata->texture);
+        if (texturedata) {
+            UpdateDirtyTexture(data->device, &texturedata->texture);
 #ifdef SDL_HAVE_YUV
-        if (texturedata->yuv) {
-            UpdateDirtyTexture(data->device, &texturedata->utexture);
-            UpdateDirtyTexture(data->device, &texturedata->vtexture);
+            if (texturedata->yuv) {
+                UpdateDirtyTexture(data->device, &texturedata->utexture);
+                UpdateDirtyTexture(data->device, &texturedata->vtexture);
+            }
+#endif // SDL_HAVE_YUV
         }
-#endif
     }
 
     if (texture) {
-        D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
-
         UpdateTextureScaleMode(data, cmd->data.draw.texture_scale_mode, 0);
         UpdateTextureAddressMode(data, cmd->data.draw.texture_address_mode, 0);
 
+#ifdef SDL_HAVE_YUV
+        D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
         if (texturedata && texturedata->yuv) {
             UpdateTextureScaleMode(data, cmd->data.draw.texture_scale_mode, 1);
             UpdateTextureScaleMode(data, cmd->data.draw.texture_scale_mode, 2);
             UpdateTextureAddressMode(data, cmd->data.draw.texture_address_mode, 1);
             UpdateTextureAddressMode(data, cmd->data.draw.texture_address_mode, 2);
         }
+#endif // SDL_HAVE_YUV
     }
 
     if (blend != data->drawstate.blend) {