From 295845e6e3179fab52ae5396470d19cb9054eca1 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Fri, 24 May 2024 14:41:51 +0200 Subject: [PATCH] revert deferred clears --- .../EncoderStateManager.cs | 1 + src/Ryujinx.Graphics.Metal/Pipeline.cs | 84 +++---------------- 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs index a6a9a149d..1320a04af 100644 --- a/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs +++ b/src/Ryujinx.Graphics.Metal/EncoderStateManager.cs @@ -134,6 +134,7 @@ namespace Ryujinx.Graphics.Metal SetDepthStencilState(renderCommandEncoder); } + // Clear the dirty flags _currentState.Dirty.Clear(); } diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index 9b01bb2a5..e782c9540 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -18,26 +18,6 @@ namespace Ryujinx.Graphics.Metal None } - [SupportedOSPlatform("macos")] - struct ColorClear - { - public int Layer; - public int LayerCount; - public uint ComponentMask; - public ColorF Color; - } - - [SupportedOSPlatform("macos")] - struct DepthStencilClear - { - public int Layer; - public int LayerCount; - public float DepthValue; - public bool DepthMask; - public int StencilValue; - public int StencilMask; - } - [SupportedOSPlatform("macos")] class Pipeline : IPipeline, IDisposable { @@ -56,10 +36,6 @@ namespace Ryujinx.Graphics.Metal private EncoderStateManager _encoderStateManager; - // Deferred clears - private ColorClear?[] _colorClears = new ColorClear?[Constants.MaxColorAttachments]; - private DepthStencilClear? _depthStencilClear; - public Pipeline(MTLDevice device, MTLCommandQueue commandQueue) { _device = device; @@ -176,38 +152,6 @@ namespace Ryujinx.Graphics.Metal return computeCommandEncoder; } - public void ExecuteDeferredColorClears() - { - for (int i = 0; i < Constants.MaxColorAttachments; i++) - { - if (_colorClears[i] != null) - { - ColorF color = _colorClears[i].Value.Color; - float[] colors = [color.Red, color.Green, color.Blue, color.Alpha]; - - Texture target = _encoderStateManager.RenderTargets[i]; - - _encoderStateManager.SwapStates(); - - _helperShader.ClearColor(target, colors); - } - _colorClears[i] = null; - } - } - - public void ExecuteDeferredDepthStencilClear() - { - if (_depthStencilClear != null) - { - Texture target = _encoderStateManager.DepthStencil; - - _encoderStateManager.SwapStates(); - - _helperShader.ClearDepthStencil(target, [_depthStencilClear.Value.DepthValue], _depthStencilClear.Value.DepthMask, _depthStencilClear.Value.StencilValue, _depthStencilClear.Value.StencilMask); - } - _depthStencilClear = null; - } - public void Present(CAMetalDrawable drawable, ITexture texture) { if (texture is not Texture tex) @@ -259,30 +203,22 @@ namespace Ryujinx.Graphics.Metal public void ClearRenderTargetColor(int index, int layer, int layerCount, uint componentMask, ColorF color) { - _colorClears[index] = new ColorClear - { - Layer = layer, - LayerCount = layerCount, - ComponentMask = componentMask, - Color = color - }; + float[] colors = [color.Red, color.Green, color.Blue, color.Alpha]; - ExecuteDeferredColorClears(); + Texture target = _encoderStateManager.RenderTargets[index]; + + _encoderStateManager.SwapStates(); + + _helperShader.ClearColor(target, colors); } public void ClearRenderTargetDepthStencil(int layer, int layerCount, float depthValue, bool depthMask, int stencilValue, int stencilMask) { - _depthStencilClear = new DepthStencilClear - { - Layer = layer, - LayerCount = layerCount, - DepthValue = depthValue, - DepthMask = depthMask, - StencilValue = stencilValue, - StencilMask = stencilMask - }; + Texture target = _encoderStateManager.DepthStencil; - ExecuteDeferredDepthStencilClear(); + _encoderStateManager.SwapStates(); + + _helperShader.ClearDepthStencil(target, [depthValue], depthMask, stencilValue, stencilMask); } public void CommandBufferBarrier()