Skip to content

Commit

Permalink
Fix incorrect pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Mar 26, 2024
1 parent 72e95d4 commit 6914a41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 6980
#define BUILD_NUMBER 6981
7 changes: 6 additions & 1 deletion ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3786,9 +3786,14 @@ HRESULT m_IDirectDrawSurfaceX::CreateD3d9Surface()
IDirect3DSurface9* pDestSurfaceD9 = GetD3D9Surface();
if (pDestSurfaceD9)
{
// Get pitch
LONG Pitch = (Format == D3DFMT_DXT1 || Format == D3DFMT_YV12) ? surfaceDesc2.dwWidth * 2 :
(ISDXTEX(Format)) ? surfaceDesc2.dwWidth * 4 :
surfaceDesc2.lPitch;

// Copy backup data to surface
RECT Rect = { 0, 0, (LONG)surfaceDesc2.dwWidth, (LONG)surfaceDesc2.dwHeight };
if (SUCCEEDED(D3DXLoadSurfaceFromMemory(pDestSurfaceD9, nullptr, &Rect, Backup.data(), (surfaceFormat == D3DFMT_P8) ? D3DFMT_L8 : surfaceFormat, surfaceDesc2.lPitch, nullptr, &Rect, D3DX_FILTER_NONE, 0)))
if (SUCCEEDED(D3DXLoadSurfaceFromMemory(pDestSurfaceD9, nullptr, &Rect, Backup.data(), (surfaceFormat == D3DFMT_P8) ? D3DFMT_L8 : surfaceFormat, Pitch, nullptr, &Rect, D3DX_FILTER_NONE, 0)))
{
// Copy surface to emulated surface
if (IsUsingEmulation())
Expand Down

0 comments on commit 6914a41

Please sign in to comment.