revert deferred clears

This commit is contained in:
Samuliak 2024-05-24 14:41:51 +02:00 committed by Isaac Marovitz
parent 19c5391e7d
commit 56fcfba689
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
2 changed files with 11 additions and 74 deletions

View File

@ -134,6 +134,7 @@ namespace Ryujinx.Graphics.Metal
SetDepthStencilState(renderCommandEncoder);
}
// Clear the dirty flags
_currentState.Dirty.Clear();
}

View File

@ -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()