Skip to content

Commit

Permalink
Fix MipMap count issue
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Nov 15, 2024
1 parent 08512ea commit c0e6f23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 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 7323
#define BUILD_NUMBER 7324
8 changes: 4 additions & 4 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ HRESULT m_IDirectDrawSurfaceX::GetAttachedSurface2(LPDDSCAPS2 lpDDSCaps2, LPDIRE
}
// Use dummy mipmap surface to prevent some games from crashing
DWORD Level = (MipMapLevel & ~DXW_IS_MIPMAP_DUMMY);
if (Level < GetMaxMipMapLevel(surfaceDesc2.dwWidth, surfaceDesc2.dwHeight) + 1)
if (Level < GetMaxMipMapLevel(surfaceDesc2.dwWidth, surfaceDesc2.dwHeight) - 1)
{
while (MipMaps.size() < Level + 1)
{
Expand Down Expand Up @@ -2418,7 +2418,7 @@ HRESULT m_IDirectDrawSurfaceX::GetSurfaceDesc2(LPDDSURFACEDESC2 lpDDSurfaceDesc2
}
if (lpDDSurfaceDesc2->dwFlags & DDSD_MIPMAPCOUNT)
{
lpDDSurfaceDesc2->dwMipMapCount = surfaceDesc2.dwMipMapCount > Level ? surfaceDesc2.dwMipMapCount - Level : 1;
lpDDSurfaceDesc2->dwMipMapCount = 1;
}
}
// Handle MipMap sub-level
Expand Down Expand Up @@ -6026,8 +6026,8 @@ inline void m_IDirectDrawSurfaceX::InitSurfaceDesc(DWORD DirectXVersion)
// Compute mipcount
DWORD MipMapLevelCount = ((surfaceDesc2.dwFlags & DDSD_MIPMAPCOUNT) && surfaceDesc2.dwMipMapCount) ? surfaceDesc2.dwMipMapCount :
GetMaxMipMapLevel(surfaceDesc2.dwWidth, surfaceDesc2.dwHeight);
MaxMipMapLevel = MipMapLevelCount;
surfaceDesc2.dwMipMapCount = MaxMipMapLevel;
MaxMipMapLevel = MipMapLevelCount - 1;
surfaceDesc2.dwMipMapCount = MaxMipMapLevel + 1;
surfaceDesc2.dwFlags |= DDSD_MIPMAPCOUNT;
}
// Mipmap textures
Expand Down

0 comments on commit c0e6f23

Please sign in to comment.