1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +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

@ -148,9 +148,9 @@ namespace dxvk {
bool isBlockAlignedFormat = blockSize.Width > 0 && blockSize.Height > 0; bool isBlockAlignedFormat = blockSize.Width > 0 && blockSize.Height > 0;
// The boundaries of pRect are validated for D3DPOOL_DEFAULT surfaces // 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 // 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) || (desc.Pool == D3DPOOL_SYSTEMMEM && type == D3DRTYPE_SURFACE)
|| (m_texture->Device()->IsD3D8Compatible() && || (m_texture->Device()->IsD3D8Compatible() &&
desc.Pool != D3DPOOL_DEFAULT && type == D3DRTYPE_CUBETEXTURE)) { desc.Pool != D3DPOOL_DEFAULT && type == D3DRTYPE_CUBETEXTURE)) {
@ -161,8 +161,8 @@ namespace dxvk {
|| pRect->right - pRect->left <= 0 || pRect->right - pRect->left <= 0
|| pRect->bottom - pRect->top <= 0 || pRect->bottom - pRect->top <= 0
// Exceeding surface dimensions // Exceeding surface dimensions
|| static_cast<UINT>(pRect->right) > desc.Width || static_cast<UINT>(pRect->right) > std::max(1u, desc.Width >> m_mipLevel)
|| static_cast<UINT>(pRect->bottom) > desc.Height) || static_cast<UINT>(pRect->bottom) > std::max(1u, desc.Height >> m_mipLevel))
return D3DERR_INVALIDCALL; 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->Bottom) - static_cast<LONG>(pBox->Top) <= 0
|| static_cast<LONG>(pBox->Back) - static_cast<LONG>(pBox->Front) <= 0 || static_cast<LONG>(pBox->Back) - static_cast<LONG>(pBox->Front) <= 0
// Exceeding surface dimensions // Exceeding surface dimensions
|| pBox->Right > desc.Width || pBox->Right > std::max(1u, desc.Width >> m_mipLevel)
|| pBox->Bottom > desc.Height || pBox->Bottom > std::max(1u, desc.Height >> m_mipLevel)
|| pBox->Back > desc.Depth) || pBox->Back > std::max(1u, desc.Depth >> m_mipLevel))
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }