diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 3fbc0743..315ff6b5 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -925,6 +925,12 @@ namespace dxvk { blitInfo.srcOffsets[1] = pSourceRect != nullptr ? VkOffset3D{ int32_t(pSourceRect->right), int32_t(pSourceRect->bottom), 1 } : VkOffset3D{ int32_t(srcExtent.width), int32_t(srcExtent.height), 1 }; + + if (unlikely(IsBlitRegionInvalid(blitInfo.srcOffsets, srcExtent))) + return D3DERR_INVALIDCALL; + + if (unlikely(IsBlitRegionInvalid(blitInfo.dstOffsets, dstExtent))) + return D3DERR_INVALIDCALL; VkExtent3D srcCopyExtent = { uint32_t(blitInfo.srcOffsets[1].x - blitInfo.srcOffsets[0].x), diff --git a/src/d3d9/d3d9_util.h b/src/d3d9/d3d9_util.h index 4d0f78a0..2ef074cc 100644 --- a/src/d3d9/d3d9_util.h +++ b/src/d3d9/d3d9_util.h @@ -247,6 +247,16 @@ namespace dxvk { || (srcFormat == D3D9Format::A4R4G4B4 && dstFormat == D3D9Format::X4R4G4B4); } + inline bool IsBlitRegionInvalid(VkOffset3D offsets[2], VkExtent3D extent) { + // Only bother checking x, y as we don't have 3D blits. + return offsets[1].x < offsets[0].x || + offsets[1].y < offsets[0].y || + offsets[0].x < 0 || + offsets[0].y < 0 || + offsets[1].x > extent.width || + offsets[1].y > extent.height; + } + enum D3D9TextureStageStateTypes : uint32_t { DXVK_TSS_COLOROP = 0,