diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index 2820998ee8..75f0ef6e42 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -6044,7 +6044,11 @@ static void D3D12_UploadToTexture( needsPlacementCopy = source->offset % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT != 0; } - alignedBytesPerSlice = alignedRowPitch * destination->h; + alignedBytesPerSlice = alignedRowPitch * blockHeight; + if (!renderer->UnrestrictedBufferTextureCopyPitchSupported && destination->d > 1 && alignedBytesPerSlice % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT != 0) { + needsRealignment = true; + alignedBytesPerSlice = D3D12_INTERNAL_Align(alignedBytesPerSlice, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); + } sourceLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; sourceLocation.PlacedFootprint.Footprint.Format = SDLToD3D12_TextureFormat[textureContainer->header.info.format]; @@ -6058,7 +6062,7 @@ static void D3D12_UploadToTexture( temporaryBuffer = D3D12_INTERNAL_CreateBuffer( d3d12CommandBuffer->renderer, 0, - alignedRowPitch * blockHeight * destination->d, + alignedBytesPerSlice * destination->d, D3D12_BUFFER_TYPE_UPLOAD, NULL);