From fc3515c16f9779ceffb632ab56c82855c389c9cb Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 26 Mar 2019 18:10:22 +0100 Subject: [PATCH] [d3d11] Implement depth-stencil uploads in UpdateSubresource1 --- src/d3d11/d3d11_context.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index ce33c1d70..349757ec9 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1123,9 +1123,13 @@ namespace dxvk { } else { const D3D11CommonTexture* textureInfo = GetCommonTexture(pDstResource); - const VkImageSubresource subresource = - textureInfo->GetSubresourceFromIndex( - VK_IMAGE_ASPECT_COLOR_BIT, DstSubresource); + VkFormat packedFormat = m_parent->LookupPackedFormat( + textureInfo->Desc()->Format, + textureInfo->GetFormatMode()).Format; + + auto formatInfo = imageFormatInfo(packedFormat); + auto subresource = textureInfo->GetSubresourceFromIndex( + formatInfo->aspectMask, DstSubresource); VkExtent3D mipExtent = textureInfo->GetImage()->mipLevelExtent(subresource.mipLevel); @@ -1152,9 +1156,6 @@ namespace dxvk { subresource.mipLevel, subresource.arrayLayer, 1 }; - auto formatInfo = imageFormatInfo( - textureInfo->GetImage()->info().format); - if (!util::isBlockAligned(offset, formatInfo->blockSize) || !util::isBlockAligned(offset, extent, formatInfo->blockSize, mipExtent)) return; @@ -1180,11 +1181,20 @@ namespace dxvk { cDstExtent = extent, cSrcData = std::move(imageDataBuffer), cSrcBytesPerRow = bytesPerRow, - cSrcBytesPerLayer = bytesPerLayer + cSrcBytesPerLayer = bytesPerLayer, + cPackedFormat = packedFormat ] (DxvkContext* ctx) { - ctx->updateImage(cDstImage, cDstLayers, - cDstOffset, cDstExtent, cSrcData.ptr(), - cSrcBytesPerRow, cSrcBytesPerLayer); + if (cDstLayers.aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { + ctx->updateImage(cDstImage, cDstLayers, + cDstOffset, cDstExtent, cSrcData.ptr(), + cSrcBytesPerRow, cSrcBytesPerLayer); + } else { + ctx->updateDepthStencilImage(cDstImage, cDstLayers, + VkOffset2D { cDstOffset.x, cDstOffset.y }, + VkExtent2D { cDstExtent.width, cDstExtent.height }, + cSrcData.ptr(), cSrcBytesPerRow, cSrcBytesPerLayer, + cPackedFormat); + } }); } }