1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 10:54:16 +01:00

[d3d9] Validate blit regions are in range

Closes #1392
This commit is contained in:
Joshua Ashton 2020-02-04 23:45:32 +00:00
parent 92ee9c7ef1
commit 87dd8f0122
2 changed files with 16 additions and 0 deletions

View File

@ -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),

View File

@ -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,