From 4960ab85f81f48553b7217261f4181e31d812a10 Mon Sep 17 00:00:00 2001 From: mageven <62494521+mageven@users.noreply.github.com> Date: Fri, 17 Apr 2020 06:46:49 +0530 Subject: Implement Depth Clamping (#1120) * Implement Depth Clamping and add misc enums * Fix formatting --- Ryujinx.Graphics.Gpu/Engine/Methods.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Engine/Methods.cs') diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index 50913801..b7f4e1d9 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -127,6 +127,11 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateScissorState(state); } + if (state.QueryModified(MethodOffset.ViewVolumeClipControl)) + { + UpdateDepthClampState(state); + } + if (state.QueryModified(MethodOffset.DepthTestEnable, MethodOffset.DepthWriteEnable, MethodOffset.DepthTestFunc)) @@ -134,7 +139,9 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateDepthTestState(state); } - if (state.QueryModified(MethodOffset.DepthMode, MethodOffset.ViewportTransform, MethodOffset.ViewportExtents)) + if (state.QueryModified(MethodOffset.DepthMode, + MethodOffset.ViewportTransform, + MethodOffset.ViewportExtents)) { UpdateViewportTransform(state); } @@ -362,6 +369,17 @@ namespace Ryujinx.Graphics.Gpu.Engine } } + /// + /// Updates host depth clamp state based on current GPU state. + /// + /// Current GPU state + private void UpdateDepthClampState(GpuState state) + { + ViewVolumeClipControl clip = state.Get(MethodOffset.ViewVolumeClipControl); + _context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampNear) != 0, + (clip & ViewVolumeClipControl.DepthClampFar) != 0); + } + /// /// Updates host depth test state based on current GPU state. /// @@ -384,8 +402,7 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetDepthMode(depthMode); - bool flipY = (state.Get(MethodOffset.YControl) & 1) != 0; - + bool flipY = (state.Get(MethodOffset.YControl) & YControl.NegateY) != 0; float yFlip = flipY ? -1 : 1; Viewport[] viewports = new Viewport[Constants.TotalViewports]; -- cgit v1.2.3