mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-03 13:24:20 +01:00
[d3d8] Validate viewport dimensions on SetViewport
This commit is contained in:
parent
903f1af176
commit
8e03b64ca4
@ -926,6 +926,22 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D8Device::SetViewport(const D3DVIEWPORT8* pViewport) {
|
||||
if (likely(pViewport != nullptr)) {
|
||||
// we need a valid render target to validate the viewport
|
||||
if (unlikely(m_renderTarget == nullptr))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
D3DSURFACE_DESC rtDesc;
|
||||
HRESULT res = m_renderTarget->GetDesc(&rtDesc);
|
||||
|
||||
// D3D8 will fail when setting a viewport that's outside of the
|
||||
// current render target, although this apparently works in D3D9
|
||||
if (likely(SUCCEEDED(res)) &&
|
||||
unlikely(pViewport->X + pViewport->Width > rtDesc.Width ||
|
||||
pViewport->Y + pViewport->Height > rtDesc.Height))
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
StateChange();
|
||||
return GetD3D9()->SetViewport(reinterpret_cast<const d3d9::D3DVIEWPORT9*>(pViewport));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user