From 42c66c410e213f7504903744a5684a4e453f71f2 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 6 Apr 2022 17:03:55 +0200 Subject: [PATCH] [d3d9] Calculate slice alignment when uploading straight from the mapping buffer --- src/d3d9/d3d9_device.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 2e6491dfa..baeb28a39 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4478,6 +4478,7 @@ namespace dxvk { + srcOffsetBlockCount.y * pitch + srcOffsetBlockCount.x * formatInfo->elementSize; + VkDeviceSize sliceAlignment = 1; VkDeviceSize rowAlignment = 1; DxvkBufferSlice copySrcSlice; if (pSrcTexture->DoesStagingBufferUploads(SrcSubresource)) { @@ -4490,7 +4491,9 @@ namespace dxvk { pitch, pitch * srcTexLevelExtentBlockCount.height); } else { copySrcSlice = DxvkBufferSlice(pSrcTexture->GetBuffer(SrcSubresource), copySrcOffset, srcSlice.length); - rowAlignment = pitch; // row alignment can act as the pitch parameter + // row/slice alignment can act as the pitch parameter + rowAlignment = pitch; + sliceAlignment = srcTexLevelExtentBlockCount.height * pitch; } EmitCs([ @@ -4499,13 +4502,14 @@ namespace dxvk { cDstLayers = dstLayers, cDstLevelExtent = alignedExtent, cOffset = alignedDestOffset, - cRowAlignment = rowAlignment + cRowAlignment = rowAlignment, + cSliceAlignment = sliceAlignment ] (DxvkContext* ctx) { ctx->copyBufferToImage( cDstImage, cDstLayers, cOffset, cDstLevelExtent, cSrcSlice.buffer(), cSrcSlice.offset(), - cRowAlignment, 0); + cRowAlignment, cSliceAlignment); }); TrackTextureMappingBufferSequenceNumber(pSrcTexture, SrcSubresource);