Skip to content

Commit

Permalink
[d3d8] Validate DS dimensions on SetRenderTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Nov 19, 2024
1 parent 3a36152 commit 0e3509c
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,31 @@ namespace dxvk {
// SetDepthStencilSurface is a separate call
D3D8Surface* zStencil = static_cast<D3D8Surface*>(pNewZStencil);

if (likely(m_depthStencil != zStencil)) {
StateChange();
res = GetD3D9()->SetDepthStencilSurface(D3D8Surface::GetD3D9Nullable(zStencil));
// Depth stencil dimensions can not be lower than
// those of the currently set render target.
if (m_renderTarget != nullptr && zStencil != nullptr) {
D3DSURFACE_DESC rtDesc;
res = m_renderTarget->GetDesc(&rtDesc);

if (unlikely(FAILED(res))) return res;

D3DSURFACE_DESC dsDesc;
res = zStencil->GetDesc(&dsDesc);

if (unlikely(FAILED(res))) return res;

m_depthStencil = zStencil;
if (unlikely(dsDesc.Width < rtDesc.Width
|| dsDesc.Height < rtDesc.Height))
return D3DERR_INVALIDCALL;
}

StateChange();
res = GetD3D9()->SetDepthStencilSurface(D3D8Surface::GetD3D9Nullable(zStencil));

if (unlikely(FAILED(res))) return res;

m_depthStencil = zStencil;

return D3D_OK;
}

Expand Down

0 comments on commit 0e3509c

Please sign in to comment.