[d3d8/9] Clear pLockedRect/Box contents universally on lock

This commit is contained in:
WinterSnowfall 2024-12-22 23:16:37 +02:00
parent 9a244e8951
commit 5c7d44955e
No known key found for this signature in database
2 changed files with 10 additions and 10 deletions

View file

@ -124,17 +124,19 @@ namespace dxvk {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
D3DBOX box; D3DBOX box;
auto& desc = *(m_texture->Desc());
D3DRESOURCETYPE type = m_texture->GetType(); D3DRESOURCETYPE type = m_texture->GetType();
if (m_texture->Device()->IsD3D8Compatible() && type != D3DRTYPE_TEXTURE) { // LockRect clears any existing content present in pLockedRect,
// D3D8 LockRect clears any existing content present in // for surfaces in D3DPOOL_DEFAULT. D3D8 additionally clears the content
// pLockedRect for anything beside D3DRTYPE_TEXTURE surfaces // for non-D3DPOOL_DEFAULT surfaces if their type is not D3DRTYPE_TEXTURE.
if (desc.Pool == D3DPOOL_DEFAULT
|| (m_texture->Device()->IsD3D8Compatible() && type != D3DRTYPE_TEXTURE)) {
pLockedRect->pBits = nullptr; pLockedRect->pBits = nullptr;
pLockedRect->Pitch = 0; pLockedRect->Pitch = 0;
} }
if (unlikely(pRect != nullptr)) { if (unlikely(pRect != nullptr)) {
auto& desc = *(m_texture->Desc());
D3D9_FORMAT_BLOCK_SIZE blockSize = GetFormatAlignedBlockSize(desc.Format); D3D9_FORMAT_BLOCK_SIZE blockSize = GetFormatAlignedBlockSize(desc.Format);
bool isBlockAlignedFormat = blockSize.Width > 0 && blockSize.Height > 0; bool isBlockAlignedFormat = blockSize.Width > 0 && blockSize.Height > 0;

View file

@ -102,12 +102,10 @@ namespace dxvk {
if (unlikely(pLockedBox == nullptr)) if (unlikely(pLockedBox == nullptr))
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
if (m_texture->Device()->IsD3D8Compatible()) { // LockBox clears any existing content present in pLockedBox
// D3D8 LockBox clears any existing content present in pLockedBox pLockedBox->pBits = nullptr;
pLockedBox->pBits = nullptr; pLockedBox->RowPitch = 0;
pLockedBox->RowPitch = 0; pLockedBox->SlicePitch = 0;
pLockedBox->SlicePitch = 0;
}
if (unlikely(pBox != nullptr)) { if (unlikely(pBox != nullptr)) {
auto& desc = *(m_texture->Desc()); auto& desc = *(m_texture->Desc());