From 4f90ad46b9051f1615fed14fc60920217d6b0a39 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Fri, 27 Sep 2024 01:15:09 +0300 Subject: [PATCH] [d3d8] Validate D3D9 auto depth stencil query --- src/d3d8/d3d8_device.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/d3d8/d3d8_device.h b/src/d3d8/d3d8_device.h index 51c3fa2dd..0eb0b1ede 100644 --- a/src/d3d8/d3d8_device.h +++ b/src/d3d8/d3d8_device.h @@ -405,9 +405,11 @@ namespace dxvk { m_backBuffers[i] = new D3D8Surface(this, std::move(pSurface9)); } - Com pStencil9 = nullptr; - GetD3D9()->GetDepthStencilSurface(&pStencil9); - m_autoDepthStencil = new D3D8Surface(this, std::move(pStencil9)); + Com pStencil9; + // This call will fail if the D3D9 device is created without + // the EnableAutoDepthStencil presentation parameter set to TRUE. + HRESULT res = GetD3D9()->GetDepthStencilSurface(&pStencil9); + m_autoDepthStencil = FAILED(res) ? nullptr : new D3D8Surface(this, std::move(pStencil9)); m_renderTarget = m_backBuffers[0]; m_depthStencil = m_autoDepthStencil;