From 4aa6800e95b093f259123107190ca56dae24e3be Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 13 Feb 2020 00:39:55 +0100 Subject: [PATCH] [d3d11] Validate subresource index in copy operations Rocket League tries to copy five subresources of a texture that only has one single array layer and one single mip map, which causes GPU hangs on Nvidia drivers. --- src/d3d11/d3d11_context.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 8fd5e37b..0cb8dcec 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -409,6 +409,10 @@ namespace dxvk { const VkImageSubresource dstSubresource = dstTextureInfo->GetSubresourceFromIndex(dstFormatInfo->aspectMask, DstSubresource); const VkImageSubresource srcSubresource = srcTextureInfo->GetSubresourceFromIndex(srcFormatInfo->aspectMask, SrcSubresource); + if (DstSubresource >= dstTextureInfo->CountSubresources() + || SrcSubresource >= srcTextureInfo->CountSubresources()) + return; + // Copies are only supported on size-compatible formats if (dstFormatInfo->elementSize != srcFormatInfo->elementSize) { Logger::err(str::format( @@ -468,7 +472,7 @@ namespace dxvk { srcSubresource.aspectMask, srcSubresource.mipLevel, srcSubresource.arrayLayer, 1 }; - + // Copying multiple slices does not // seem to be supported in D3D11 if (copy2Dto3D || copy3Dto2D) { @@ -1190,6 +1194,9 @@ namespace dxvk { } else { const D3D11CommonTexture* textureInfo = GetCommonTexture(pDstResource); + if (DstSubresource >= textureInfo->CountSubresources()) + return; + VkFormat packedFormat = m_parent->LookupPackedFormat( textureInfo->Desc()->Format, textureInfo->GetFormatMode()).Format; @@ -1376,6 +1383,10 @@ namespace dxvk { auto dstVulkanFormatInfo = imageFormatInfo(dstFormatInfo.Format); auto srcVulkanFormatInfo = imageFormatInfo(srcFormatInfo.Format); + if (DstSubresource >= dstTextureInfo->CountSubresources() + || SrcSubresource >= srcTextureInfo->CountSubresources()) + return; + const VkImageSubresource dstSubresource = dstTextureInfo->GetSubresourceFromIndex( dstVulkanFormatInfo->aspectMask, DstSubresource);