Better index buffer management

This commit is contained in:
Isaac Marovitz
2024-07-08 12:02:42 +01:00
committed by Evan Husted
parent b468569665
commit fcd2adecc5
5 changed files with 108 additions and 34 deletions

View File

@@ -23,9 +23,7 @@ namespace Ryujinx.Graphics.Metal
private readonly EncoderState _mainState = new();
private EncoderState _currentState;
public readonly Auto<DisposableBuffer> IndexBuffer => _currentState.IndexBuffer;
public readonly MTLIndexType IndexType => _currentState.IndexType;
public readonly ulong IndexBufferOffset => _currentState.IndexBufferOffset;
public readonly IndexBufferState IndexBuffer => _currentState.IndexBuffer;
public readonly PrimitiveTopology Topology => _currentState.Topology;
public readonly Texture[] RenderTargets => _currentState.RenderTargets;
public readonly Texture DepthStencil => _currentState.DepthStencil;
@@ -305,18 +303,11 @@ namespace Ryujinx.Graphics.Metal
{
if (buffer.Handle != BufferHandle.Null)
{
if (type == GAL.IndexType.UByte)
{
_currentState.IndexType = MTLIndexType.UInt16;
_currentState.IndexBufferOffset = 0;
_currentState.IndexBuffer = _bufferManager.GetBufferI8ToI16(_pipeline.Cbs, buffer.Handle, buffer.Offset, buffer.Size);
}
else
{
_currentState.IndexType = type.Convert();
_currentState.IndexBufferOffset = (ulong)buffer.Offset;
_currentState.IndexBuffer = _bufferManager.GetBuffer(buffer.Handle, false);
}
_currentState.IndexBuffer = new IndexBufferState(buffer.Handle, buffer.Offset, buffer.Size, type);
}
else
{
_currentState.IndexBuffer = IndexBufferState.Null;
}
}