From 6462174c135869ad435cb8c309857ae9df86539d Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 20 May 2021 05:41:32 +0200 Subject: [PATCH] [dxvk] Support multi-plane formats in copyImageToBuffer --- src/d3d11/d3d11_context.cpp | 3 +-- src/d3d9/d3d9_device.cpp | 6 ++---- src/d3d9/d3d9_swapchain.cpp | 3 +-- src/dxvk/dxvk_context.cpp | 15 +++------------ src/dxvk/dxvk_context.h | 2 +- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index cc942fe49..637b0a3fc 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -4052,8 +4052,7 @@ namespace dxvk { cPackedFormat = packedFormat ] (DxvkContext* ctx) { if (cSubresources.aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { - ctx->copyImageToBuffer( - cImageBuffer, 0, VkExtent2D { 0u, 0u }, + ctx->copyImageToBuffer(cImageBuffer, 0, 0, cImage, cSubresources, VkOffset3D { 0, 0, 0 }, cLevelExtent); } else { diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index cd7d16a60..9bda0f255 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -866,8 +866,7 @@ namespace dxvk { cLevelExtent = srcExtent, cDstExtent = dstExtent ] (DxvkContext* ctx) { - ctx->copyImageToBuffer( - cBuffer, 0, cDstExtent, + ctx->copyImageToBuffer(cBuffer, 0, 4, cImage, cSubresources, VkOffset3D { 0, 0, 0 }, cLevelExtent); }); @@ -4162,8 +4161,7 @@ namespace dxvk { cPackedFormat = packedFormat ] (DxvkContext* ctx) { if (cSubresources.aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { - ctx->copyImageToBuffer( - cImageBuffer, 0, VkExtent2D { 0u, 0u }, + ctx->copyImageToBuffer(cImageBuffer, 0, 0, cImage, cSubresources, VkOffset3D { 0, 0, 0 }, cLevelExtent); } else { diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 222b8ef43..f38d7a978 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -456,8 +456,7 @@ namespace dxvk { cSubresources = srcSubresourceLayers, cLevelExtent = srcExtent ] (DxvkContext* ctx) { - ctx->copyImageToBuffer( - cBuffer, 0, VkExtent2D { 0u, 0u }, + ctx->copyImageToBuffer(cBuffer, 0, 0, cImage, cSubresources, VkOffset3D { 0, 0, 0 }, cLevelExtent); }); diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index d6399fd86..f13e8992c 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -892,7 +892,7 @@ namespace dxvk { void DxvkContext::copyImageToBuffer( const Rc& dstBuffer, VkDeviceSize dstOffset, - VkExtent2D dstExtent, + VkDeviceSize rowAlignment, const Rc& srcImage, VkImageSubresourceLayers srcSubresource, VkOffset3D srcOffset, @@ -926,17 +926,8 @@ namespace dxvk { m_execAcquires.recordCommands(m_cmd); - VkBufferImageCopy copyRegion; - copyRegion.bufferOffset = dstSlice.offset; - copyRegion.bufferRowLength = dstExtent.width; - copyRegion.bufferImageHeight = dstExtent.height; - copyRegion.imageSubresource = srcSubresource; - copyRegion.imageOffset = srcOffset; - copyRegion.imageExtent = srcExtent; - - m_cmd->cmdCopyImageToBuffer(DxvkCmdBuffer::ExecBuffer, - srcImage->handle(), srcImageLayoutTransfer, - dstSlice.handle, 1, ©Region); + this->copyImageBufferData(DxvkCmdBuffer::ExecBuffer, srcImage, srcSubresource, + srcOffset, srcExtent, srcImageLayoutTransfer, dstSlice, rowAlignment, 0); m_execBarriers.accessImage( srcImage, srcSubresourceRange, diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 5cb119722..61dc8fd02 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -409,7 +409,7 @@ namespace dxvk { void copyImageToBuffer( const Rc& dstBuffer, VkDeviceSize dstOffset, - VkExtent2D dstExtent, + VkDeviceSize rowAlignment, const Rc& srcImage, VkImageSubresourceLayers srcSubresource, VkOffset3D srcOffset,