Calculate tighter bounds for data copied in D3D11 initial states

* This can be a problem since copying by pitch * count can slightly over-read if
  the pitch is larger than a row or slice, potentially reading into unmapped
  pages.
This commit is contained in:
baldurk
2024-02-23 14:09:40 +00:00
parent ac18f52757
commit 36f4432351
+16 -2
View File
@@ -696,7 +696,13 @@ bool WrappedID3D11Device::Serialise_InitialState(SerialiserType &ser, ResourceId
{
SubresourceContents = mapped.pData;
RowPitch = mapped.RowPitch;
ContentsLength = RowPitch * numRows;
const uint32_t rowLength = GetByteSize(desc.Width, 1, 1, desc.Format, mip);
RDCASSERT(RowPitch >= rowLength);
ContentsLength = RowPitch * (RDCMAX(1U, numRows) - 1);
ContentsLength += rowLength;
}
}
@@ -878,8 +884,16 @@ bool WrappedID3D11Device::Serialise_InitialState(SerialiserType &ser, ResourceId
SubresourceContents = mapped.pData;
RowPitch = mapped.RowPitch;
DepthPitch = mapped.DepthPitch;
const uint32_t numSlices = RDCMAX(1U, desc.Depth >> mip);
const uint32_t rowLength = GetByteSize(desc.Width, 1, 1, desc.Format, mip);
RDCASSERT(RowPitch >= rowLength);
RDCASSERT(DepthPitch >= RowPitch * numRows);
ContentsLength = DepthPitch * RDCMAX(1U, desc.Depth >> mip);
ContentsLength = DepthPitch * (RDCMAX(1U, numSlices) - 1);
ContentsLength += RowPitch * (RDCMAX(1U, numRows) - 1);
ContentsLength += rowLength;
}
}