From 35b0436a2b374de4f29a66d19762235a0a3762bb Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 16 May 2024 15:59:56 -0400 Subject: [PATCH] Clamp Viewport ZNear & ZFar --- src/Ryujinx.Graphics.Metal/Pipeline.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index 33d5678a4..961512c1f 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -735,6 +735,11 @@ namespace Ryujinx.Graphics.Metal public unsafe void SetViewports(ReadOnlySpan viewports) { + static float Clamp(float value) + { + return Math.Clamp(value, 0f, 1f); + } + var mtlViewports = new MTLViewport[viewports.Length]; for (int i = 0; i < viewports.Length; i++) @@ -746,8 +751,8 @@ namespace Ryujinx.Graphics.Metal originY = viewport.Region.Y, width = viewport.Region.Width, height = viewport.Region.Height, - znear = viewport.DepthNear, - zfar = viewport.DepthFar + znear = Clamp(viewport.DepthNear), + zfar = Clamp(viewport.DepthFar) }; }