Skip to content

Commit

Permalink
Clear existing rect/volume content on surface/volume locks (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall authored Oct 17, 2024
1 parent b5d8458 commit 2a81c4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/d3d8to9_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ HRESULT STDMETHODCALLTYPE Direct3DSurface8::GetDesc(D3DSURFACE_DESC8 *pDesc)
}
HRESULT STDMETHODCALLTYPE Direct3DSurface8::LockRect(D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags)
{
D3DSURFACE_DESC8 SurfaceDesc;

const HRESULT hr = GetDesc(&SurfaceDesc);

// D3D8 clears the contents of pLockedRect for all
// surfaces except those of type D3DRTYPE_TEXTURE
if (SUCCEEDED(hr) && pLockedRect != nullptr && SurfaceDesc.Type != D3DRTYPE_TEXTURE)
{
pLockedRect->pBits = nullptr;
pLockedRect->Pitch = 0;
}

return ProxyInterface->LockRect(pLockedRect, pRect, Flags);
}
HRESULT STDMETHODCALLTYPE Direct3DSurface8::UnlockRect()
Expand Down
8 changes: 8 additions & 0 deletions source/d3d8to9_volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ HRESULT STDMETHODCALLTYPE Direct3DVolume8::GetDesc(D3DVOLUME_DESC8 *pDesc)
}
HRESULT STDMETHODCALLTYPE Direct3DVolume8::LockBox(D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags)
{
if (pLockedVolume != nullptr)
{
// D3D8 clears the contents of pLockedVolume
pLockedVolume->pBits = nullptr;
pLockedVolume->RowPitch = 0;
pLockedVolume->SlicePitch = 0;
}

return ProxyInterface->LockBox(pLockedVolume, pBox, Flags);
}
HRESULT STDMETHODCALLTYPE Direct3DVolume8::UnlockBox()
Expand Down

0 comments on commit 2a81c4e

Please sign in to comment.