Skip to content

Commit 1e27bb3

Browse files
committed
Fix D3D12 DSV creation for array/cube/cube-array depth textures
DSV creation was missing a TEXTURE2DARRAY branch for array, cube, and cube-array depth textures. It fell through to TEXTURE2D, so FirstArraySlice was never set and all layers' DSVs targeted layer 0. This caused incorrect rendering when using depth textures with multiple layers, such as cubemap shadow maps.
1 parent 72ed7d0 commit 1e27bb3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/gpu/d3d12/SDL_gpu_d3d12.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3646,7 +3646,12 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture(
36463646
dsvDesc.Format = SDLToD3D12_DepthFormat[createinfo->format];
36473647
dsvDesc.Flags = (D3D12_DSV_FLAGS)0;
36483648

3649-
if (isMultisample) {
3649+
if (createinfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY || createinfo->type == SDL_GPU_TEXTURETYPE_CUBE || createinfo->type == SDL_GPU_TEXTURETYPE_CUBE_ARRAY) {
3650+
dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY;
3651+
dsvDesc.Texture2DArray.MipSlice = levelIndex;
3652+
dsvDesc.Texture2DArray.FirstArraySlice = layerIndex;
3653+
dsvDesc.Texture2DArray.ArraySize = 1;
3654+
} else if (isMultisample) {
36503655
dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DMS;
36513656
} else {
36523657
dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;

0 commit comments

Comments
 (0)