Skip to content

Commit

Permalink
Update names to keep consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 4, 2024
1 parent 36b50c6 commit 5ae5765
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 48 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 7117
#define BUILD_NUMBER 7118
2 changes: 1 addition & 1 deletion Logging/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ std::ostream& operator<<(std::ostream& os, const D3DSURFACETYPE& ddType)
ddType == D3DTYPE_OFFPLAINSURFACE ? "D3DTYPE_OFFPLAINSURFACE" :
ddType == D3DTYPE_TEXTURE ? "D3DTYPE_TEXTURE" :
ddType == D3DTYPE_RENDERTARGET ? "D3DTYPE_RENDERTARGET" :
ddType == D3DTYPE_DEPTHBUFFER ? "D3DTYPE_DEPTHBUFFER" : "D3DTYPE_UNKNOWN");
ddType == D3DTYPE_DEPTHSTENCIL ? "D3DTYPE_DEPTHSTENCIL" : "D3DTYPE_UNKNOWN");
}

std::ostream& operator<<(std::ostream& os, const DDFOURCC& dwFourCC)
Expand Down
4 changes: 2 additions & 2 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ HRESULT m_IDirect3DDeviceX::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlag

if ((dwFlags & D3DCLEAR_TARGET) && lpCurrentRenderTargetX)
{
lpCurrentRenderTargetX->DrawingToSurface();
lpCurrentRenderTargetX->SetRenderTargetDirty();
}

