From c2ac45adc5e735f752c128990e022252a6e0a426 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Thu, 30 Apr 2020 02:47:24 +0100 Subject: [PATCH] Fix depth clamp enable bit, unit scale for polygon offset. (#1178) Verified with deko3d and opengl driver code. --- Ryujinx.Graphics.GAL/IPipeline.cs | 2 +- Ryujinx.Graphics.Gpu/Engine/Methods.cs | 3 +-- Ryujinx.Graphics.Gpu/State/ViewVolumeClipControl.cs | 3 +-- Ryujinx.Graphics.OpenGL/Pipeline.cs | 8 ++------ 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Ryujinx.Graphics.GAL/IPipeline.cs b/Ryujinx.Graphics.GAL/IPipeline.cs index 1e685923..51b8d91a 100644 --- a/Ryujinx.Graphics.GAL/IPipeline.cs +++ b/Ryujinx.Graphics.GAL/IPipeline.cs @@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.GAL void SetBlendState(int index, BlendDescriptor blend); void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp); - void SetDepthClamp(bool clampNear, bool clampFar); + void SetDepthClamp(bool clamp); void SetDepthMode(DepthMode mode); void SetDepthTest(DepthTestDescriptor depthTest); diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index ddb6e052..a517ae05 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -394,8 +394,7 @@ namespace Ryujinx.Graphics.Gpu.Engine private void UpdateDepthClampState(GpuState state) { ViewVolumeClipControl clip = state.Get(MethodOffset.ViewVolumeClipControl); - _context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampNear) != 0, - (clip & ViewVolumeClipControl.DepthClampFar) != 0); + _context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampDisabled) == 0); } /// diff --git a/Ryujinx.Graphics.Gpu/State/ViewVolumeClipControl.cs b/Ryujinx.Graphics.Gpu/State/ViewVolumeClipControl.cs index 4e12c424..ace8342c 100644 --- a/Ryujinx.Graphics.Gpu/State/ViewVolumeClipControl.cs +++ b/Ryujinx.Graphics.Gpu/State/ViewVolumeClipControl.cs @@ -6,7 +6,6 @@ namespace Ryujinx.Graphics.Gpu.State enum ViewVolumeClipControl { ForceDepthRangeZeroToOne = 1 << 0, - DepthClampNear = 1 << 3, - DepthClampFar = 1 << 4, + DepthClampDisabled = 1 << 11, } } \ No newline at end of file diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index e313595d..604d0ba3 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -549,17 +549,13 @@ namespace Ryujinx.Graphics.OpenGL return; } - GL.PolygonOffset(factor, units); + GL.PolygonOffset(factor, units / 2f); // TODO: Enable when GL_EXT_polygon_offset_clamp is supported. // GL.PolygonOffsetClamp(factor, units, clamp); } - public void SetDepthClamp(bool clampNear, bool clampFar) + public void SetDepthClamp(bool clamp) { - // TODO: Use GL_AMD_depth_clamp_separate or similar if available? - // Currently enables clamping if either is set. - bool clamp = clampNear || clampFar; - if (!clamp) { GL.Disable(EnableCap.DepthClamp);