From 2d39be4e72aca562f73aa771c27333fd70debe8b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 14 Mar 2019 01:11:39 +0100 Subject: [PATCH] [d3d11] Check image block alignment in UpdateSubresource1 Fixes validation errors in World of Warcraft, which for some reason tries to update individual pixels of block-compressed textures. See #964. --- src/d3d11/d3d11_context.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index a128182d..d99309af 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1137,8 +1137,10 @@ namespace dxvk { textureInfo->GetSubresourceFromIndex( VK_IMAGE_ASPECT_COLOR_BIT, DstSubresource); + VkExtent3D mipExtent = textureInfo->GetImage()->mipLevelExtent(subresource.mipLevel); + VkOffset3D offset = { 0, 0, 0 }; - VkExtent3D extent = textureInfo->GetImage()->mipLevelExtent(subresource.mipLevel); + VkExtent3D extent = mipExtent; if (pDstBox != nullptr) { if (pDstBox->left >= pDstBox->right @@ -1163,6 +1165,10 @@ namespace dxvk { auto formatInfo = imageFormatInfo( textureInfo->GetImage()->info().format); + if (!util::isBlockAligned(offset, formatInfo->blockSize) + || !util::isBlockAligned(offset, extent, formatInfo->blockSize, mipExtent)) + return; + const VkExtent3D regionExtent = util::computeBlockCount(extent, formatInfo->blockSize); const VkDeviceSize bytesPerRow = regionExtent.width * formatInfo->elementSize;