From 722aa4e45d1a44b8a08a5a0dd3ec0742c0c42f68 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Mon, 22 Apr 2024 17:44:55 -0400 Subject: [PATCH] Rebase + GAL Changes --- src/Ryujinx.Graphics.Metal/EnumConversion.cs | 2 ++ src/Ryujinx.Graphics.Metal/MetalRenderer.cs | 12 ++++++++++++ src/Ryujinx.Graphics.Metal/Pipeline.cs | 10 ++++++++++ src/Ryujinx.Graphics.Metal/Texture.cs | 13 +++++++------ src/Ryujinx/AppHost.cs | 5 ++--- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/Ryujinx.Graphics.Metal/EnumConversion.cs b/src/Ryujinx.Graphics.Metal/EnumConversion.cs index d0987f0fe..428e90caa 100644 --- a/src/Ryujinx.Graphics.Metal/EnumConversion.cs +++ b/src/Ryujinx.Graphics.Metal/EnumConversion.cs @@ -1,9 +1,11 @@ using Ryujinx.Common.Logging; using Ryujinx.Graphics.GAL; using SharpMetal.Metal; +using System.Runtime.Versioning; namespace Ryujinx.Graphics.Metal { + [SupportedOSPlatform("macos")] static class EnumConversion { public static MTLSamplerAddressMode Convert(this AddressMode mode) diff --git a/src/Ryujinx.Graphics.Metal/MetalRenderer.cs b/src/Ryujinx.Graphics.Metal/MetalRenderer.cs index d1f321c2e..aabe0c1e6 100644 --- a/src/Ryujinx.Graphics.Metal/MetalRenderer.cs +++ b/src/Ryujinx.Graphics.Metal/MetalRenderer.cs @@ -70,6 +70,11 @@ namespace Ryujinx.Graphics.Metal throw new NotImplementedException(); } + public IImageArray CreateImageArray(int size, bool isBuffer) + { + throw new NotImplementedException(); + } + public BufferHandle CreateBuffer(int size, BufferAccess access) { var buffer = _device.NewBuffer((ulong)size, MTLResourceOptions.ResourceStorageModeShared); @@ -100,6 +105,11 @@ namespace Ryujinx.Graphics.Metal return texture; } + public ITextureArray CreateTextureArray(int size, bool isBuffer) + { + throw new NotImplementedException(); + } + public bool PrepareHostMapping(IntPtr address, ulong size) { // TODO: Metal Host Mapping @@ -157,6 +167,8 @@ namespace Ryujinx.Graphics.Metal supportsCubemapView: true, supportsNonConstantTextureOffset: false, supportsScaledVertexFormats: true, + // TODO: Metal Bindless Support + supportsSeparateSampler: false, supportsShaderBallot: false, supportsShaderBarrierDivergence: false, supportsShaderFloat64: false, diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index 14c6b99a6..6c33699e3 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -428,6 +428,11 @@ namespace Ryujinx.Graphics.Metal 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) { // 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 buffers) { _uniformBuffers = []; diff --git a/src/Ryujinx.Graphics.Metal/Texture.cs b/src/Ryujinx.Graphics.Metal/Texture.cs index 8cf62aea3..fb1c92be5 100644 --- a/src/Ryujinx.Graphics.Metal/Texture.cs +++ b/src/Ryujinx.Graphics.Metal/Texture.cs @@ -3,6 +3,7 @@ using Ryujinx.Common.Memory; using Ryujinx.Graphics.GAL; using SharpMetal.Metal; using System; +using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.Versioning; @@ -170,11 +171,11 @@ namespace Ryujinx.Graphics.Metal } // TODO: Handle array formats - public unsafe void SetData(SpanOrArray data) + public unsafe void SetData(IMemoryOwner data) { var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder(); - var dataSpan = data.Span; + var dataSpan = data.Memory.Span; var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared); var bufferSpan = new Span(mtlBuffer.Contents.ToPointer(), dataSpan.Length); dataSpan.CopyTo(bufferSpan); @@ -222,7 +223,7 @@ namespace Ryujinx.Graphics.Metal } } - public void SetData(SpanOrArray data, int layer, int level) + public void SetData(IMemoryOwner data, int layer, int level) { var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder(); @@ -235,7 +236,7 @@ namespace Ryujinx.Graphics.Metal unsafe { - var dataSpan = data.Span; + var dataSpan = data.Memory.Span; var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared); var bufferSpan = new Span(mtlBuffer.Contents.ToPointer(), dataSpan.Length); dataSpan.CopyTo(bufferSpan); @@ -254,7 +255,7 @@ namespace Ryujinx.Graphics.Metal } } - public void SetData(SpanOrArray data, int layer, int level, Rectangle region) + public void SetData(IMemoryOwner data, int layer, int level, Rectangle region) { var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder(); @@ -267,7 +268,7 @@ namespace Ryujinx.Graphics.Metal unsafe { - var dataSpan = data.Span; + var dataSpan = data.Memory.Span; var mtlBuffer = _device.NewBuffer((ulong)dataSpan.Length, MTLResourceOptions.ResourceStorageModeShared); var bufferSpan = new Span(mtlBuffer.Contents.ToPointer(), dataSpan.Length); dataSpan.CopyTo(bufferSpan); diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 8cc1d65a0..f88bac0cd 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -1054,6 +1054,7 @@ namespace Ryujinx.Ava { GraphicsBackend.Vulkan => "Vulkan", GraphicsBackend.OpenGl => "OpenGL", + GraphicsBackend.Metal => "Metal", _ => throw new NotImplementedException() }, $"GPU: {_renderer.GetHardwareInfo().GpuDriver}")); @@ -1072,12 +1073,10 @@ namespace Ryujinx.Ava StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( Device.EnableDeviceVsync, LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%", - ConfigurationState.Instance.Graphics.GraphicsBackend.Value.ToString(), dockedMode, ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(), LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)", - $"FIFO: {Device.Statistics.GetFifoPercent():00.00} %", - $"GPU: {_renderer.GetHardwareInfo().GpuDriver}")); + $"FIFO: {Device.Statistics.GetFifoPercent():00.00} %")); } public async Task ShowExitPrompt()