Skip to content

Commit

Permalink
Set correct depth stencil surface size
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jun 8, 2024
1 parent a3834e0 commit 47b4aab
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 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 7036
#define BUILD_NUMBER 7037
16 changes: 15 additions & 1 deletion ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ HRESULT m_IDirectDrawSurfaceX::GetAttachedSurface2(LPDDSCAPS2 lpDDSCaps2, LPDIRE
if (!lpFoundSurface)
{
// Handle mipmaps
if (MipMaps.size() && (DDSCAPS_MIPMAP & lpDDSCaps2->dwCaps) && (GetSurfaceCaps().dwCaps & lpDDSCaps2->dwCaps) == lpDDSCaps2->dwCaps)
if (MipMaps.size() && (lpDDSCaps2->dwCaps & DDSCAPS_MIPMAP) && (GetSurfaceCaps().dwCaps & lpDDSCaps2->dwCaps) == lpDDSCaps2->dwCaps)
{
if (SUCCEEDED(GetMipMapSubLevel(lplpDDAttachedSurface, MipMapLevel, DirectXVersion)))
{
Expand All @@ -1601,6 +1601,20 @@ HRESULT m_IDirectDrawSurfaceX::GetAttachedSurface2(LPDDSCAPS2 lpDDSCaps2, LPDIRE
return DDERR_NOTFOUND;
}

// Handle zbuffer
if ((lpDDSCaps2->dwCaps && DDSCAPS_ZBUFFER) && (IsRenderingTarget() || (GetSurfaceCaps().dwCaps & DDSCAPS_BACKBUFFER)))
{
m_IDirectDrawSurfaceX* m_SurfaceX = ddrawParent->GetDepthStencilSurface();
if (m_SurfaceX)
{
*lplpDDAttachedSurface = (LPDIRECTDRAWSURFACE7)m_SurfaceX->GetWrapperInterfaceX(DirectXVersion);

(*lplpDDAttachedSurface)->AddRef();

return DD_OK;
}
}

LOG_LIMIT(100, __FUNCTION__ << " Error: failed to find attached surface that matches the capabilities requested: " << *lpDDSCaps2 <<
" Attached number of surfaces: " << AttachedSurfaceMap.size() << " MaxMipMapLevel: " << MaxMipMapLevel);
return DDERR_NOTFOUND;
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawSurfaceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
inline bool IsSurfaceManaged() { return (surfaceDesc2.ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)) != 0; }
inline bool IsUsingEmulation() { return (surface.emu && surface.emu->DC && surface.emu->GameDC && surface.emu->pBits); }
inline bool IsEmulationDCReady() { return (IsUsingEmulation() && !surface.emu->UsingGameDC); }
inline bool IsSurface3DDevice() { return Is3DRenderingTarget; }
inline bool IsRenderingTarget() { return Is3DRenderingTarget; }
inline bool IsSurfaceDirty() { return surface.IsDirtyFlag; }
inline DWORD GetD39MipMapLevel(DWORD MipMapLevel) { return min(MipMapLevel, MaxMipMapLevel - 1); }
bool GetColorKeyForShader(float(&lowColorKey)[4], float(&highColorKey)[4]);
Expand Down
8 changes: 7 additions & 1 deletion ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,18 @@ HRESULT m_IDirectDrawX::CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRE

// ToDo: handle Config.DdrawOverrideStencilFormat

Logging::Log() << __FUNCTION__ << " Found Stencil surface: " << GetDisplayFormat(Desc2.ddpfPixelFormat);
Logging::Log() << __FUNCTION__ << " Found Stencil surface: " << GetDisplayFormat(Desc2.ddpfPixelFormat);

if (IsDepthStencilSurface && DepthStencilSurface)
{
Logging::Log() << __FUNCTION__ << " Warning: Creating a second depth stencil surface! " << Desc2;
}

if (d3d9Device && DisplayMode.Width && DisplayMode.Height && (DisplayMode.Width != Desc2.dwWidth || DisplayMode.Height != Desc2.dwHeight))
{
Desc2.dwWidth = DisplayMode.Width;
Desc2.dwHeight = DisplayMode.Height;
}
}

// Check if there is a change in the present parameters
Expand Down

0 comments on commit 47b4aab

Please sign in to comment.