diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-03-29 00:02:58 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-29 14:02:58 +1100 |
| commit | ab4867505ec0d3f5a9ec4f042ccd6f7890e3632e (patch) | |
| tree | b3956fc821e0dcb8c8c3edc9dcae5eadf83ce29d /Ryujinx.Graphics.Gpu | |
| parent | 06bf25521ff3ab2ad82eb49cde2bb6f90324caa2 (diff) | |
Implement GPU scissors (#1058)
* Implement GPU scissors
* Remove unused using
* Add missing changes for Clear
Diffstat (limited to 'Ryujinx.Graphics.Gpu')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodClear.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Methods.cs | 26 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/GpuStateTable.cs | 1 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/MethodOffset.cs | 1 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/State/ScissorState.cs | 12 |
5 files changed, 46 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs b/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs index dfa7b12e..ff538df3 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs @@ -13,6 +13,12 @@ namespace Ryujinx.Graphics.Gpu.Engine /// <param name="argument">Method call argument</param> private void Clear(GpuState state, int argument) { + // Scissor affects clears aswell. + if (state.QueryModified(MethodOffset.ScissorState)) + { + UpdateScissorState(state); + } + UpdateRenderTargetState(state, useControl: false); TextureManager.CommitGraphicsBindings(); diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index a2c9876e..0b30e61d 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -117,6 +117,11 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateRenderTargetState(state, useControl: true); } + if (state.QueryModified(MethodOffset.ScissorState)) + { + UpdateScissorState(state); + } + if (state.QueryModified(MethodOffset.DepthTestEnable, MethodOffset.DepthWriteEnable, MethodOffset.DepthTestFunc)) @@ -322,6 +327,27 @@ namespace Ryujinx.Graphics.Gpu.Engine } /// <summary> + /// Updates host scissor test state based on current GPU state. + /// </summary> + /// <param name="state">Current GPU state</param> + private void UpdateScissorState(GpuState state) + { + for (int index = 0; index < Constants.TotalViewports; index++) + { + ScissorState scissor = state.Get<ScissorState>(MethodOffset.ScissorState, index); + + bool enable = scissor.Enable && (scissor.X1 != 0 || scissor.Y1 != 0 || scissor.X2 != 0xffff || scissor.Y2 != 0xffff); + + _context.Renderer.Pipeline.SetScissorEnable(index, enable); + + if (enable) + { + _context.Renderer.Pipeline.SetScissor(index, scissor.X1, scissor.Y1, scissor.X2 - scissor.X1, scissor.Y2 - scissor.Y1); + } + } + } + + /// <summary> /// Updates host depth test state based on current GPU state. /// </summary> /// <param name="state">Current GPU state</param> diff --git a/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs b/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs index db8d141e..8631efcc 100644 --- a/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs +++ b/Ryujinx.Graphics.Gpu/State/GpuStateTable.cs @@ -57,6 +57,7 @@ namespace Ryujinx.Graphics.Gpu.State new TableItem(MethodOffset.ViewportExtents, typeof(ViewportExtents), 8), new TableItem(MethodOffset.VertexBufferDrawState, typeof(VertexBufferDrawState), 1), new TableItem(MethodOffset.DepthBiasState, typeof(DepthBiasState), 1), + new TableItem(MethodOffset.ScissorState, typeof(ScissorState), 8), new TableItem(MethodOffset.StencilBackMasks, typeof(StencilBackMasks), 1), new TableItem(MethodOffset.RtDepthStencilState, typeof(RtDepthStencilState), 1), new TableItem(MethodOffset.VertexAttribState, typeof(VertexAttribState), 16), diff --git a/Ryujinx.Graphics.Gpu/State/MethodOffset.cs b/Ryujinx.Graphics.Gpu/State/MethodOffset.cs index 730ff40a..0a720b2c 100644 --- a/Ryujinx.Graphics.Gpu/State/MethodOffset.cs +++ b/Ryujinx.Graphics.Gpu/State/MethodOffset.cs @@ -33,6 +33,7 @@ namespace Ryujinx.Graphics.Gpu.State ClearStencilValue = 0x368, DepthBiasState = 0x370, TextureBarrier = 0x378, + ScissorState = 0x380, StencilBackMasks = 0x3d5, InvalidateTextures = 0x3dd, TextureBarrierTiled = 0x3df, diff --git a/Ryujinx.Graphics.Gpu/State/ScissorState.cs b/Ryujinx.Graphics.Gpu/State/ScissorState.cs new file mode 100644 index 00000000..06766640 --- /dev/null +++ b/Ryujinx.Graphics.Gpu/State/ScissorState.cs @@ -0,0 +1,12 @@ +namespace Ryujinx.Graphics.Gpu.State +{ + struct ScissorState + { + public Boolean32 Enable; + public ushort X1; + public ushort X2; + public ushort Y1; + public ushort Y2; + public uint Padding; + } +} |
