diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 31ab07ddaa..5db7b8b4ec 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -486,8 +486,8 @@ void Renderer::SetViewport() Ht = (Y + Ht <= GetTargetHeight()) ? Ht : (GetTargetHeight() - Y); D3D11_VIEWPORT vp = CD3D11_VIEWPORT(X, Y, Wd, Ht, - (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f, - xfmem.viewport.farZ / 16777216.0f); + std::max(0.0f, std::min(1.0f, (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f)), + std::max(0.0f, std::min(1.0f, xfmem.viewport.farZ / 16777216.0f))); D3D::context->RSSetViewports(1, &vp); }