1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 01:24:11 +01:00

[d3d8] Validate DS dimensions on SetRenderTarget

This commit is contained in:
WinterSnowfall 2024-11-19 16:13:14 +02:00 committed by Robin Kertels
parent dd183b4a53
commit 423c86bf5e

View File

@ -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;
m_depthStencil = zStencil;
D3DSURFACE_DESC dsDesc;
res = zStencil->GetDesc(&dsDesc);
if (unlikely(FAILED(res))) return res;
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;
}