Skip to content

Commit

Permalink
[d3d8] Relax viewport validation in windowed mode
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Sep 15, 2024
1 parent 8e03b64 commit a5153d8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ namespace dxvk {

HRESULT STDMETHODCALLTYPE D3D8Device::SetViewport(const D3DVIEWPORT8* pViewport) {
if (likely(pViewport != nullptr)) {
// we need a valid render target to validate the viewport
// We need a valid render target to validate the viewport
if (unlikely(m_renderTarget == nullptr))
return D3DERR_INVALIDCALL;

Expand All @@ -938,8 +938,20 @@ namespace dxvk {
// 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;
pViewport->Y + pViewport->Height > rtDesc.Height)) {
// On Linux/Wine and in windowed mode, we can get in situations
// where the actual render target dimensions are off by one
// pixel to what the game sets them to. Allow this corner case
// to skip the validation, in order to prevent issues.
bool isOnePixelWider = pViewport->X + pViewport->Width == rtDesc.Width + 1;
bool isOnePixelTaller = pViewport->Y + pViewport->Height == rtDesc.Height + 1;

if (m_presentParams.Windowed && (isOnePixelWider || isOnePixelTaller)) {
Logger::debug("Viewport exceeds render target dimensions by one pixel");
} else {
return D3DERR_INVALIDCALL;
}
}
}

StateChange();
Expand Down

0 comments on commit a5153d8

Please sign in to comment.