From 495f58370cbd0f27ed70935c40ce56b2e3961199 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 3 Feb 2018 21:14:55 +0100 Subject: [PATCH] [d3d11] Implemented CopySubresourceRegion for buffers Also fixed a typo where ResolveSubresource would do the wrong thing. --- src/d3d11/d3d11_context.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index a362f6c3..6de6ea01 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -217,7 +217,31 @@ namespace dxvk { } if (dstResourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) { - Logger::err("D3D11DeviceContext::CopySubresourceRegion: Buffers not supported"); + auto dstBuffer = static_cast(pDstResource)->GetBufferSlice(); + auto srcBuffer = static_cast(pSrcResource)->GetBufferSlice(); + + VkDeviceSize srcOffset = 0; + VkDeviceSize srcLength = srcBuffer.length(); + + if (pSrcBox != nullptr) { + if (pSrcBox->right > pSrcBox->left) + return; // no-op, but legal + + srcOffset = pSrcBox->left; + srcLength = pSrcBox->right - pSrcBox->left; + } + + EmitCs([ + cDstSlice = dstBuffer.subSlice(DstX, srcLength), + cSrcSlice = srcBuffer.subSlice(srcOffset, srcLength) + ] (DxvkContext* ctx) { + ctx->copyBuffer( + cDstSlice.buffer(), + cDstSlice.offset(), + cSrcSlice.buffer(), + cSrcSlice.offset(), + cSrcSlice.length()); + }); } else { const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource); const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource); @@ -736,7 +760,7 @@ namespace dxvk { cDstImage->mipLevelExtent(cDstLayers.mipLevel)); }); } else if (!srcFormatInfo.flags.test(DxgiFormatFlag::Typeless) - && !srcFormatInfo.flags.test(DxgiFormatFlag::Typeless)) { + && !dstFormatInfo.flags.test(DxgiFormatFlag::Typeless)) { if (dstDesc.Format != srcDesc.Format) { Logger::err("D3D11: ResolveSubresource: Incompatible formats"); return;