mirror of
https://github.com/Ryujinx-NX/Ryujinx.git
synced 2024-11-14 13:07:41 -07:00
Start Metal Backend
Revert build yml changes
This commit is contained in:
parent
24ee8c39f1
commit
18b631730d
@ -38,6 +38,7 @@
|
||||
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
|
||||
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
|
||||
<PackageVersion Include="shaderc.net" Version="0.1.0" />
|
||||
<PackageVersion Include="SharpMetal" Version="1.0.0-preview6" />
|
||||
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageVersion Include="Silk.NET.Vulkan" Version="2.21.0" />
|
||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.21.0" />
|
||||
|
@ -88,6 +88,10 @@ EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Horizon.Kernel.Generators", "src\Ryujinx.Horizon.Kernel.Generators\Ryujinx.Horizon.Kernel.Generators.csproj", "{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.HLE.Generators", "src\Ryujinx.HLE.Generators\Ryujinx.HLE.Generators.csproj", "{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.Graphics.Metal", "src\Ryujinx.Graphics.Metal\Ryujinx.Graphics.Metal.csproj", "{C08931FA-1191-417A-864F-3882D93E683B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{A602AE97-91A5-4608-8DF1-EBF4ED7A0B9E} = {A602AE97-91A5-4608-8DF1-EBF4ED7A0B9E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -255,6 +259,10 @@ Global
|
||||
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C08931FA-1191-417A-864F-3882D93E683B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -8,5 +8,6 @@ namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
Vulkan,
|
||||
OpenGl,
|
||||
Metal
|
||||
}
|
||||
}
|
||||
|
13
src/Ryujinx.Graphics.Metal/Constants.cs
Normal file
13
src/Ryujinx.Graphics.Metal/Constants.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
static class Constants
|
||||
{
|
||||
// TODO: Check these values, these were largely copied from Vulkan
|
||||
public const int MaxShaderStages = 5;
|
||||
public const int MaxUniformBuffersPerStage = 18;
|
||||
public const int MaxStorageBuffersPerStage = 16;
|
||||
public const int MaxTexturesPerStage = 64;
|
||||
public const int MaxCommandBuffersPerQueue = 16;
|
||||
public const int MaxTextureBindings = MaxTexturesPerStage * MaxShaderStages;
|
||||
}
|
||||
}
|
192
src/Ryujinx.Graphics.Metal/EnumConversion.cs
Normal file
192
src/Ryujinx.Graphics.Metal/EnumConversion.cs
Normal file
@ -0,0 +1,192 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using SharpMetal;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
static class EnumConversion
|
||||
{
|
||||
public static MTLSamplerAddressMode Convert(this AddressMode mode)
|
||||
{
|
||||
return mode switch
|
||||
{
|
||||
AddressMode.Clamp => MTLSamplerAddressMode.ClampToEdge, // TODO: Should be clamp.
|
||||
AddressMode.Repeat => MTLSamplerAddressMode.Repeat,
|
||||
AddressMode.MirrorClamp => MTLSamplerAddressMode.MirrorClampToEdge, // TODO: Should be mirror clamp.
|
||||
AddressMode.MirroredRepeat => MTLSamplerAddressMode.MirrorRepeat,
|
||||
AddressMode.ClampToBorder => MTLSamplerAddressMode.ClampToBorderColor,
|
||||
AddressMode.ClampToEdge => MTLSamplerAddressMode.ClampToEdge,
|
||||
AddressMode.MirrorClampToEdge => MTLSamplerAddressMode.MirrorClampToEdge,
|
||||
AddressMode.MirrorClampToBorder => MTLSamplerAddressMode.ClampToBorderColor, // TODO: Should be mirror clamp to border.
|
||||
_ => LogInvalidAndReturn(mode, nameof(AddressMode), MTLSamplerAddressMode.ClampToEdge) // TODO: Should be clamp.
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLBlendFactor Convert(this BlendFactor factor)
|
||||
{
|
||||
return factor switch
|
||||
{
|
||||
BlendFactor.Zero or BlendFactor.ZeroGl => MTLBlendFactor.Zero,
|
||||
BlendFactor.One or BlendFactor.OneGl => MTLBlendFactor.One,
|
||||
BlendFactor.SrcColor or BlendFactor.SrcColorGl => MTLBlendFactor.SourceColor,
|
||||
BlendFactor.OneMinusSrcColor or BlendFactor.OneMinusSrcColorGl => MTLBlendFactor.OneMinusSourceColor,
|
||||
BlendFactor.SrcAlpha or BlendFactor.SrcAlphaGl => MTLBlendFactor.SourceAlpha,
|
||||
BlendFactor.OneMinusSrcAlpha or BlendFactor.OneMinusSrcAlphaGl => MTLBlendFactor.OneMinusSourceAlpha,
|
||||
BlendFactor.DstAlpha or BlendFactor.DstAlphaGl => MTLBlendFactor.DestinationAlpha,
|
||||
BlendFactor.OneMinusDstAlpha or BlendFactor.OneMinusDstAlphaGl => MTLBlendFactor.OneMinusDestinationAlpha,
|
||||
BlendFactor.DstColor or BlendFactor.DstColorGl => MTLBlendFactor.DestinationColor,
|
||||
BlendFactor.OneMinusDstColor or BlendFactor.OneMinusDstColorGl => MTLBlendFactor.OneMinusDestinationColor,
|
||||
BlendFactor.SrcAlphaSaturate or BlendFactor.SrcAlphaSaturateGl => MTLBlendFactor.SourceAlphaSaturated,
|
||||
BlendFactor.Src1Color or BlendFactor.Src1ColorGl => MTLBlendFactor.Source1Color,
|
||||
BlendFactor.OneMinusSrc1Color or BlendFactor.OneMinusSrc1ColorGl => MTLBlendFactor.OneMinusSource1Color,
|
||||
BlendFactor.Src1Alpha or BlendFactor.Src1AlphaGl => MTLBlendFactor.Source1Alpha,
|
||||
BlendFactor.OneMinusSrc1Alpha or BlendFactor.OneMinusSrc1AlphaGl => MTLBlendFactor.OneMinusSource1Alpha,
|
||||
BlendFactor.ConstantColor => MTLBlendFactor.BlendColor,
|
||||
BlendFactor.OneMinusConstantColor => MTLBlendFactor.OneMinusBlendColor,
|
||||
BlendFactor.ConstantAlpha => MTLBlendFactor.BlendAlpha,
|
||||
BlendFactor.OneMinusConstantAlpha => MTLBlendFactor.OneMinusBlendAlpha,
|
||||
_ => LogInvalidAndReturn(factor, nameof(BlendFactor), MTLBlendFactor.Zero)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLBlendOperation Convert(this BlendOp op)
|
||||
{
|
||||
return op switch
|
||||
{
|
||||
BlendOp.Add or BlendOp.AddGl => MTLBlendOperation.Add,
|
||||
BlendOp.Subtract or BlendOp.SubtractGl => MTLBlendOperation.Subtract,
|
||||
BlendOp.ReverseSubtract or BlendOp.ReverseSubtractGl => MTLBlendOperation.ReverseSubtract,
|
||||
BlendOp.Minimum => MTLBlendOperation.Min,
|
||||
BlendOp.Maximum => MTLBlendOperation.Max,
|
||||
_ => LogInvalidAndReturn(op, nameof(BlendOp), MTLBlendOperation.Add)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLCompareFunction Convert(this CompareOp op)
|
||||
{
|
||||
return op switch
|
||||
{
|
||||
CompareOp.Never or CompareOp.NeverGl => MTLCompareFunction.Never,
|
||||
CompareOp.Less or CompareOp.LessGl => MTLCompareFunction.Less,
|
||||
CompareOp.Equal or CompareOp.EqualGl => MTLCompareFunction.Equal,
|
||||
CompareOp.LessOrEqual or CompareOp.LessOrEqualGl => MTLCompareFunction.LessEqual,
|
||||
CompareOp.Greater or CompareOp.GreaterGl => MTLCompareFunction.Greater,
|
||||
CompareOp.NotEqual or CompareOp.NotEqualGl => MTLCompareFunction.NotEqual,
|
||||
CompareOp.GreaterOrEqual or CompareOp.GreaterOrEqualGl => MTLCompareFunction.GreaterEqual,
|
||||
CompareOp.Always or CompareOp.AlwaysGl => MTLCompareFunction.Always,
|
||||
_ => LogInvalidAndReturn(op, nameof(CompareOp), MTLCompareFunction.Never)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLCullMode Convert(this Face face)
|
||||
{
|
||||
return face switch
|
||||
{
|
||||
Face.Back => MTLCullMode.Back,
|
||||
Face.Front => MTLCullMode.Front,
|
||||
Face.FrontAndBack => MTLCullMode.None,
|
||||
_ => LogInvalidAndReturn(face, nameof(Face), MTLCullMode.Back)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLWinding Convert(this FrontFace frontFace)
|
||||
{
|
||||
return frontFace switch
|
||||
{
|
||||
FrontFace.Clockwise => MTLWinding.Clockwise,
|
||||
FrontFace.CounterClockwise => MTLWinding.CounterClockwise,
|
||||
_ => LogInvalidAndReturn(frontFace, nameof(FrontFace), MTLWinding.Clockwise)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLIndexType Convert(this IndexType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
IndexType.UShort => MTLIndexType.UInt16,
|
||||
IndexType.UInt => MTLIndexType.UInt32,
|
||||
_ => LogInvalidAndReturn(type, nameof(IndexType), MTLIndexType.UInt16)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLSamplerMinMagFilter Convert(this MagFilter filter)
|
||||
{
|
||||
return filter switch
|
||||
{
|
||||
MagFilter.Nearest => MTLSamplerMinMagFilter.Nearest,
|
||||
MagFilter.Linear => MTLSamplerMinMagFilter.Linear,
|
||||
_ => LogInvalidAndReturn(filter, nameof(MagFilter), MTLSamplerMinMagFilter.Nearest)
|
||||
};
|
||||
}
|
||||
|
||||
public static (MTLSamplerMinMagFilter, MTLSamplerMipFilter) Convert(this MinFilter filter)
|
||||
{
|
||||
return filter switch
|
||||
{
|
||||
MinFilter.Nearest => (MTLSamplerMinMagFilter.Nearest, MTLSamplerMipFilter.Nearest),
|
||||
MinFilter.Linear => (MTLSamplerMinMagFilter.Linear, MTLSamplerMipFilter.Linear),
|
||||
MinFilter.NearestMipmapNearest => (MTLSamplerMinMagFilter.Nearest, MTLSamplerMipFilter.Nearest),
|
||||
MinFilter.LinearMipmapNearest => (MTLSamplerMinMagFilter.Linear, MTLSamplerMipFilter.Nearest),
|
||||
MinFilter.NearestMipmapLinear => (MTLSamplerMinMagFilter.Nearest, MTLSamplerMipFilter.Linear),
|
||||
MinFilter.LinearMipmapLinear => (MTLSamplerMinMagFilter.Linear, MTLSamplerMipFilter.Linear),
|
||||
_ => LogInvalidAndReturn(filter, nameof(MinFilter), (MTLSamplerMinMagFilter.Nearest, MTLSamplerMipFilter.Nearest))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Metal does not have native support for Triangle Fans but it is possible to emulate with TriangleStrip and moving around the indices
|
||||
public static MTLPrimitiveType Convert(this PrimitiveTopology topology)
|
||||
{
|
||||
return topology switch
|
||||
{
|
||||
PrimitiveTopology.Points => MTLPrimitiveType.Point,
|
||||
PrimitiveTopology.Lines => MTLPrimitiveType.Line,
|
||||
PrimitiveTopology.LineStrip => MTLPrimitiveType.LineStrip,
|
||||
PrimitiveTopology.Triangles => MTLPrimitiveType.Triangle,
|
||||
PrimitiveTopology.TriangleStrip => MTLPrimitiveType.TriangleStrip,
|
||||
_ => LogInvalidAndReturn(topology, nameof(PrimitiveTopology), MTLPrimitiveType.Triangle)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLStencilOperation Convert(this StencilOp op)
|
||||
{
|
||||
return op switch
|
||||
{
|
||||
StencilOp.Keep or StencilOp.KeepGl => MTLStencilOperation.Keep,
|
||||
StencilOp.Zero or StencilOp.ZeroGl => MTLStencilOperation.Zero,
|
||||
StencilOp.Replace or StencilOp.ReplaceGl => MTLStencilOperation.Replace,
|
||||
StencilOp.IncrementAndClamp or StencilOp.IncrementAndClampGl => MTLStencilOperation.IncrementClamp,
|
||||
StencilOp.DecrementAndClamp or StencilOp.DecrementAndClampGl => MTLStencilOperation.DecrementClamp,
|
||||
StencilOp.Invert or StencilOp.InvertGl => MTLStencilOperation.Invert,
|
||||
StencilOp.IncrementAndWrap or StencilOp.IncrementAndWrapGl => MTLStencilOperation.IncrementWrap,
|
||||
StencilOp.DecrementAndWrap or StencilOp.DecrementAndWrapGl => MTLStencilOperation.DecrementWrap,
|
||||
_ => LogInvalidAndReturn(op, nameof(StencilOp), MTLStencilOperation.Keep)
|
||||
};
|
||||
}
|
||||
|
||||
public static MTLTextureType Convert(this Target target)
|
||||
{
|
||||
return target switch
|
||||
{
|
||||
Target.TextureBuffer => MTLTextureType.TypeTextureBuffer,
|
||||
Target.Texture1D => MTLTextureType.Type1D,
|
||||
Target.Texture1DArray => MTLTextureType.Type1DArray,
|
||||
Target.Texture2D => MTLTextureType.Type2D,
|
||||
Target.Texture2DArray => MTLTextureType.Type2DArray,
|
||||
Target.Texture2DMultisample => MTLTextureType.Type2DMultisample,
|
||||
Target.Texture2DMultisampleArray => MTLTextureType.Type2DMultisampleArray,
|
||||
Target.Texture3D => MTLTextureType.Type3D,
|
||||
Target.Cubemap => MTLTextureType.TypeCube,
|
||||
Target.CubemapArray => MTLTextureType.TypeCubeArray,
|
||||
_ => LogInvalidAndReturn(target, nameof(Target), MTLTextureType.Type2D)
|
||||
};
|
||||
}
|
||||
|
||||
private static T2 LogInvalidAndReturn<T1, T2>(T1 value, string name, T2 defaultValue = default)
|
||||
{
|
||||
Logger.Debug?.Print(LogClass.Gpu, $"Invalid {name} enum value: {value}.");
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
14
src/Ryujinx.Graphics.Metal/FormatCapabilities.cs
Normal file
14
src/Ryujinx.Graphics.Metal/FormatCapabilities.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using SharpMetal;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
static class FormatCapabilities
|
||||
{
|
||||
public static MTLPixelFormat ConvertToMTLFormat(GAL.Format srcFormat)
|
||||
{
|
||||
var format = FormatTable.GetFormat(srcFormat);
|
||||
|
||||
return format;
|
||||
}
|
||||
}
|
||||
}
|
172
src/Ryujinx.Graphics.Metal/FormatTable.cs
Normal file
172
src/Ryujinx.Graphics.Metal/FormatTable.cs
Normal file
@ -0,0 +1,172 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using SharpMetal;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
static class FormatTable
|
||||
{
|
||||
private static readonly MTLPixelFormat[] _table;
|
||||
|
||||
static FormatTable()
|
||||
{
|
||||
_table = new MTLPixelFormat[Enum.GetNames(typeof(Format)).Length];
|
||||
|
||||
Add(Format.R8Unorm, MTLPixelFormat.R8Unorm);
|
||||
Add(Format.R8Snorm, MTLPixelFormat.R8Snorm);
|
||||
Add(Format.R8Uint, MTLPixelFormat.R8Uint);
|
||||
Add(Format.R8Sint, MTLPixelFormat.R8Sint);
|
||||
Add(Format.R16Float, MTLPixelFormat.R16Float);
|
||||
Add(Format.R16Unorm, MTLPixelFormat.R16Unorm);
|
||||
Add(Format.R16Snorm, MTLPixelFormat.R16Snorm);
|
||||
Add(Format.R16Uint, MTLPixelFormat.R16Uint);
|
||||
Add(Format.R16Sint, MTLPixelFormat.R16Sint);
|
||||
Add(Format.R32Float, MTLPixelFormat.R32Float);
|
||||
Add(Format.R32Uint, MTLPixelFormat.R32Uint);
|
||||
Add(Format.R32Sint, MTLPixelFormat.R32Sint);
|
||||
Add(Format.R8G8Unorm, MTLPixelFormat.RG8Unorm);
|
||||
Add(Format.R8G8Snorm, MTLPixelFormat.RG8Snorm);
|
||||
Add(Format.R8G8Uint, MTLPixelFormat.RG8Uint);
|
||||
Add(Format.R8G8Sint, MTLPixelFormat.RG8Sint);
|
||||
Add(Format.R16G16Float, MTLPixelFormat.RG16Float);
|
||||
Add(Format.R16G16Unorm, MTLPixelFormat.RG16Unorm);
|
||||
Add(Format.R16G16Snorm, MTLPixelFormat.RG16Snorm);
|
||||
Add(Format.R16G16Uint, MTLPixelFormat.RG16Uint);
|
||||
Add(Format.R16G16Sint, MTLPixelFormat.RG16Sint);
|
||||
Add(Format.R32G32Float, MTLPixelFormat.RG32Float);
|
||||
Add(Format.R32G32Uint, MTLPixelFormat.RG32Uint);
|
||||
Add(Format.R32G32Sint, MTLPixelFormat.RG32Sint);
|
||||
// Add(Format.R8G8B8Unorm, MTLPixelFormat.R8G8B8Unorm);
|
||||
// Add(Format.R8G8B8Snorm, MTLPixelFormat.R8G8B8Snorm);
|
||||
// Add(Format.R8G8B8Uint, MTLPixelFormat.R8G8B8Uint);
|
||||
// Add(Format.R8G8B8Sint, MTLPixelFormat.R8G8B8Sint);
|
||||
// Add(Format.R16G16B16Float, MTLPixelFormat.R16G16B16Float);
|
||||
// Add(Format.R16G16B16Unorm, MTLPixelFormat.R16G16B16Unorm);
|
||||
// Add(Format.R16G16B16Snorm, MTLPixelFormat.R16G16B16SNorm);
|
||||
// Add(Format.R16G16B16Uint, MTLPixelFormat.R16G16B16Uint);
|
||||
// Add(Format.R16G16B16Sint, MTLPixelFormat.R16G16B16Sint);
|
||||
// Add(Format.R32G32B32Float, MTLPixelFormat.R32G32B32Sfloat);
|
||||
// Add(Format.R32G32B32Uint, MTLPixelFormat.R32G32B32Uint);
|
||||
// Add(Format.R32G32B32Sint, MTLPixelFormat.R32G32B32Sint);
|
||||
Add(Format.R8G8B8A8Unorm, MTLPixelFormat.RGBA8Unorm);
|
||||
Add(Format.R8G8B8A8Snorm, MTLPixelFormat.RGBA8Snorm);
|
||||
Add(Format.R8G8B8A8Uint, MTLPixelFormat.RGBA8Uint);
|
||||
Add(Format.R8G8B8A8Sint, MTLPixelFormat.RGBA8Sint);
|
||||
Add(Format.R16G16B16A16Float, MTLPixelFormat.RGBA16Float);
|
||||
Add(Format.R16G16B16A16Unorm, MTLPixelFormat.RGBA16Unorm);
|
||||
Add(Format.R16G16B16A16Snorm, MTLPixelFormat.RGBA16Snorm);
|
||||
Add(Format.R16G16B16A16Uint, MTLPixelFormat.RGBA16Uint);
|
||||
Add(Format.R16G16B16A16Sint, MTLPixelFormat.RGBA16Sint);
|
||||
Add(Format.R32G32B32A32Float, MTLPixelFormat.RGBA32Float);
|
||||
Add(Format.R32G32B32A32Uint, MTLPixelFormat.RGBA32Uint);
|
||||
Add(Format.R32G32B32A32Sint, MTLPixelFormat.RGBA32Sint);
|
||||
Add(Format.S8Uint, MTLPixelFormat.Stencil8);
|
||||
Add(Format.D16Unorm, MTLPixelFormat.Depth16Unorm);
|
||||
// Add(Format.S8UintD24Unorm, MTLPixelFormat.S8UintD24Unorm);
|
||||
Add(Format.D32Float, MTLPixelFormat.Depth32Float);
|
||||
Add(Format.D24UnormS8Uint, MTLPixelFormat.Depth24Unorm_Stencil8);
|
||||
Add(Format.D32FloatS8Uint, MTLPixelFormat.Depth32Float_Stencil8);
|
||||
Add(Format.R8G8B8A8Srgb, MTLPixelFormat.RGBA8Unorm_sRGB);
|
||||
// Add(Format.R4G4Unorm, MTLPixelFormat.R4G4Unorm);
|
||||
// Add(Format.R4G4B4A4Unorm, MTLPixelFormat.R4G4B4A4Unorm);
|
||||
// Add(Format.R5G5B5X1Unorm, MTLPixelFormat.R5G5B5X1Unorm);
|
||||
// Add(Format.R5G5B5A1Unorm, MTLPixelFormat.R5G5B5A1Unorm);
|
||||
Add(Format.R5G6B5Unorm, MTLPixelFormat.B5G6R5Unorm);
|
||||
Add(Format.R10G10B10A2Unorm, MTLPixelFormat.RGB10A2Unorm);
|
||||
Add(Format.R10G10B10A2Uint, MTLPixelFormat.RGB10A2Uint);
|
||||
Add(Format.R11G11B10Float, MTLPixelFormat.RG11B10Float);
|
||||
Add(Format.R9G9B9E5Float, MTLPixelFormat.RGB9E5Float);
|
||||
Add(Format.Bc1RgbaUnorm, MTLPixelFormat.BC1_RGBA);
|
||||
Add(Format.Bc2Unorm, MTLPixelFormat.BC2_RGBA);
|
||||
Add(Format.Bc3Unorm, MTLPixelFormat.BC3_RGBA);
|
||||
Add(Format.Bc1RgbaSrgb, MTLPixelFormat.BC1_RGBA_sRGB);
|
||||
Add(Format.Bc2Srgb, MTLPixelFormat.BC2_RGBA_sRGB);
|
||||
Add(Format.Bc3Srgb, MTLPixelFormat.BC3_RGBA_sRGB);
|
||||
Add(Format.Bc4Unorm, MTLPixelFormat.BC4_RUnorm);
|
||||
Add(Format.Bc4Snorm, MTLPixelFormat.BC4_RSnorm);
|
||||
Add(Format.Bc5Unorm, MTLPixelFormat.BC5_RGUnorm);
|
||||
Add(Format.Bc5Snorm, MTLPixelFormat.BC5_RGSnorm);
|
||||
Add(Format.Bc7Unorm, MTLPixelFormat.BC7_RGBAUnorm);
|
||||
Add(Format.Bc7Srgb, MTLPixelFormat.BC7_RGBAUnorm_sRGB);
|
||||
Add(Format.Bc6HSfloat, MTLPixelFormat.BC6H_RGBFloat);
|
||||
Add(Format.Bc6HUfloat, MTLPixelFormat.BC6H_RGBUfloat);
|
||||
Add(Format.Etc2RgbUnorm, MTLPixelFormat.ETC2_RGB8);
|
||||
Add(Format.Etc2RgbaUnorm, MTLPixelFormat.ETC2_RGB8A1);
|
||||
// Add(Format.Etc2RgbPtaUnorm, MTLPixelFormat.Etc2RgbPtaUnorm);
|
||||
Add(Format.Etc2RgbSrgb, MTLPixelFormat.ETC2_RGB8_sRGB);
|
||||
Add(Format.Etc2RgbaSrgb, MTLPixelFormat.ETC2_RGB8A1_sRGB);
|
||||
// Add(Format.Etc2RgbPtaSrgb, MTLPixelFormat.Etc2RgbPtaSrgb);
|
||||
// Add(Format.R8Uscaled, MTLPixelFormat.R8Uscaled);
|
||||
// Add(Format.R8Sscaled, MTLPixelFormat.R8Sscaled);
|
||||
// Add(Format.R16Uscaled, MTLPixelFormat.R16Uscaled);
|
||||
// Add(Format.R16Sscaled, MTLPixelFormat.R16Sscaled);
|
||||
// Add(Format.R32Uscaled, MTLPixelFormat.R32Uscaled);
|
||||
// Add(Format.R32Sscaled, MTLPixelFormat.R32Sscaled);
|
||||
// Add(Format.R8G8Uscaled, MTLPixelFormat.R8G8Uscaled);
|
||||
// Add(Format.R8G8Sscaled, MTLPixelFormat.R8G8Sscaled);
|
||||
// Add(Format.R16G16Uscaled, MTLPixelFormat.R16G16Uscaled);
|
||||
// Add(Format.R16G16Sscaled, MTLPixelFormat.R16G16Sscaled);
|
||||
// Add(Format.R32G32Uscaled, MTLPixelFormat.R32G32Uscaled);
|
||||
// Add(Format.R32G32Sscaled, MTLPixelFormat.R32G32Sscaled);
|
||||
// Add(Format.R8G8B8Uscaled, MTLPixelFormat.R8G8B8Uscaled);
|
||||
// Add(Format.R8G8B8Sscaled, MTLPixelFormat.R8G8B8Sscaled);
|
||||
// Add(Format.R16G16B16Uscaled, MTLPixelFormat.R16G16B16Uscaled);
|
||||
// Add(Format.R16G16B16Sscaled, MTLPixelFormat.R16G16B16Sscaled);
|
||||
// Add(Format.R32G32B32Uscaled, MTLPixelFormat.R32G32B32Uscaled);
|
||||
// Add(Format.R32G32B32Sscaled, MTLPixelFormat.R32G32B32Sscaled);
|
||||
// Add(Format.R8G8B8A8Uscaled, MTLPixelFormat.R8G8B8A8Uscaled);
|
||||
// Add(Format.R8G8B8A8Sscaled, MTLPixelFormat.R8G8B8A8Sscaled);
|
||||
// Add(Format.R16G16B16A16Uscaled, MTLPixelFormat.R16G16B16A16Uscaled);
|
||||
// Add(Format.R16G16B16A16Sscaled, MTLPixelFormat.R16G16B16A16Sscaled);
|
||||
// Add(Format.R32G32B32A32Uscaled, MTLPixelFormat.R32G32B32A32Uscaled);
|
||||
// Add(Format.R32G32B32A32Sscaled, MTLPixelFormat.R32G32B32A32Sscaled);
|
||||
// Add(Format.R10G10B10A2Snorm, MTLPixelFormat.A2B10G10R10SNormPack32);
|
||||
// Add(Format.R10G10B10A2Sint, MTLPixelFormat.A2B10G10R10SintPack32);
|
||||
// Add(Format.R10G10B10A2Uscaled, MTLPixelFormat.A2B10G10R10UscaledPack32);
|
||||
// Add(Format.R10G10B10A2Sscaled, MTLPixelFormat.A2B10G10R10SscaledPack32);
|
||||
Add(Format.Astc4x4Unorm, MTLPixelFormat.ASTC_4x4_LDR);
|
||||
Add(Format.Astc5x4Unorm, MTLPixelFormat.ASTC_5x4_LDR);
|
||||
Add(Format.Astc5x5Unorm, MTLPixelFormat.ASTC_5x5_LDR);
|
||||
Add(Format.Astc6x5Unorm, MTLPixelFormat.ASTC_6x5_LDR);
|
||||
Add(Format.Astc6x6Unorm, MTLPixelFormat.ASTC_6x6_LDR);
|
||||
Add(Format.Astc8x5Unorm, MTLPixelFormat.ASTC_8x5_LDR);
|
||||
Add(Format.Astc8x6Unorm, MTLPixelFormat.ASTC_8x6_LDR);
|
||||
Add(Format.Astc8x8Unorm, MTLPixelFormat.ASTC_8x8_LDR);
|
||||
Add(Format.Astc10x5Unorm, MTLPixelFormat.ASTC_10x5_LDR);
|
||||
Add(Format.Astc10x6Unorm, MTLPixelFormat.ASTC_10x6_LDR);
|
||||
Add(Format.Astc10x8Unorm, MTLPixelFormat.ASTC_10x8_LDR);
|
||||
Add(Format.Astc10x10Unorm, MTLPixelFormat.ASTC_10x10_LDR);
|
||||
Add(Format.Astc12x10Unorm, MTLPixelFormat.ASTC_12x10_LDR);
|
||||
Add(Format.Astc12x12Unorm, MTLPixelFormat.ASTC_12x12_LDR);
|
||||
Add(Format.Astc4x4Srgb, MTLPixelFormat.ASTC_4x4_sRGB);
|
||||
Add(Format.Astc5x4Srgb, MTLPixelFormat.ASTC_5x4_sRGB);
|
||||
Add(Format.Astc5x5Srgb, MTLPixelFormat.ASTC_5x5_sRGB);
|
||||
Add(Format.Astc6x5Srgb, MTLPixelFormat.ASTC_6x5_sRGB);
|
||||
Add(Format.Astc6x6Srgb, MTLPixelFormat.ASTC_6x6_sRGB);
|
||||
Add(Format.Astc8x5Srgb, MTLPixelFormat.ASTC_8x5_sRGB);
|
||||
Add(Format.Astc8x6Srgb, MTLPixelFormat.ASTC_8x6_sRGB);
|
||||
Add(Format.Astc8x8Srgb, MTLPixelFormat.ASTC_8x8_sRGB);
|
||||
Add(Format.Astc10x5Srgb, MTLPixelFormat.ASTC_10x5_sRGB);
|
||||
Add(Format.Astc10x6Srgb, MTLPixelFormat.ASTC_10x6_sRGB);
|
||||
Add(Format.Astc10x8Srgb, MTLPixelFormat.ASTC_10x8_sRGB);
|
||||
Add(Format.Astc10x10Srgb, MTLPixelFormat.ASTC_10x10_sRGB);
|
||||
Add(Format.Astc12x10Srgb, MTLPixelFormat.ASTC_12x10_sRGB);
|
||||
Add(Format.Astc12x12Srgb, MTLPixelFormat.ASTC_12x12_sRGB);
|
||||
Add(Format.B5G6R5Unorm, MTLPixelFormat.B5G6R5Unorm);
|
||||
Add(Format.B5G5R5A1Unorm, MTLPixelFormat.BGR5A1Unorm);
|
||||
Add(Format.A1B5G5R5Unorm, MTLPixelFormat.A1BGR5Unorm);
|
||||
Add(Format.B8G8R8A8Unorm, MTLPixelFormat.BGRA8Unorm);
|
||||
Add(Format.B8G8R8A8Srgb, MTLPixelFormat.BGRA8Unorm_sRGB);
|
||||
}
|
||||
|
||||
private static void Add(Format format, MTLPixelFormat mtlFormat)
|
||||
{
|
||||
_table[(int)format] = mtlFormat;
|
||||
}
|
||||
|
||||
public static MTLPixelFormat GetFormat(Format format)
|
||||
{
|
||||
return _table[(int)format];
|
||||
}
|
||||
}
|
||||
}
|
82
src/Ryujinx.Graphics.Metal/HardwareInfo.cs
Normal file
82
src/Ryujinx.Graphics.Metal/HardwareInfo.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
static partial class HardwareInfoTools
|
||||
{
|
||||
|
||||
private readonly static IntPtr kCFAllocatorDefault = IntPtr.Zero;
|
||||
private readonly static UInt32 kCFStringEncodingASCII = 0x0600;
|
||||
private const string IOKit = "/System/Library/Frameworks/IOKit.framework/IOKit";
|
||||
private const string CoreFoundation = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
|
||||
|
||||
[LibraryImport(IOKit, StringMarshalling = StringMarshalling.Utf8)]
|
||||
private static partial IntPtr IOServiceMatching(string name);
|
||||
|
||||
[LibraryImport(IOKit)]
|
||||
private static partial IntPtr IOServiceGetMatchingService(IntPtr mainPort, IntPtr matching);
|
||||
|
||||
[LibraryImport(IOKit)]
|
||||
private static partial IntPtr IORegistryEntryCreateCFProperty(IntPtr entry, IntPtr key, IntPtr allocator, UInt32 options);
|
||||
|
||||
[LibraryImport(CoreFoundation, StringMarshalling = StringMarshalling.Utf8)]
|
||||
private static partial IntPtr CFStringCreateWithCString(IntPtr allocator, string cString, UInt32 encoding);
|
||||
|
||||
[LibraryImport(CoreFoundation)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static partial bool CFStringGetCString(IntPtr theString, IntPtr buffer, long bufferSizes, UInt32 encoding);
|
||||
|
||||
[LibraryImport(CoreFoundation)]
|
||||
public static partial IntPtr CFDataGetBytePtr(IntPtr theData);
|
||||
|
||||
static string GetNameFromId(uint id)
|
||||
{
|
||||
return id switch
|
||||
{
|
||||
0x1002 => "AMD",
|
||||
0x106B => "Apple",
|
||||
0x10DE => "NVIDIA",
|
||||
0x13B5 => "ARM",
|
||||
0x8086 => "Intel",
|
||||
_ => $"0x{id:X}"
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetVendor()
|
||||
{
|
||||
var serviceDict = IOServiceMatching("IOGPU");
|
||||
var service = IOServiceGetMatchingService(IntPtr.Zero, serviceDict);
|
||||
var cfString = CFStringCreateWithCString(kCFAllocatorDefault, "vendor-id", kCFStringEncodingASCII);
|
||||
var cfProperty = IORegistryEntryCreateCFProperty(service, cfString, kCFAllocatorDefault, 0);
|
||||
|
||||
byte[] buffer = new byte[4];
|
||||
var bufferPtr = CFDataGetBytePtr(cfProperty);
|
||||
Marshal.Copy(bufferPtr, buffer, 0, buffer.Length);
|
||||
|
||||
var vendorId = BitConverter.ToUInt32(buffer);
|
||||
|
||||
return GetNameFromId(vendorId);
|
||||
}
|
||||
|
||||
public static string GetModel()
|
||||
{
|
||||
var serviceDict = IOServiceMatching("IOGPU");
|
||||
var service = IOServiceGetMatchingService(IntPtr.Zero, serviceDict);
|
||||
var cfString = CFStringCreateWithCString(kCFAllocatorDefault, "model", kCFStringEncodingASCII);
|
||||
var cfProperty = IORegistryEntryCreateCFProperty(service, cfString, kCFAllocatorDefault, 0);
|
||||
|
||||
char[] buffer = new char[64];
|
||||
IntPtr bufferPtr = Marshal.AllocHGlobal(buffer.Length);
|
||||
|
||||
if (CFStringGetCString(cfProperty, bufferPtr, buffer.Length, kCFStringEncodingASCII))
|
||||
{
|
||||
var model = Marshal.PtrToStringUTF8(bufferPtr);
|
||||
Marshal.FreeHGlobal(bufferPtr);
|
||||
return model;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
246
src/Ryujinx.Graphics.Metal/MetalRenderer.cs
Normal file
246
src/Ryujinx.Graphics.Metal/MetalRenderer.cs
Normal file
@ -0,0 +1,246 @@
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System;
|
||||
using SharpMetal;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
public sealed class MetalRenderer : IRenderer
|
||||
{
|
||||
private MTLDevice _device;
|
||||
|
||||
private Window _window;
|
||||
|
||||
private Pipeline _pipeline;
|
||||
|
||||
internal MTLCommandQueue Queue { get; private set; }
|
||||
|
||||
internal int BufferCount { get; private set; }
|
||||
|
||||
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||
public bool PreferThreading => true;
|
||||
public IPipeline Pipeline => _pipeline;
|
||||
public IWindow Window => _window;
|
||||
|
||||
public void Initialize(GraphicsDebugLevel logLevel)
|
||||
{
|
||||
_device = MTLDevice.MTLCreateSystemDefaultDevice();
|
||||
Queue = _device.NewCommandQueueWithMaxCommandBufferCount(Constants.MaxCommandBuffersPerQueue);
|
||||
|
||||
var commandBuffer = Queue.CommandBufferWithDescriptor(new MTLCommandBufferDescriptor { RetainedReferences = true });
|
||||
|
||||
_pipeline = new Pipeline(_device, commandBuffer);
|
||||
}
|
||||
|
||||
public void BackgroundContextAction(Action action, bool alwaysBackground = false)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public BufferHandle CreateBuffer(int size, BufferHandle storageHint)
|
||||
{
|
||||
return CreateBuffer(size, BufferAccess.Default);
|
||||
}
|
||||
|
||||
public BufferHandle CreateBuffer(IntPtr pointer, int size)
|
||||
{
|
||||
BufferCount++;
|
||||
|
||||
var buffer = _device.NewBufferWithBytesLengthOptions(pointer, (ulong)size, MTLResourceOptions.StorageModeShared);
|
||||
var bufferPtr = buffer.NativePtr;
|
||||
return Unsafe.As<IntPtr, BufferHandle>(ref bufferPtr);
|
||||
}
|
||||
|
||||
public BufferHandle CreateBuffer(int size, BufferAccess access)
|
||||
{
|
||||
BufferCount++;
|
||||
|
||||
var buffer = _device.NewBufferWithLengthOptions((ulong)size, MTLResourceOptions.StorageModeShared);
|
||||
var bufferPtr = buffer.NativePtr;
|
||||
return Unsafe.As<IntPtr, BufferHandle>(ref bufferPtr);
|
||||
}
|
||||
|
||||
public IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info)
|
||||
{
|
||||
var library = _device.NewDefaultLibrary();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ISampler CreateSampler(SamplerCreateInfo info)
|
||||
{
|
||||
(MTLSamplerMinMagFilter minFilter, MTLSamplerMipFilter mipFilter) = info.MinFilter.Convert();
|
||||
|
||||
var sampler = _device.CreateSamplerState(new MTLSamplerDescriptor
|
||||
{
|
||||
BorderColor = MTLSamplerBorderColor.TransparentBlack,
|
||||
MinFilter = minFilter,
|
||||
MagFilter = info.MagFilter.Convert(),
|
||||
MipFilter = mipFilter,
|
||||
CompareFunction = info.CompareOp.Convert(),
|
||||
LodMinClamp = info.MinLod,
|
||||
LodMaxClamp = info.MaxLod,
|
||||
LodAverage = false,
|
||||
MaxAnisotropy = (uint)info.MaxAnisotropy,
|
||||
SAddressMode = info.AddressU.Convert(),
|
||||
TAddressMode = info.AddressV.Convert(),
|
||||
RAddressMode = info.AddressP.Convert()
|
||||
});
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITexture CreateTexture(TextureCreateInfo info, float scale)
|
||||
{
|
||||
MTLTextureDescriptor descriptor = new()
|
||||
{
|
||||
PixelFormat = FormatCapabilities.ConvertToMTLFormat(info.Format),
|
||||
TextureType = info.Target.Convert(),
|
||||
Width = (ulong)info.Width,
|
||||
Height = (ulong)info.Height,
|
||||
MipmapLevelCount = (ulong)info.Levels,
|
||||
SampleCount = (ulong)info.Samples,
|
||||
};
|
||||
|
||||
return CreateTextureView(info, scale);
|
||||
}
|
||||
|
||||
internal TextureView CreateTextureView(TextureCreateInfo info, float scale)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool PrepareHostMapping(IntPtr address, ulong size)
|
||||
{
|
||||
// TODO: Metal Host Mapping
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CreateSync(ulong id, bool strict)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DeleteBuffer(BufferHandle buffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PinnedSpan<byte> GetBufferData(BufferHandle buffer, int offset, int size)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Capabilities GetCapabilities()
|
||||
{
|
||||
// TODO: Finalize these values
|
||||
return new Capabilities(
|
||||
api: TargetApi.Metal,
|
||||
vendorName: HardwareInfoTools.GetVendor(),
|
||||
hasFrontFacingBug: false,
|
||||
hasVectorIndexingBug: true,
|
||||
needsFragmentOutputSpecialization: true,
|
||||
reduceShaderPrecision: true,
|
||||
supportsAstcCompression: true,
|
||||
supportsBc123Compression: true,
|
||||
supportsBc45Compression: true,
|
||||
supportsBc67Compression: true,
|
||||
supportsEtc2Compression: true,
|
||||
supports3DTextureCompression: true,
|
||||
supportsBgraFormat: true,
|
||||
supportsR4G4Format: false,
|
||||
supportsR4G4B4A4Format: true,
|
||||
supportsSnormBufferTextureFormat: true,
|
||||
supports5BitComponentFormat: true,
|
||||
supportsBlendEquationAdvanced: false,
|
||||
supportsFragmentShaderInterlock: true,
|
||||
supportsFragmentShaderOrderingIntel: false,
|
||||
supportsGeometryShader: false,
|
||||
supportsGeometryShaderPassthrough: false,
|
||||
supportsImageLoadFormatted: false,
|
||||
supportsLayerVertexTessellation: false,
|
||||
supportsMismatchingViewFormat: true,
|
||||
supportsCubemapView: true,
|
||||
supportsNonConstantTextureOffset: false,
|
||||
supportsShaderBallot: false,
|
||||
supportsTextureShadowLod: false,
|
||||
supportsViewportIndexVertexTessellation: false,
|
||||
supportsViewportMask: false,
|
||||
supportsViewportSwizzle: false,
|
||||
supportsIndirectParameters: true,
|
||||
maximumUniformBuffersPerStage: Constants.MaxUniformBuffersPerStage,
|
||||
maximumStorageBuffersPerStage: Constants.MaxStorageBuffersPerStage,
|
||||
maximumTexturesPerStage: Constants.MaxTexturesPerStage,
|
||||
maximumImagesPerStage: Constants.MaxTextureBindings,
|
||||
maximumComputeSharedMemorySize: (int)_device.MaxThreadgroupMemoryLength,
|
||||
maximumSupportedAnisotropy: 0,
|
||||
storageBufferOffsetAlignment: 0,
|
||||
gatherBiasPrecision: 0
|
||||
);
|
||||
}
|
||||
|
||||
public ulong GetCurrentSync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public HardwareInfo GetHardwareInfo()
|
||||
{
|
||||
return new HardwareInfo(HardwareInfoTools.GetVendor(), HardwareInfoTools.GetModel());
|
||||
}
|
||||
|
||||
public IProgram LoadProgramBinary(byte[] programBinary, bool hasFragmentShader, ShaderInfo info)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateCounters()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void PreFrame()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, bool hostReserved)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ResetCounter(CounterType type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void WaitSync(ulong id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetInterruptAction(Action<Action> interruptAction)
|
||||
{
|
||||
// Not needed for now
|
||||
}
|
||||
|
||||
public void Screenshot()
|
||||
{
|
||||
// TODO: Screenshots
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_window.Dispose();
|
||||
_pipeline.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
314
src/Ryujinx.Graphics.Metal/Pipeline.cs
Normal file
314
src/Ryujinx.Graphics.Metal/Pipeline.cs
Normal file
@ -0,0 +1,314 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
using SharpMetal;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
public class Pipeline : IPipeline, IDisposable
|
||||
{
|
||||
private MTLCommandBuffer _commandBuffer;
|
||||
private MTLRenderCommandEncoder _renderCommandEncoder;
|
||||
|
||||
public Pipeline(MTLDevice device, MTLCommandBuffer commandBuffer)
|
||||
{
|
||||
var renderPipelineDescriptor = new MTLRenderPipelineDescriptor();
|
||||
var renderPipelineState = device.CreateRenderPipelineState(renderPipelineDescriptor, out NSError _);
|
||||
|
||||
_commandBuffer = commandBuffer;
|
||||
_renderCommandEncoder = _commandBuffer.CreateRenderCommandEncoder(new MTLRenderPassDescriptor());
|
||||
_renderCommandEncoder.SetRenderPipelineState(renderPipelineState);
|
||||
}
|
||||
|
||||
public void Barrier()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ClearBuffer(BufferHandle destination, int offset, int size, uint value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ClearRenderTargetColor(int index, int layer, int layerCount, uint componentMask, ColorF color)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ClearRenderTargetDepthStencil(int layer, int layerCount, float depthValue, bool depthMask, int stencilValue,
|
||||
int stencilMask)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CommandBufferBarrier()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyBuffer(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DispatchCompute(int groupsX, int groupsY, int groupsZ)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DrawIndexedIndirect(BufferRange indirectBuffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DrawIndirect(BufferRange indirectBuffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetAlphaTest(bool enable, float reference, CompareOp op)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetBlendState(AdvancedBlendDescriptor blend)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetBlendState(int index, BlendDescriptor blend)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetDepthClamp(bool clamp)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetDepthMode(DepthMode mode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetDepthTest(DepthTestDescriptor depthTest)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetFaceCulling(bool enable, Face face)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetFrontFace(FrontFace frontFace)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetIndexBuffer(BufferRange buffer, IndexType type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetImage(int binding, ITexture texture, Format imageFormat)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetLineParameters(float width, bool smooth)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetLogicOpState(bool enable, LogicalOp op)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetMultisampleState(MultisampleDescriptor multisample)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetPatchParameters(int vertices, ReadOnlySpan<float> defaultOuterLevel, ReadOnlySpan<float> defaultInnerLevel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetPolygonMode(PolygonMode frontMode, PolygonMode backMode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetPrimitiveRestart(bool enable, int index)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetPrimitiveTopology(PrimitiveTopology topology)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetProgram(IProgram program)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetRasterizerDiscard(bool discard)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetRenderTargetScale(float scale)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetRenderTargets(ITexture[] colors, ITexture depthStencil)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetScissors(ReadOnlySpan<Rectangle<int>> regions)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetStencilTest(StencilTestDescriptor stencilTest)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetStorageBuffers(ReadOnlySpan<BufferAssignment> buffers)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetTextureAndSampler(ShaderStage stage, int binding, ITexture texture, ISampler sampler)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetUniformBuffers(ReadOnlySpan<BufferAssignment> buffers)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetUserClipDistance(int index, bool enableClip)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetViewports(ReadOnlySpan<Viewport> viewports, bool disableTransform)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void TextureBarrier()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void TextureBarrierTiled()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryHostConditionalRendering(ICounterEvent value, ulong compare, bool isEqual)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryHostConditionalRendering(ICounterEvent value, ICounterEvent compare, bool isEqual)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void EndHostConditionalRendering()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateRenderScale(ReadOnlySpan<float> scales, int totalCount, int fragmentCount)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void BeginTransformFeedback(PrimitiveTopology topology)
|
||||
{
|
||||
// Metal does not support Transform Feedback
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void EndTransformFeedback()
|
||||
{
|
||||
// Metal does not support Transform Feedback
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void SetTransformFeedbackBuffers(ReadOnlySpan<BufferRange> buffers)
|
||||
{
|
||||
// Metal does not support Transform Feedback
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
17
src/Ryujinx.Graphics.Metal/Ryujinx.Graphics.Metal.csproj
Normal file
17
src/Ryujinx.Graphics.Metal/Ryujinx.Graphics.Metal.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Graphics.GAL\Ryujinx.Graphics.GAL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpMetal" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
77
src/Ryujinx.Graphics.Metal/TextureView.cs
Normal file
77
src/Ryujinx.Graphics.Metal/TextureView.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
class TextureView : ITexture, IDisposable
|
||||
{
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
public float ScaleFactor { get; }
|
||||
public void CopyTo(ITexture destination, int firstLayer, int firstLevel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyTo(ITexture destination, int srcLayer, int dstLayer, int srcLevel, int dstLevel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyTo(BufferRange range, int layer, int level, int stride)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PinnedSpan<byte> GetData()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PinnedSpan<byte> GetData(int layer, int level)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetStorage(BufferRange buffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
53
src/Ryujinx.Graphics.Metal/Window.cs
Normal file
53
src/Ryujinx.Graphics.Metal/Window.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using SharpMetal;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal
|
||||
{
|
||||
public class Window : IWindow, IDisposable
|
||||
{
|
||||
|
||||
public Window()
|
||||
{
|
||||
/*var viewport = new MTLViewport
|
||||
{
|
||||
|
||||
};*/
|
||||
}
|
||||
|
||||
public void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetSize(int width, int height)
|
||||
{
|
||||
// Not needed as we can get the size from the surface.
|
||||
}
|
||||
|
||||
public void ChangeVSyncMode(bool vsyncEnabled)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetAntiAliasing(AntiAliasing antialiasing)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetScalingFilter(ScalingFilter type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetScalingFilterLevel(float level)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
88
src/Ryujinx.Graphics.Shader/CodeGen/Msl/CodeGenContext.cs
Normal file
88
src/Ryujinx.Graphics.Shader/CodeGen/Msl/CodeGenContext.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||
{
|
||||
class CodeGenContext
|
||||
{
|
||||
public const string Tab = " ";
|
||||
|
||||
public StructuredProgramInfo Info { get; }
|
||||
public ShaderConfig Config { get; }
|
||||
|
||||
private readonly StringBuilder _sb;
|
||||
|
||||
private int _level;
|
||||
|
||||
private string _indentation;
|
||||
|
||||
public CodeGenContext(StructuredProgramInfo info, ShaderConfig config)
|
||||
{
|
||||
Info = info;
|
||||
Config = Config;
|
||||
|
||||
_sb = new StringBuilder();
|
||||
}
|
||||
|
||||
public void AppendLine()
|
||||
{
|
||||
_sb.AppendLine();
|
||||
}
|
||||
|
||||
public void AppendLine(string str)
|
||||
{
|
||||
_sb.AppendLine(_indentation + str);
|
||||
}
|
||||
|
||||
public string GetCode()
|
||||
{
|
||||
return _sb.ToString();
|
||||
}
|
||||
|
||||
public void EnterScope()
|
||||
{
|
||||
AppendLine("{");
|
||||
|
||||
_level++;
|
||||
|
||||
UpdateIndentation();
|
||||
}
|
||||
|
||||
public void LeaveScope(string suffix = "")
|
||||
{
|
||||
if (_level == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_level--;
|
||||
|
||||
UpdateIndentation();
|
||||
|
||||
AppendLine("}" + suffix);
|
||||
}
|
||||
|
||||
public StructuredFunction GetFunction(int id)
|
||||
{
|
||||
return Info.Functions[id];
|
||||
}
|
||||
|
||||
private void UpdateIndentation()
|
||||
{
|
||||
_indentation = GetIndentation(_level);
|
||||
}
|
||||
|
||||
private static string GetIndentation(int level)
|
||||
{
|
||||
string indentation = string.Empty;
|
||||
|
||||
for (int index = 0; index < level; index++)
|
||||
{
|
||||
indentation += Tab;
|
||||
}
|
||||
|
||||
return indentation;
|
||||
}
|
||||
}
|
||||
}
|
16
src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs
Normal file
16
src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Ryujinx.Graphics.Shader.CodeGen.Glsl;
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||
{
|
||||
static class Declarations
|
||||
{
|
||||
public static void Declare(CodeGenContext context, StructuredProgramInfo info)
|
||||
{
|
||||
context.AppendLine("#include <metal_stdlib>");
|
||||
context.AppendLine("#include <simd/simd.h>");
|
||||
context.AppendLine();
|
||||
context.AppendLine("using namespace metal;");
|
||||
}
|
||||
}
|
||||
}
|
17
src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs
Normal file
17
src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||
{
|
||||
static class MslGenerator
|
||||
{
|
||||
public static string Generate(StructuredProgramInfo info, ShaderConfig config)
|
||||
{
|
||||
CodeGenContext context = new CodeGenContext(info, config);
|
||||
|
||||
Declarations.Declare(context, info);
|
||||
|
||||
return context.GetCode();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,5 +4,6 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
OpenGL,
|
||||
Vulkan,
|
||||
Metal
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
Glsl,
|
||||
Spirv,
|
||||
Arb,
|
||||
Msl
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ using Ryujinx.Graphics.GAL.Multithreading;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.Graphics.OpenGL;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Ryujinx.Graphics.Metal;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
@ -1067,10 +1068,12 @@ namespace Ryujinx.Ava
|
||||
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
|
||||
Device.EnableDeviceVsync,
|
||||
LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%",
|
||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value.ToText(),
|
||||
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} %"));
|
||||
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %",
|
||||
$"GPU: {_renderer.GetHardwareInfo().GpuDriver}"));
|
||||
}
|
||||
|
||||
public async Task ShowExitPrompt()
|
||||
|
1225
src/Ryujinx/AppHost.cs.orig
Normal file
1225
src/Ryujinx/AppHost.cs.orig
Normal file
File diff suppressed because it is too large
Load Diff
@ -188,6 +188,10 @@ namespace Ryujinx.Ava
|
||||
{
|
||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
|
||||
}
|
||||
else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "metal")
|
||||
{
|
||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Metal;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if docked mode was overriden.
|
||||
|
25
src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs
Normal file
25
src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using SPB.Windowing;
|
||||
using SPB.Platform.Metal;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.UI.Renderer
|
||||
{
|
||||
public class EmbeddedWindowMetal : EmbeddedWindow
|
||||
{
|
||||
public SimpleMetalWindow CreateSurface()
|
||||
{
|
||||
SimpleMetalWindow simpleMetalWindow;
|
||||
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
simpleMetalWindow = new SimpleMetalWindow(new NativeHandle(NsView), new NativeHandle(MetalLayer));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
return simpleMetalWindow;
|
||||
}
|
||||
}
|
||||
}
|
@ -111,6 +111,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMetalAvailable => OperatingSystem.IsMacOS();
|
||||
|
||||
public bool IsOpenGLAvailable => !OperatingSystem.IsMacOS();
|
||||
|
||||
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
||||
|
@ -43,6 +43,9 @@
|
||||
<ComboBoxItem IsEnabled="{Binding IsOpenGLAvailable}">
|
||||
<TextBlock Text="OpenGL" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem IsVisible="{Binding IsMetalAvailable}">
|
||||
<TextBlock Text="Metal" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" IsVisible="{Binding IsVulkanSelected}">
|
||||
|
Loading…
Reference in New Issue
Block a user