From 43c13057da7726c324f2b5d674e5e1308eb1f6a7 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 28 Jul 2020 18:30:08 -0300 Subject: Implement alpha test using legacy functions (#1426) --- Ryujinx.Graphics.Gpu/Engine/Methods.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 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 fbde0f0a..f8b6e43f 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -164,6 +164,13 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateDepthClampState(state); } + if (state.QueryModified(MethodOffset.AlphaTestEnable, + MethodOffset.AlphaTestRef, + MethodOffset.AlphaTestFunc)) + { + UpdateAlphaTestState(state); + } + if (state.QueryModified(MethodOffset.DepthTestEnable, MethodOffset.DepthWriteEnable, MethodOffset.DepthTestFunc)) @@ -372,7 +379,7 @@ namespace Ryujinx.Graphics.Gpu.Engine if (dsEnable) { var dsState = state.Get(MethodOffset.RtDepthStencilState); - var dsSize = state.Get (MethodOffset.RtDepthStencilSize); + var dsSize = state.Get(MethodOffset.RtDepthStencilSize); depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY); } @@ -450,6 +457,18 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampDisabled) == 0); } + /// + /// Updates host alpha test state based on current GPU state. + /// + /// Current GPU state + private void UpdateAlphaTestState(GpuState state) + { + _context.Renderer.Pipeline.SetAlphaTest( + state.Get(MethodOffset.AlphaTestEnable), + state.Get(MethodOffset.AlphaTestRef), + state.Get(MethodOffset.AlphaTestFunc)); + } + /// /// Updates host depth test state based on current GPU state. /// @@ -577,8 +596,8 @@ namespace Ryujinx.Graphics.Gpu.Engine /// Current GPU state private void UpdateStencilTestState(GpuState state) { - var backMasks = state.Get (MethodOffset.StencilBackMasks); - var test = state.Get (MethodOffset.StencilTestState); + var backMasks = state.Get(MethodOffset.StencilBackMasks); + var test = state.Get(MethodOffset.StencilTestState); var backTest = state.Get(MethodOffset.StencilBackTestState); CompareOp backFunc; -- cgit v1.2.3