return (*d3d9Device)->Clear(dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
Expand Down Expand Up @@ -4293,7 +4293,7 @@ inline void m_IDirect3DDeviceX::RestoreDrawStates(DWORD dwVertexTypeDesc, DWORD
{
if (lpCurrentRenderTargetX)
{
lpCurrentRenderTargetX->DrawingToSurface();
lpCurrentRenderTargetX->SetRenderTargetDirty();
}
if (Config.DdrawFixByteAlignment > 1)
{
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirect3DTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef enum _D3DSURFACETYPE {
D3DTYPE_OFFPLAINSURFACE = 1,
D3DTYPE_TEXTURE = 2,
D3DTYPE_RENDERTARGET = 3,
D3DTYPE_DEPTHBUFFER = 4
D3DTYPE_DEPTHSTENCIL = 4
} D3DSURFACETYPE;

void ConvertLight(D3DLIGHT7& Light7, D3DLIGHT& Light);
Expand Down
64 changes: 33 additions & 31 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ HRESULT m_IDirectDrawSurfaceX::AddAttachedSurface(LPDIRECTDRAWSURFACE7 lpDDSurfa
return DDERR_SURFACEALREADYATTACHED;
}

if (lpAttachedSurfaceX->IsDepthBuffer() && GetAttachedZBuffer())
if (lpAttachedSurfaceX->IsDepthStencil() && GetAttachedDepthStencil())
{
LOG_LIMIT(100, __FUNCTION__ << " Error: zbuffer surface already exists");
return DDERR_CANNOTATTACHSURFACE;
Expand All @@ -413,9 +413,9 @@ HRESULT m_IDirectDrawSurfaceX::AddAttachedSurface(LPDIRECTDRAWSURFACE7 lpDDSurfa
}

// Update attached stencil surface
if (lpAttachedSurfaceX->IsDepthBuffer())
if (lpAttachedSurfaceX->IsDepthStencil())
{
UpdateAttachedZBuffer(lpAttachedSurfaceX);
UpdateAttachedDepthStencil(lpAttachedSurfaceX);
}

AddAttachedSurfaceToMap(lpAttachedSurfaceX, true);
Expand Down Expand Up @@ -560,10 +560,10 @@ HRESULT m_IDirectDrawSurfaceX::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDS
// Clear the depth stencil surface
if (dwFlags & DDBLT_DEPTHFILL)
{
// ToDo: check surface is stencil is the currently used stencil
if (!(surfaceDesc2.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER))
// Check if the surface or the attached surface is the current depth stencil
if (ddrawParent->GetDepthStencilSurface() != this && ddrawParent->GetDepthStencilSurface() != GetAttachedDepthStencil())
{
LOG_LIMIT(100, __FUNCTION__ << " Error: not Depth Stencil format: " << surfaceDesc2);
LOG_LIMIT(100, __FUNCTION__ << " Error: not current Depth Stencil format: " << surfaceDesc2);
return DDERR_INVALIDPARAMS;
}
return (*d3d9Device)->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0, ConvertDepthValue(lpDDBltFx->dwFillDepth, surface.Format), 0);
Expand Down Expand Up @@ -1013,7 +1013,7 @@ HRESULT m_IDirectDrawSurfaceX::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAW
}

// clear zbuffer
if (lpAttachedSurfaceX->IsDepthBuffer() &&
if (lpAttachedSurfaceX->IsDepthStencil() &&
(ddrawParent->GetDepthStencilSurface() == lpAttachedSurfaceX || ddrawParent->GetRenderTargetSurface() == this))
{
ddrawParent->SetDepthStencilSurface(nullptr);
Expand All @@ -1034,11 +1034,11 @@ HRESULT m_IDirectDrawSurfaceX::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAW
return ProxyInterface->DeleteAttachedSurface(dwFlags, lpDDSAttachedSurface);
}

m_IDirectDrawSurfaceX* m_IDirectDrawSurfaceX::GetAttachedZBuffer()
m_IDirectDrawSurfaceX* m_IDirectDrawSurfaceX::GetAttachedDepthStencil()
{
for (auto& it : AttachedSurfaceMap)
{
if (it.second.pSurface->IsDepthBuffer())
if (it.second.pSurface->IsDepthStencil())
{
return it.second.pSurface;
}
Expand Down Expand Up @@ -4217,7 +4217,7 @@ HRESULT m_IDirectDrawSurfaceX::CreateD3d9Surface()
surface.BitCount = GetBitCount(surface.Format);
SurfaceRequiresEmulation = ((surface.Format == D3DFMT_A8B8G8R8 || surface.Format == D3DFMT_X8B8G8R8 || surface.Format == D3DFMT_B8G8R8 || surface.Format == D3DFMT_R8G8B8 ||
Config.DdrawEmulateSurface || (Config.DdrawRemoveScanlines && IsPrimaryOrBackBuffer()) || ShouldEmulate == SC_FORCE_EMULATED) &&
!IsDepthBuffer() && !(surface.Format & 0xFF000000 /*FOURCC or D3DFMT_DXTx*/) && !surface.UsingSurfaceMemory);
!IsDepthStencil() && !(surface.Format & 0xFF000000 /*FOURCC or D3DFMT_DXTx*/) && !surface.UsingSurfaceMemory);
const bool IsSurfaceEmulated = (SurfaceRequiresEmulation || (IsPrimaryOrBackBuffer() && (Config.DdrawWriteToGDI || Config.DdrawReadFromGDI) && !Using3D));
DCRequiresEmulation = (surface.Format != D3DFMT_R5G6B5 && surface.Format != D3DFMT_X1R5G5B5 && surface.Format != D3DFMT_R8G8B8 && surface.Format != D3DFMT_X8R8G8B8);
const D3DFORMAT Format = ((surfaceDesc2.ddsCaps.dwCaps2 & DDSCAPS2_NOTUSERLOCKABLE) && surface.Format == D3DFMT_D16_LOCKABLE) ? D3DFMT_D16 : ConvertSurfaceFormat(surface.Format);
Expand Down Expand Up @@ -4262,15 +4262,16 @@ HRESULT m_IDirectDrawSurfaceX::CreateD3d9Surface()
HRESULT hr = DD_OK;

do {
// Create depth buffer
if (IsDepthBuffer())
// Create depth stencil
if (IsDepthStencil())
{
surface.Type = D3DTYPE_DEPTHBUFFER;
surface.Type = D3DTYPE_DEPTHSTENCIL;
surface.Usage = D3DUSAGE_DEPTHSTENCIL;
surface.Pool = D3DPOOL_DEFAULT;
if (FAILED((*d3d9Device)->CreateDepthStencilSurface(Width, Height, Format, surface.MultiSampleType, surface.MultiSampleQuality, surface.MultiSampleType ? TRUE : FALSE, &surface.Surface, nullptr)) &&
FAILED((*d3d9Device)->CreateDepthStencilSurface(Width, Height, GetFailoverFormat(Format), surface.MultiSampleType, surface.MultiSampleQuality, surface.MultiSampleType ? TRUE : FALSE, &surface.Surface, nullptr)))
{
LOG_LIMIT(100, __FUNCTION__ << " Error: failed to create depth buffer surface. Size: " << Width << "x" << Height << " Format: " << surface.Format << " dwCaps: " << surfaceDesc2.ddsCaps);
LOG_LIMIT(100, __FUNCTION__ << " Error: failed to create depth stencil surface. Size: " << Width << "x" << Height << " Format: " << surface.Format << " dwCaps: " << surfaceDesc2.ddsCaps);
hr = DDERR_GENERIC;
break;
}
Expand All @@ -4280,6 +4281,7 @@ HRESULT m_IDirectDrawSurfaceX::CreateD3d9Surface()
{
// ToDo: if render surface is a texture then create as a texture (MipMaps can be supported on render target textures)
surface.Type = D3DTYPE_RENDERTARGET;
surface.Usage = D3DUSAGE_RENDERTARGET;
surface.Pool = D3DPOOL_DEFAULT;
BOOL IsLockable = (surface.MultiSampleType || (surfaceDesc2.ddsCaps.dwCaps2 & DDSCAPS2_NOTUSERLOCKABLE)) ? FALSE : TRUE;
if (FAILED((*d3d9Device)->CreateRenderTarget(Width, Height, Format, surface.MultiSampleType, surface.MultiSampleQuality, IsLockable, &surface.Surface, nullptr)) &&
Expand All @@ -4290,10 +4292,10 @@ HRESULT m_IDirectDrawSurfaceX::CreateD3d9Surface()
break;
}
// Update attached stencil surface
m_IDirectDrawSurfaceX* lpAttachedSurfaceX = GetAttachedZBuffer();
m_IDirectDrawSurfaceX* lpAttachedSurfaceX = GetAttachedDepthStencil();
if (lpAttachedSurfaceX)
{
UpdateAttachedZBuffer(lpAttachedSurfaceX);
UpdateAttachedDepthStencil(lpAttachedSurfaceX);
}
}
// Create texture
Expand Down Expand Up @@ -4695,25 +4697,25 @@ HRESULT m_IDirectDrawSurfaceX::CreateDCSurface()
return DD_OK;
}

void m_IDirectDrawSurfaceX::UpdateAttachedZBuffer(m_IDirectDrawSurfaceX* lpAttachedSurfaceX)
void m_IDirectDrawSurfaceX::UpdateAttachedDepthStencil(m_IDirectDrawSurfaceX* lpAttachedSurfaceX)
{
bool HasChanged = false;
// Verify depth buffer's with and height
// Verify depth stencil's with and height
if ((surfaceDesc2.dwFlags & (DDSD_WIDTH | DDSD_HEIGHT)) == (DDSD_WIDTH | DDSD_HEIGHT) &&
(surfaceDesc2.dwWidth != lpAttachedSurfaceX->surfaceDesc2.dwWidth || surfaceDesc2.dwHeight != lpAttachedSurfaceX->surfaceDesc2.dwHeight))
{
HasChanged = true;
lpAttachedSurfaceX->surfaceDesc2.dwWidth = surfaceDesc2.dwWidth;
lpAttachedSurfaceX->surfaceDesc2.dwHeight = surfaceDesc2.dwHeight;
}
// Set depth buffer multisampling
// Set depth stencil multisampling
if (lpAttachedSurfaceX && (surface.MultiSampleType != lpAttachedSurfaceX->surface.MultiSampleType || surface.MultiSampleQuality != lpAttachedSurfaceX->surface.MultiSampleQuality))
{
HasChanged = true;
lpAttachedSurfaceX->surface.MultiSampleType = surface.MultiSampleType;
lpAttachedSurfaceX->surface.MultiSampleQuality = surface.MultiSampleQuality;
}
// If depth buffer changed
// If depth stencil changed
if (HasChanged)
{
lpAttachedSurfaceX->ReleaseD9Surface(false, false);
Expand Down Expand Up @@ -4803,7 +4805,7 @@ void m_IDirectDrawSurfaceX::UpdateSurfaceDesc()
// Set attached stencil surface size
if (IsChanged && (surfaceDesc2.dwFlags & (DDSD_WIDTH | DDSD_HEIGHT)) == (DDSD_WIDTH | DDSD_HEIGHT))
{
m_IDirectDrawSurfaceX* lpAttachedSurfaceX = GetAttachedZBuffer();
m_IDirectDrawSurfaceX* lpAttachedSurfaceX = GetAttachedDepthStencil();
if (lpAttachedSurfaceX && (surfaceDesc2.dwWidth != lpAttachedSurfaceX->surfaceDesc2.dwWidth || surfaceDesc2.dwHeight != lpAttachedSurfaceX->surfaceDesc2.dwHeight))
{
lpAttachedSurfaceX->ReleaseD9Surface(false, false);
Expand Down Expand Up @@ -4951,7 +4953,7 @@ void m_IDirectDrawSurfaceX::ReleaseD9Surface(bool BackupData, bool ResetSurface)
// Backup d3d9 surface texture
if (BackupData)
{
if (surface.SurfaceHasData && (surface.Surface || surface.Texture) && !IsRenderTarget() && !IsDepthBuffer() && (!ResetSurface || IsD9UsingVideoMemory()))
if (surface.SurfaceHasData && (surface.Surface || surface.Texture) && !IsRenderTarget() && !IsDepthStencil() && (!ResetSurface || IsD9UsingVideoMemory()))
{
IsSurfaceLost = true;
LostDeviceBackup.clear();
Expand Down Expand Up @@ -5005,7 +5007,7 @@ void m_IDirectDrawSurfaceX::ReleaseD9Surface(bool BackupData, bool ResetSurface)
ReleaseD9ContextSurface();

// Release d3d9 3D surface
if (surface.Surface && (!ResetSurface || IsD9UsingVideoMemory() || IsDepthBuffer()))
if (surface.Surface && (!ResetSurface || IsD9UsingVideoMemory() || IsDepthStencil()))
{
Logging::LogDebug() << __FUNCTION__ << " Releasing Direct3D9 surface";
ULONG ref = surface.Surface->Release();
Expand Down Expand Up @@ -5487,6 +5489,12 @@ inline HRESULT m_IDirectDrawSurfaceX::LockEmulatedSurface(D3DLOCKED_RECT* pLocke
return DD_OK;
}

void m_IDirectDrawSurfaceX::SetRenderTargetDirty()
{
surface.IsRenderTargetDirty = true;
SetDirtyFlag();
}

// Set dirty flag
void m_IDirectDrawSurfaceX::SetDirtyFlag()
{
Expand All @@ -5502,12 +5510,6 @@ void m_IDirectDrawSurfaceX::SetDirtyFlag()
ChangeUniquenessValue();
}

void m_IDirectDrawSurfaceX::DrawingToSurface()
{
SetDirtyFlag();
surface.IsVideoSurfaceDirty = true;
}

void m_IDirectDrawSurfaceX::ClearDirtyFlags()
{
// Reset dirty flag
Expand Down Expand Up @@ -6067,7 +6069,7 @@ HRESULT m_IDirectDrawSurfaceX::CopySurface(m_IDirectDrawSurfaceX* pSourceSurface
if ((pSourceSurface->surface.Pool == D3DPOOL_DEFAULT && surface.Pool == D3DPOOL_DEFAULT) &&
(pSourceSurface->surface.Type == surface.Type || (pSourceSurface->surface.Type == D3DTYPE_OFFPLAINSURFACE && surface.Type == D3DTYPE_RENDERTARGET)) &&
(!IsStretchRect || (this != pSourceSurface && !ISDXTEX(SrcFormat) && !ISDXTEX(DestFormat) && surface.Type == D3DTYPE_RENDERTARGET)) &&
(surface.Type != D3DTYPE_DEPTHBUFFER || !ddrawParent->IsInScene()) &&
(surface.Type != D3DTYPE_DEPTHSTENCIL || !ddrawParent->IsInScene()) &&
(surface.Type != D3DTYPE_TEXTURE) &&
(!pSourceSurface->IsPalette() && !IsPalette()) &&
!IsColorKey)
Expand Down Expand Up @@ -6095,7 +6097,7 @@ HRESULT m_IDirectDrawSurfaceX::CopySurface(m_IDirectDrawSurfaceX* pSourceSurface

// Use UpdateSurface for copying system memory to video memory
if ((pSourceSurface->surface.Pool == D3DPOOL_SYSTEMMEM && surface.Pool == D3DPOOL_DEFAULT) &&
(pSourceSurface->surface.Type != D3DTYPE_DEPTHBUFFER && surface.Type != D3DTYPE_DEPTHBUFFER) &&
(pSourceSurface->surface.Type != D3DTYPE_DEPTHSTENCIL && surface.Type != D3DTYPE_DEPTHSTENCIL) &&
(pSourceSurface->surface.Format == surface.Format) &&
(!pSourceSurface->IsPalette() && !IsPalette()) &&
!IsStretchRect && !IsColorKey)
Expand Down
10 changes: 5 additions & 5 deletions ddraw/IDirectDrawSurfaceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
bool SurfaceHasData = false;
bool UsingSurfaceMemory = false;
bool IsDirtyFlag = false;
bool IsVideoSurfaceDirty = false;
bool IsRenderTargetDirty = false;
bool IsDrawTextureDirty = false;
bool IsPaletteDirty = false; // Used to detect if the palette surface needs to be updated
DWORD BitCount = 0; // Bit count for this surface
Expand Down Expand Up @@ -253,7 +253,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
void UnsetEmulationGameDC();
HRESULT CreateDCSurface();
void ReleaseDCSurface();
void UpdateAttachedZBuffer(m_IDirectDrawSurfaceX* lpAttachedSurfaceX);
void UpdateAttachedDepthStencil(m_IDirectDrawSurfaceX* lpAttachedSurfaceX);
void UpdateSurfaceDesc();

// Direct3D9 interfaces
Expand Down Expand Up @@ -457,14 +457,14 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
inline bool IsSurfaceTexture() { return (surfaceDesc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE) != 0; }
inline bool IsColorKeyTexture() { return (IsSurfaceTexture() && (surfaceDesc2.dwFlags & DDSD_CKSRCBLT)); }
inline bool IsPalette() { return (surface.Format == D3DFMT_P8); }
inline bool IsDepthBuffer() { return (surfaceDesc2.ddpfPixelFormat.dwFlags & (DDPF_ZBUFFER | DDPF_STENCILBUFFER)) != 0; }
inline bool IsDepthStencil() { return (surfaceDesc2.ddpfPixelFormat.dwFlags & (DDPF_ZBUFFER | DDPF_STENCILBUFFER)) != 0; }
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 IsSurfaceDirty() { return surface.IsDirtyFlag; }
inline bool IsMipMapAutogen() { return surface.Texture && (surface.Usage & D3DUSAGE_AUTOGENMIPMAP); }
inline bool IsMipMapGenerated() { return IsMipMapReadyToUse || IsMipMapAutogen(); }
void DrawingToSurface();
void SetRenderTargetDirty();
void ClearDirtyFlags();
bool GetColorKeyForShader(float(&lowColorKey)[4], float(&highColorKey)[4]);
bool GetColorKeyForPrimaryShader(float(&lowColorKey)[4], float(&highColorKey)[4]);
Expand All @@ -481,7 +481,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
}
return false;
}
m_IDirectDrawSurfaceX* GetAttachedZBuffer();
m_IDirectDrawSurfaceX* GetAttachedDepthStencil();
LPDIRECT3DSURFACE9 GetD3d9Surface();
LPDIRECT3DTEXTURE9 GetD3d9DrawTexture();
LPDIRECT3DTEXTURE9 GetD3d9Texture();
Expand Down
8 changes: 4 additions & 4 deletions ddraw/IDirectDrawTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ConvertSurfaceDesc(DDSURFACEDESC &Desc, DDSURFACEDESC2 &Desc2)
}
ConvertCaps(Desc.ddsCaps, Desc2.ddsCaps);
// Check for dwFlags that did not get converted
if (Desc.dwFlags != Desc2.dwFlags && (Desc.dwFlags - Desc2.dwFlags) != (DDSD_ZBUFFERBITDEPTH - DDSD_PIXELFORMAT))
if (Desc.dwFlags != Desc2.dwFlags && (Desc.dwFlags - Desc2.dwFlags) != ((DWORD)DDSD_ZBUFFERBITDEPTH - (DWORD)DDSD_PIXELFORMAT))
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: (Desc2->Desc) Removing unsupported flags: " << Logging::hex(Desc2.dwFlags & ~Desc.dwFlags));
}
Expand Down Expand Up @@ -115,7 +115,7 @@ void ConvertSurfaceDesc(DDSURFACEDESC2 &Desc2, DDSURFACEDESC &Desc)
// Extra parameters
Desc2.dwTextureStage = 0; // Stage identifier that is used to bind a texture to a specific stage
// Check for dwFlags that did not get converted
if (Desc.dwFlags != Desc2.dwFlags && (Desc.dwFlags - Desc2.dwFlags) != (DDSD_ZBUFFERBITDEPTH - DDSD_PIXELFORMAT))
if (Desc.dwFlags != Desc2.dwFlags && (Desc.dwFlags - Desc2.dwFlags) != ((DWORD)DDSD_ZBUFFERBITDEPTH - (DWORD)DDSD_PIXELFORMAT))
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: (Desc->Desc2) Removing unsupported flags: " << Logging::hex(Desc.dwFlags & ~Desc2.dwFlags));
}
Expand Down Expand Up @@ -434,7 +434,7 @@ DWORD GetBitCount(DDPIXELFORMAT ddpfPixelFormat)
return 0;
}
if (ddpfPixelFormat.dwRGBBitCount && (ddpfPixelFormat.dwFlags &
(DDPF_RGB | DDPF_YUV | DDPF_ALPHA | DDPF_ZBUFFER | DDPF_LUMINANCE | DDPF_BUMPDUDV)))
(DDPF_RGB | DDPF_YUV | DDPF_ALPHA | DDPF_ZBUFFER | DDPF_STENCILBUFFER | DDPF_LUMINANCE | DDPF_BUMPDUDV)))
{
return ddpfPixelFormat.dwRGBBitCount;
}
Expand Down Expand Up @@ -928,7 +928,7 @@ D3DFORMAT GetDisplayFormat(DDPIXELFORMAT ddpfPixelFormat)
}

// zBuffer formats
if (ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
if (ddpfPixelFormat.dwFlags & (DDPF_ZBUFFER | DDPF_STENCILBUFFER))
{
switch (ddpfPixelFormat.dwZBufferBitDepth)
{
Expand Down
6 changes: 3 additions & 3 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3523,7 +3523,7 @@ HRESULT m_IDirectDrawX::SetRenderTargetSurface(m_IDirectDrawSurfaceX* lpSurface)
break;
}

m_IDirectDrawSurfaceX* pSurfaceZBuffer = RenderTargetSurface->GetAttachedZBuffer();
m_IDirectDrawSurfaceX* pSurfaceZBuffer = RenderTargetSurface->GetAttachedDepthStencil();
hr = SetDepthStencilSurface(pSurfaceZBuffer);

if (FAILED(hr))
Expand Down Expand Up @@ -3553,7 +3553,7 @@ HRESULT m_IDirectDrawX::SetDepthStencilSurface(m_IDirectDrawSurfaceX* lpSurface)
hr = d3d9Device->SetDepthStencilSurface(nullptr);
}
}
else if (lpSurface->IsDepthBuffer())
else if (lpSurface->IsDepthStencil())
{
DepthStencilSurface = lpSurface;

Expand Down Expand Up @@ -3609,7 +3609,7 @@ inline void m_IDirectDrawX::ReleaseAllD9Resources(bool BackupData, bool ResetInt
SetCriticalSection();
SetPTCriticalSection();

// Remove render target and depth buffer surfaces
// Remove render target and depth stencil surfaces
if (d3d9Device && (RenderTargetSurface || DepthStencilSurface))
{
SetRenderTargetSurface(nullptr);
Expand Down

0 comments on commit 5ae5765

Please sign in to comment.