From bfd47ec8767e7589f86ce4b54372669da2963907 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Fri, 26 Aug 2022 21:51:50 +0200 Subject: [PATCH] [d3d9] Try to match either top or bottom mips in UpdateTexture --- src/d3d9/d3d9_device.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 54b1ab10b..88e5327fc 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -823,9 +823,19 @@ namespace dxvk { uint32_t mipLevels = dstTexInfo->IsAutomaticMip() ? 1 : dstTexInfo->Desc()->MipLevels; uint32_t arraySlices = std::min(srcTexInfo->Desc()->ArraySize, dstTexInfo->Desc()->ArraySize); - uint32_t srcMipOffset = srcTexInfo->Desc()->MipLevels - mipLevels; - VkExtent3D srcFirstMipExtent = util::computeMipLevelExtent(srcTexInfo->GetExtent(), srcMipOffset); + uint32_t srcMipOffset = 0; + VkExtent3D srcFirstMipExtent = srcTexInfo->GetExtent(); VkExtent3D dstFirstMipExtent = dstTexInfo->GetExtent(); + + if (srcFirstMipExtent != dstFirstMipExtent) { + // UpdateTexture can be used with textures that have different mip lengths. + // It will either match the the top mips or the bottom ones. + + srcMipOffset = srcTexInfo->Desc()->MipLevels - mipLevels; + srcFirstMipExtent = util::computeMipLevelExtent(srcTexInfo->GetExtent(), srcMipOffset); + dstFirstMipExtent = dstTexInfo->GetExtent(); + } + if (srcFirstMipExtent != dstFirstMipExtent) return D3DERR_INVALIDCALL;