Housekeeping
This commit is contained in:
parent
68b6f40ca5
commit
686b0c686a
13 changed files with 24 additions and 29 deletions
|
@ -5,7 +5,7 @@ using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
public interface IAuto
|
interface IAuto
|
||||||
{
|
{
|
||||||
bool HasCommandBufferDependency(CommandBufferScoped cbs);
|
bool HasCommandBufferDependency(CommandBufferScoped cbs);
|
||||||
|
|
||||||
|
@ -14,13 +14,13 @@ namespace Ryujinx.Graphics.Metal
|
||||||
void DecrementReferenceCount();
|
void DecrementReferenceCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IAutoPrivate : IAuto
|
interface IAutoPrivate : IAuto
|
||||||
{
|
{
|
||||||
void AddCommandBufferDependencies(CommandBufferScoped cbs);
|
void AddCommandBufferDependencies(CommandBufferScoped cbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class Auto<T> : IAutoPrivate, IDisposable where T : IDisposable
|
class Auto<T> : IAutoPrivate, IDisposable where T : IDisposable
|
||||||
{
|
{
|
||||||
private int _referenceCount;
|
private int _referenceCount;
|
||||||
private T _value;
|
private T _value;
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
if (_pool == null)
|
if (_pool == null)
|
||||||
{
|
{
|
||||||
MTLCommandQueue queue = _renderer.BackgroundQueue;
|
MTLCommandQueue queue = _renderer.BackgroundQueue;
|
||||||
_pool = new CommandBufferPool(queue.Device, queue);
|
_pool = new CommandBufferPool(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _pool;
|
return _pool;
|
||||||
|
|
|
@ -8,7 +8,7 @@ using System.Threading;
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class BufferHolder : IDisposable
|
class BufferHolder : IDisposable
|
||||||
{
|
{
|
||||||
private CacheByRange<BufferHolder> _cachedConvertedBuffers;
|
private CacheByRange<BufferHolder> _cachedConvertedBuffers;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
public readonly struct ScopedTemporaryBuffer : IDisposable
|
readonly struct ScopedTemporaryBuffer : IDisposable
|
||||||
{
|
{
|
||||||
private readonly BufferManager _bufferManager;
|
private readonly BufferManager _bufferManager;
|
||||||
private readonly bool _isReserved;
|
private readonly bool _isReserved;
|
||||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class BufferManager : IDisposable
|
class BufferManager : IDisposable
|
||||||
{
|
{
|
||||||
private readonly IdList<BufferHolder> _buffers;
|
private readonly IdList<BufferHolder> _buffers;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
using SharpMetal.Metal;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
public interface ICacheKey : IDisposable
|
interface ICacheKey : IDisposable
|
||||||
{
|
{
|
||||||
bool KeyEqual(ICacheKey other);
|
bool KeyEqual(ICacheKey other);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +115,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public readonly struct Dependency
|
readonly struct Dependency
|
||||||
{
|
{
|
||||||
private readonly BufferHolder _buffer;
|
private readonly BufferHolder _buffer;
|
||||||
private readonly int _offset;
|
private readonly int _offset;
|
||||||
|
|
|
@ -7,14 +7,12 @@ using System.Runtime.Versioning;
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class CommandBufferPool : IDisposable
|
class CommandBufferPool : IDisposable
|
||||||
{
|
{
|
||||||
public const int MaxCommandBuffers = 16;
|
public const int MaxCommandBuffers = 16;
|
||||||
|
|
||||||
private readonly int _totalCommandBuffers;
|
private readonly int _totalCommandBuffers;
|
||||||
private readonly int _totalCommandBuffersMask;
|
private readonly int _totalCommandBuffersMask;
|
||||||
|
|
||||||
private readonly MTLDevice _device;
|
|
||||||
private readonly MTLCommandQueue _queue;
|
private readonly MTLCommandQueue _queue;
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
|
@ -45,9 +43,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
private int _queuedCount;
|
private int _queuedCount;
|
||||||
private int _inUseCount;
|
private int _inUseCount;
|
||||||
|
|
||||||
public CommandBufferPool(MTLDevice device, MTLCommandQueue queue)
|
public CommandBufferPool(MTLCommandQueue queue)
|
||||||
{
|
{
|
||||||
_device = device;
|
|
||||||
_queue = queue;
|
_queue = queue;
|
||||||
|
|
||||||
_totalCommandBuffers = MaxCommandBuffers;
|
_totalCommandBuffers = MaxCommandBuffers;
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Runtime.Versioning;
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public readonly struct CommandBufferScoped : IDisposable
|
readonly struct CommandBufferScoped : IDisposable
|
||||||
{
|
{
|
||||||
private readonly CommandBufferPool _pool;
|
private readonly CommandBufferPool _pool;
|
||||||
public MTLCommandBuffer CommandBuffer { get; }
|
public MTLCommandBuffer CommandBuffer { get; }
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
public struct DirtyFlags
|
struct DirtyFlags
|
||||||
{
|
{
|
||||||
public bool RenderPipeline = false;
|
public bool RenderPipeline = false;
|
||||||
public bool ComputePipeline = false;
|
public bool ComputePipeline = false;
|
||||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public record struct BufferRef
|
record struct BufferRef
|
||||||
{
|
{
|
||||||
public Auto<DisposableBuffer> Buffer;
|
public Auto<DisposableBuffer> Buffer;
|
||||||
public int Index;
|
public int Index;
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.Versioning;
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class HelperShader : IDisposable
|
class HelperShader : IDisposable
|
||||||
{
|
{
|
||||||
private const int ConvertElementsPerWorkgroup = 32 * 100; // Work group size of 32 times 100 elements.
|
private const int ConvertElementsPerWorkgroup = 32 * 100; // Work group size of 32 times 100 elements.
|
||||||
private const string ShadersSourcePath = "/Ryujinx.Graphics.Metal/Shaders";
|
private const string ShadersSourcePath = "/Ryujinx.Graphics.Metal/Shaders";
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||||
public bool PreferThreading => true;
|
public bool PreferThreading => true;
|
||||||
|
|
||||||
public IPipeline Pipeline => _pipeline;
|
public IPipeline Pipeline => _pipeline;
|
||||||
public IWindow Window => _window;
|
public IWindow Window => _window;
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
layer.Device = _device;
|
layer.Device = _device;
|
||||||
layer.FramebufferOnly = false;
|
layer.FramebufferOnly = false;
|
||||||
|
|
||||||
CommandBufferPool = new CommandBufferPool(_device, _queue);
|
CommandBufferPool = new CommandBufferPool(_queue);
|
||||||
_window = new Window(this, layer);
|
_window = new Window(this, layer);
|
||||||
_pipeline = new Pipeline(_device, this);
|
_pipeline = new Pipeline(_device, this);
|
||||||
BufferManager = new BufferManager(_device, this, _pipeline);
|
BufferManager = new BufferManager(_device, this, _pipeline);
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
/// Holder for multiple host GPU fences.
|
/// Holder for multiple host GPU fences.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class MultiFenceHolder
|
class MultiFenceHolder
|
||||||
{
|
{
|
||||||
private const int BufferUsageTrackingGranularity = 4096;
|
private const int BufferUsageTrackingGranularity = 4096;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
CommandBuffer = (Cbs = _renderer.CommandBufferPool.Rent()).CommandBuffer;
|
CommandBuffer = (Cbs = _renderer.CommandBufferPool.Rent()).CommandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitEncoderStateManager(BufferManager bufferManager)
|
internal void InitEncoderStateManager(BufferManager bufferManager)
|
||||||
{
|
{
|
||||||
_encoderStateManager = new EncoderStateManager(_device, bufferManager, this);
|
_encoderStateManager = new EncoderStateManager(_device, bufferManager, this);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MTLRenderCommandEncoder BeginRenderPass()
|
private MTLRenderCommandEncoder BeginRenderPass()
|
||||||
{
|
{
|
||||||
EndCurrentPass();
|
EndCurrentPass();
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
return renderCommandEncoder;
|
return renderCommandEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MTLBlitCommandEncoder BeginBlitPass()
|
private MTLBlitCommandEncoder BeginBlitPass()
|
||||||
{
|
{
|
||||||
EndCurrentPass();
|
EndCurrentPass();
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
return blitCommandEncoder;
|
return blitCommandEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MTLComputeCommandEncoder BeginComputePass()
|
private MTLComputeCommandEncoder BeginComputePass()
|
||||||
{
|
{
|
||||||
EndCurrentPass();
|
EndCurrentPass();
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_encoderStateManager.UpdateStorageBuffers(buffers);
|
_encoderStateManager.UpdateStorageBuffers(buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStorageBuffers(int first, ReadOnlySpan<Auto<DisposableBuffer>> buffers)
|
internal void SetStorageBuffers(int first, ReadOnlySpan<Auto<DisposableBuffer>> buffers)
|
||||||
{
|
{
|
||||||
_encoderStateManager.UpdateStorageBuffers(first, buffers);
|
_encoderStateManager.UpdateStorageBuffers(first, buffers);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
public readonly struct StagingBufferReserved
|
readonly struct StagingBufferReserved
|
||||||
{
|
{
|
||||||
public readonly BufferHolder Buffer;
|
public readonly BufferHolder Buffer;
|
||||||
public readonly int Offset;
|
public readonly int Offset;
|
||||||
|
@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
public class StagingBuffer : IDisposable
|
class StagingBuffer : IDisposable
|
||||||
{
|
{
|
||||||
private const int BufferSize = 32 * 1024 * 1024;
|
private const int BufferSize = 32 * 1024 * 1024;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue