Rebase + GAL Changes

This commit is contained in:
Isaac Marovitz 2024-04-22 17:44:55 -04:00 committed by Isaac Marovitz
parent 00b99770a2
commit 722aa4e45d
5 changed files with 33 additions and 9 deletions

View file

@ -1,9 +1,11 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using SharpMetal.Metal; using SharpMetal.Metal;
using System.Runtime.Versioning;
namespace Ryujinx.Graphics.Metal namespace Ryujinx.Graphics.Metal
{ {
[SupportedOSPlatform("macos")]
static class EnumConversion static class EnumConversion
{ {
public static MTLSamplerAddressMode Convert(this AddressMode mode) public static MTLSamplerAddressMode Convert(this AddressMode mode)

View file

@ -70,6 +70,11 @@ namespace Ryujinx.Graphics.Metal
throw new NotImplementedException(); throw new NotImplementedException();
} }
public IImageArray CreateImageArray(int size, bool isBuffer)
{
throw new NotImplementedException();
}
public BufferHandle CreateBuffer(int size, BufferAccess access) public BufferHandle CreateBuffer(int size, BufferAccess access)
{ {
var buffer = _device.NewBuffer((ulong)size, MTLResourceOptions.ResourceStorageModeShared); var buffer = _device.NewBuffer((ulong)size, MTLResourceOptions.ResourceStorageModeShared);
@ -100,6 +105,11 @@ namespace Ryujinx.Graphics.Metal
return texture; return texture;
} }
public ITextureArray CreateTextureArray(int size, bool isBuffer)
{
throw new NotImplementedException();
}
public bool PrepareHostMapping(IntPtr address, ulong size) public bool PrepareHostMapping(IntPtr address, ulong size)
{ {
// TODO: Metal Host Mapping // TODO: Metal Host Mapping
@ -157,6 +167,8 @@ namespace Ryujinx.Graphics.Metal
supportsCubemapView: true, supportsCubemapView: true,
supportsNonConstantTextureOffset: false, supportsNonConstantTextureOffset: false,
supportsScaledVertexFormats: true, supportsScaledVertexFormats: true,
// TODO: Metal Bindless Support
supportsSeparateSampler: false,
supportsShaderBallot: false, supportsShaderBallot: false,
supportsShaderBarrierDivergence: false, supportsShaderBarrierDivergence: false,
supportsShaderFloat64: false, supportsShaderFloat64: false,

View file

@ -428,6 +428,11 @@ namespace Ryujinx.Graphics.Metal
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!"); Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
} }
public void SetImageArray(ShaderStage stage, int binding, IImageArray array)
{
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
}
public void SetLineParameters(float width, bool smooth) public void SetLineParameters(float width, bool smooth)
{ {
// Not supported in Metal // Not supported in Metal
@ -644,6 +649,11 @@ namespace Ryujinx.Graphics.Metal
} }
} }
public void SetTextureArray(ShaderStage stage, int binding, ITextureArray array)
{
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
}
public void SetUniformBuffers(ReadOnlySpan<BufferAssignment> buffers) public void SetUniformBuffers(ReadOnlySpan<BufferAssignment> buffers)
{ {
_uniformBuffers = []; _uniformBuffers = [];

View file

@ -3,6 +3,7 @@ using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using SharpMetal.Metal; using SharpMetal.Metal;
using System; using System;
using System.Buffers;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Versioning; using System.Runtime.Versioning;
@ -170,11 +171,11 @@ namespace Ryujinx.Graphics.Metal
} }
// TODO: Handle array formats // TODO: Handle array formats
public unsafe void SetData(SpanOrArray<byte> data) public unsafe void SetData(IMemoryOwner<byte> data)
{ {
var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder(); var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
var dataSpan = data.Span; var dataSpan = data.Memory.Span;
var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared); var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared);
var bufferSpan = new Span<byte>(mtlBuffer.Contents.ToPointer(), dataSpan.Length); var bufferSpan = new Span<byte>(mtlBuffer.Contents.ToPointer(), dataSpan.Length);
dataSpan.CopyTo(bufferSpan); dataSpan.CopyTo(bufferSpan);
@ -222,7 +223,7 @@ namespace Ryujinx.Graphics.Metal
} }
} }
public void SetData(SpanOrArray<byte> data, int layer, int level) public void SetData(IMemoryOwner<byte> data, int layer, int level)
{ {
var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder(); var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
@ -235,7 +236,7 @@ namespace Ryujinx.Graphics.Metal
unsafe unsafe
{ {
var dataSpan = data.Span; var dataSpan = data.Memory.Span;
var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared); var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared);
var bufferSpan = new Span<byte>(mtlBuffer.Contents.ToPointer(), dataSpan.Length); var bufferSpan = new Span<byte>(mtlBuffer.Contents.ToPointer(), dataSpan.Length);
dataSpan.CopyTo(bufferSpan); dataSpan.CopyTo(bufferSpan);
@ -254,7 +255,7 @@ namespace Ryujinx.Graphics.Metal
} }
} }
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region) public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{ {
var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder(); var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
@ -267,7 +268,7 @@ namespace Ryujinx.Graphics.Metal
unsafe unsafe
{ {
var dataSpan = data.Span; var dataSpan = data.Memory.Span;
var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared); var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared);
var bufferSpan = new Span<byte>(mtlBuffer.Contents.ToPointer(), dataSpan.Length); var bufferSpan = new Span<byte>(mtlBuffer.Contents.ToPointer(), dataSpan.Length);
dataSpan.CopyTo(bufferSpan); dataSpan.CopyTo(bufferSpan);

View file

@ -1054,6 +1054,7 @@ namespace Ryujinx.Ava
{ {
GraphicsBackend.Vulkan => "Vulkan", GraphicsBackend.Vulkan => "Vulkan",
GraphicsBackend.OpenGl => "OpenGL", GraphicsBackend.OpenGl => "OpenGL",
GraphicsBackend.Metal => "Metal",
_ => throw new NotImplementedException() _ => throw new NotImplementedException()
}, },
$"GPU: {_renderer.GetHardwareInfo().GpuDriver}")); $"GPU: {_renderer.GetHardwareInfo().GpuDriver}"));
@ -1072,12 +1073,10 @@ namespace Ryujinx.Ava
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
Device.EnableDeviceVsync, Device.EnableDeviceVsync,
LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%", LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%",
ConfigurationState.Instance.Graphics.GraphicsBackend.Value.ToString(),
dockedMode, dockedMode,
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)", LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %", $"FIFO: {Device.Statistics.GetFifoPercent():00.00} %"));
$"GPU: {_renderer.GetHardwareInfo().GpuDriver}"));
} }
public async Task ShowExitPrompt() public async Task ShowExitPrompt()