From 53369e79bdc34440a48e932e7024bab92f30f957 Mon Sep 17 00:00:00 2001 From: mageven <62494521+mageven@users.noreply.github.com> Date: Mon, 4 May 2020 07:34:49 +0530 Subject: Implement user-defined clipping on GL state pipeline (#1118) --- Ryujinx.Graphics.Gpu/Engine/Methods.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Ryujinx.Graphics.Gpu/Engine') diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index a517ae05..59678be5 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -125,6 +125,11 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateShaderState(state); } + if (state.QueryModified(MethodOffset.ClipDistanceEnable)) + { + UpdateUserClipState(state); + } + if (state.QueryModified(MethodOffset.RasterizeEnable)) { UpdateRasterizerState(state); @@ -902,6 +907,20 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetProgram(gs.HostProgram); } + /// + /// Updates user-defined clipping based on the guest GPU state. + /// + /// Current GPU state + private void UpdateUserClipState(GpuState state) + { + int clipMask = state.Get(MethodOffset.ClipDistanceEnable); + + for (int i = 0; i < Constants.TotalClipDistances; ++i) + { + _context.Renderer.Pipeline.SetUserClipDistance(i, (clipMask & (1 << i)) != 0); + } + } + /// /// Gets texture target from a sampler type. /// -- cgit v1.2.3