From 67ea67f191450cedf99b5b0ae70c1a5c72335e20 Mon Sep 17 00:00:00 2001
From: Katelyn Gadd <[EMAIL REDACTED]>
Date: Wed, 1 Jan 2025 23:21:37 -0800
Subject: [PATCH] Fix mip generation for 2x1 textures on D3D12
---
src/gpu/d3d12/SDL_gpu_d3d12.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c
index c064d33d5d1c3..d073b88f196fd 100644
--- a/src/gpu/d3d12/SDL_gpu_d3d12.c
+++ b/src/gpu/d3d12/SDL_gpu_d3d12.c
@@ -6222,16 +6222,16 @@ static void D3D12_GenerateMipmaps(
blitInfo.source.layer_or_depth_plane = layerOrDepthIndex;
blitInfo.source.x = 0;
blitInfo.source.y = 0;
- blitInfo.source.w = container->header.info.width >> (levelIndex - 1);
- blitInfo.source.h = container->header.info.height >> (levelIndex - 1);
+ blitInfo.source.w = SDL_max(container->header.info.width >> (levelIndex - 1), 1);
+ blitInfo.source.h = SDL_max(container->header.info.height >> (levelIndex - 1), 1);
blitInfo.destination.texture = texture;
blitInfo.destination.mip_level = levelIndex;
blitInfo.destination.layer_or_depth_plane = layerOrDepthIndex;
blitInfo.destination.x = 0;
blitInfo.destination.y = 0;
- blitInfo.destination.w = container->header.info.width >> levelIndex;
- blitInfo.destination.h = container->header.info.height >> levelIndex;
+ blitInfo.destination.w = SDL_max(container->header.info.width >> levelIndex, 1);
+ blitInfo.destination.h = SDL_max(container->header.info.height >> levelIndex, 1);
blitInfo.load_op = SDL_GPU_LOADOP_DONT_CARE;
blitInfo.filter = SDL_GPU_FILTER_LINEAR;