1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 04:29:15 +01:00

[d3d9] Validate block aligned format mip > 0 dimensions as well

This commit is contained in:
WinterSnowfall 2025-03-05 12:48:30 +02:00
parent 4a83a16aae
commit 46471a6ad8
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View File

@ -119,7 +119,7 @@ namespace dxvk {
pDesc->MultiSampleType = desc.MultiSample;
pDesc->MultiSampleQuality = desc.MultisampleQuality;
pDesc->Width = std::max(1u, desc.Width >> m_mipLevel);
pDesc->Width = std::max(1u, desc.Width >> m_mipLevel);
pDesc->Height = std::max(1u, desc.Height >> m_mipLevel);
return D3D_OK;
@ -148,9 +148,9 @@ namespace dxvk {
bool isBlockAlignedFormat = blockSize.Width > 0 && blockSize.Height > 0;
// The boundaries of pRect are validated for D3DPOOL_DEFAULT surfaces
// with formats which need to be block aligned (mip 0), surfaces created via
// with formats which need to be block aligned, surfaces created via
// CreateImageSurface and D3D8 cube textures outside of D3DPOOL_DEFAULT
if ((m_mipLevel == 0 && isBlockAlignedFormat && desc.Pool == D3DPOOL_DEFAULT)
if ((isBlockAlignedFormat && desc.Pool == D3DPOOL_DEFAULT)
|| (desc.Pool == D3DPOOL_SYSTEMMEM && type == D3DRTYPE_SURFACE)
|| (m_texture->Device()->IsD3D8Compatible() &&
desc.Pool != D3DPOOL_DEFAULT && type == D3DRTYPE_CUBETEXTURE)) {
@ -161,8 +161,8 @@ namespace dxvk {
|| pRect->right - pRect->left <= 0
|| pRect->bottom - pRect->top <= 0
// Exceeding surface dimensions
|| static_cast<UINT>(pRect->right) > desc.Width
|| static_cast<UINT>(pRect->bottom) > desc.Height)
|| static_cast<UINT>(pRect->right) > std::max(1u, desc.Width >> m_mipLevel)
|| static_cast<UINT>(pRect->bottom) > std::max(1u, desc.Height >> m_mipLevel))
return D3DERR_INVALIDCALL;
}

View File

@ -119,9 +119,9 @@ namespace dxvk {
|| static_cast<LONG>(pBox->Bottom) - static_cast<LONG>(pBox->Top) <= 0
|| static_cast<LONG>(pBox->Back) - static_cast<LONG>(pBox->Front) <= 0
// Exceeding surface dimensions
|| pBox->Right > desc.Width
|| pBox->Bottom > desc.Height
|| pBox->Back > desc.Depth)
|| pBox->Right > std::max(1u, desc.Width >> m_mipLevel)
|| pBox->Bottom > std::max(1u, desc.Height >> m_mipLevel)
|| pBox->Back > std::max(1u, desc.Depth >> m_mipLevel))
return D3DERR_INVALIDCALL;
}