diff --git a/Dllmain/BuildNo.rc b/Dllmain/BuildNo.rc index e75896cb..5fcde554 100644 --- a/Dllmain/BuildNo.rc +++ b/Dllmain/BuildNo.rc @@ -1 +1 @@ -#define BUILD_NUMBER 7036 +#define BUILD_NUMBER 7037 diff --git a/ddraw/IDirectDrawSurfaceX.cpp b/ddraw/IDirectDrawSurfaceX.cpp index b528d191..a47cd5f7 100644 --- a/ddraw/IDirectDrawSurfaceX.cpp +++ b/ddraw/IDirectDrawSurfaceX.cpp @@ -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))) { @@ -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; diff --git a/ddraw/IDirectDrawSurfaceX.h b/ddraw/IDirectDrawSurfaceX.h index 08fbbedf..7e5ffa74 100644 --- a/ddraw/IDirectDrawSurfaceX.h +++ b/ddraw/IDirectDrawSurfaceX.h @@ -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]); diff --git a/ddraw/IDirectDrawX.cpp b/ddraw/IDirectDrawX.cpp index 57ca477a..33aa8311 100644 --- a/ddraw/IDirectDrawX.cpp +++ b/ddraw/IDirectDrawX.cpp @@ -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