rebase with upstream

This commit is contained in:
Emmanuel Hansen 2023-11-11 20:06:56 +00:00
parent 038ee1a6dd
commit e5d54d5374
25 changed files with 68 additions and 84 deletions

View File

@ -14,7 +14,7 @@ namespace ARMeilleure.CodeGen.Arm64
return;
}
if (OperatingSystem.IsLinux() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (OperatingSystem.IsLinux())
{
LinuxFeatureInfoHwCap = (LinuxFeatureFlagsHwCap)getauxval(AT_HWCAP);
LinuxFeatureInfoHwCap2 = (LinuxFeatureFlagsHwCap2)getauxval(AT_HWCAP2);

View File

@ -111,7 +111,7 @@ namespace ARMeilleure.Signal
return context.BitwiseAnd(err, Const(2ul));
}
}
else if (OperatingSystem.IsLinux() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux())
{
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{

View File

@ -413,11 +413,6 @@ namespace ARMeilleure.Translation.PTC
finally
{
ResetCarriersIfNeeded();
if (!OperatingSystem.IsAndroid())
{
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
}
}
_waitEvent.Set();
@ -793,11 +788,6 @@ namespace ARMeilleure.Translation.PTC
{
ResetCarriersIfNeeded();
if (!OperatingSystem.IsAndroid())
{
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
}
return;
}
@ -1010,7 +1000,7 @@ namespace ARMeilleure.Translation.PTC
osPlatform |= (OperatingSystem.IsLinux() ? 1u : 0u) << 1;
osPlatform |= (OperatingSystem.IsMacOS() ? 1u : 0u) << 2;
osPlatform |= (OperatingSystem.IsWindows() ? 1u : 0u) << 3;
osPlatform |= (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid() ? 1u : 0u) << 4;
osPlatform |= (Ryujinx.Common.PlatformInfo.IsBionic ? 1u : 0u) << 4;
#pragma warning restore IDE0055
return osPlatform;

View File

@ -7,10 +7,10 @@ using LibRyujinx.Shared.Audio.Oboe;
using Microsoft.Win32.SafeHandles;
using Rxmxnx.PInvoke;
using Ryujinx.Audio.Backends.OpenAL;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Logging.Targets;
using Ryujinx.Common.SystemInfo;
using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.Input;
using Silk.NET.Core.Loader;
@ -87,7 +87,7 @@ namespace LibRyujinx
public static JBoolean JniInitialize(JEnvRef jEnv, JObjectLocalRef jObj, JLong jpathId, JBoolean enableDebugLogs)
{
Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
SystemInfo.IsBionic = true;
PlatformInfo.IsBionic = true;
Logger.AddTarget(
new AsyncLogTargetWrapper(

View File

@ -9,8 +9,8 @@ namespace LibRyujinx.Jni.Pointers
{
public readonly struct JBooleanRef
{
private const Int32 JBooleanResultFalse = 0;
private const Int32 JBooleanResultTrue = 1;
private static readonly Int32 JBooleanResultFalse = 0;
private static readonly Int32 JBooleanResultTrue = 1;
#pragma warning disable IDE0052
private readonly IntPtr _value;
@ -20,6 +20,11 @@ namespace LibRyujinx.Jni.Pointers
=> this._value = jBoolean.HasValue ? GetJBooleanRef(jBoolean.Value) : IntPtr.Zero;
private static IntPtr GetJBooleanRef(Boolean value)
=> value ? Unsafe.AsRef(JBooleanResultTrue).GetUnsafeIntPtr() : Unsafe.AsRef(JBooleanResultFalse).GetUnsafeIntPtr();
{
// Probably gonna break stuff
var t = JBooleanResultTrue;
var f = JBooleanResultFalse;
return value ? Unsafe.AsRef(ref f).GetUnsafeIntPtr() : Unsafe.AsRef(ref t).GetUnsafeIntPtr();
}
}
}

View File

@ -24,7 +24,7 @@ namespace LibRyujinx.Jni.Values
public Boolean IsDefault => isDefault(this);
public static JValue Create(ReadOnlySpan<Byte> source)
public static JValue Create(in ReadOnlySpan<Byte> source)
{
Byte[] result = new Byte[Size];
for (Int32 i = 0; i < source.Length; i++)
@ -38,7 +38,10 @@ namespace LibRyujinx.Jni.Values
=> (jValue._value1 + jValue._value2 + jValue._value3) == default
&& jValue._value4 == default;
private static Boolean DefaultLong(in JValue jValue) =>
Unsafe.AsRef(jValue).Transform<JValue, Int64>() == default;
private static Boolean DefaultLong(in JValue jValue)
{
var jv = jValue;
return Unsafe.AsRef(ref jv).Transform<JValue, Int64>() == default;
}
}
}

View File

@ -37,7 +37,7 @@ namespace LibRyujinx
[UnmanagedCallersOnly(EntryPoint = "graphics_initialize")]
public static bool InitializeGraphicsNative(GraphicsConfiguration graphicsConfiguration)
{
if(Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if(Ryujinx.Common.PlatformInfo.IsBionic)
{
Silk.NET.Core.Loader.SearchPathContainer.Platform = Silk.NET.Core.Loader.UnderlyingPlatform.Android;
}
@ -179,7 +179,7 @@ namespace LibRyujinx
debug_break(1);
if (Ryujinx.Common.SystemInfo.SystemInfo.IsBionic)
if (Ryujinx.Common.PlatformInfo.IsBionic)
{
setRenderingThread();
}

View File

@ -8,12 +8,14 @@
</PropertyGroup>
<PropertyGroup>
<PublishAot>true</PublishAot>
<NativeLib>Shared</NativeLib>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OptimizationPreference>Speed</OptimizationPreference>
<Optimize>true</Optimize>
<OptimizationPreference>Speed</OptimizationPreference>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />

View File

@ -126,7 +126,7 @@ namespace Ryujinx.Common.Logging
_time = Stopwatch.StartNew();
if (!Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (!Ryujinx.Common.PlatformInfo.IsBionic)
{
// Logger should log to console by default
AddTarget(new AsyncLogTargetWrapper(

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ryujinx.Common
{
public static class PlatformInfo
{
public static bool IsBionic { get; set; }
}
}

View File

@ -35,7 +35,7 @@ namespace Ryujinx.Common
return BuildVersion;
}
if (SystemInfo.SystemInfo.IsBionic)
if (PlatformInfo.IsBionic)
{
return "Android_1.0";
}
@ -59,7 +59,7 @@ namespace Ryujinx.Common
#else
public static string GetBaseApplicationDirectory()
{
if (IsFlatHubBuild() || OperatingSystem.IsMacOS() || SystemInfo.SystemInfo.IsBionic)
if (IsFlatHubBuild() || OperatingSystem.IsMacOS() || PlatformInfo.IsBionic)
{
return AppDataManager.BaseDirPath;
}

View File

@ -126,11 +126,6 @@ namespace Ryujinx.Cpu.Jit
}
}
/// <inheritdoc/>
public void Reprotect(ulong va, ulong size, MemoryPermission permission)
{
}
/// <inheritdoc/>
public T Read<T>(ulong va) where T : unmanaged
{

View File

@ -194,11 +194,6 @@ namespace Ryujinx.Cpu.Jit
}
}
/// <inheritdoc/>
public void Reprotect(ulong va, ulong size, MemoryPermission permission)
{
}
/// <inheritdoc/>
public T Read<T>(ulong va) where T : unmanaged
{

View File

@ -11,7 +11,7 @@ namespace Ryujinx.Cpu.Nce
public static IntPtr GetCurrentThreadHandle()
{
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsBionic)
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
return NceThreadPalUnix.GetCurrentThreadHandle();
}
@ -23,7 +23,7 @@ namespace Ryujinx.Cpu.Nce
public static void SuspendThread(IntPtr handle)
{
if (Ryujinx.Common.SystemInfo.SystemInfo.IsBionic)
if (Ryujinx.Common.PlatformInfo.IsBionic)
{
NceThreadPalAndroid.SuspendThread(handle);
}

View File

@ -88,11 +88,11 @@ namespace Ryujinx.Cpu.Signal
ref SignalHandlerConfig config = ref GetConfigRef();
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || PlatformInfo.IsBionic)
{
_signalHandlerPtr = MapCode(NativeSignalHandlerGenerator.GenerateUnixSignalHandler(_handlerConfig, rangeStructSize, pageSize));
if (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (PlatformInfo.IsBionic)
{
config.StructAddressOffset = 16; // si_addr
config.StructWriteOffset = 8; // si_code

View File

@ -68,7 +68,7 @@ namespace Ryujinx.Cpu.Signal
int result;
SigAction old;
if (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (Ryujinx.Common.PlatformInfo.IsBionic)
{
result = sigaction(SIGSEGV, IntPtr.Zero, out SigActionBionic tmp);
@ -98,7 +98,7 @@ namespace Ryujinx.Cpu.Signal
int result;
SigAction old;
if (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (Ryujinx.Common.PlatformInfo.IsBionic)
{
SigActionBionic sig = new()
{
@ -185,7 +185,7 @@ namespace Ryujinx.Cpu.Signal
{
int result;
if (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (Ryujinx.Common.PlatformInfo.IsBionic)
{
SigActionBionic sig = new()
{
@ -233,7 +233,7 @@ namespace Ryujinx.Cpu.Signal
public static bool RestoreExceptionHandler(SigAction oldAction)
{
if (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (Ryujinx.Common.PlatformInfo.IsBionic)
{
SigActionBionic tmp = new SigActionBionic
{

View File

@ -142,7 +142,7 @@ namespace Ryujinx.Graphics.Vulkan
ImageFormat = surfaceFormat.Format,
ImageColorSpace = surfaceFormat.ColorSpace,
ImageExtent = extent,
ImageUsage = ImageUsageFlags.ColorAttachmentBit | ImageUsageFlags.TransferDstBit | (Ryujinx.Common.SystemInfo.SystemInfo.IsBionic ? 0 : ImageUsageFlags.StorageBit),
ImageUsage = ImageUsageFlags.ColorAttachmentBit | ImageUsageFlags.TransferDstBit | (Ryujinx.Common.PlatformInfo.IsBionic ? 0 : ImageUsageFlags.StorageBit),
ImageSharingMode = SharingMode.Exclusive,
ImageArrayLayers = 1,
PreTransform = capabilities.CurrentTransform,

View File

@ -25,7 +25,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
IsAnyInternetRequestAccepted = true, // NOTE: Why not accept any internet request?
};
if (!Ryujinx.Common.SystemInfo.SystemInfo.IsBionic)
if (!Ryujinx.Common.PlatformInfo.IsBionic)
{
NetworkChange.NetworkAddressChanged += LocalInterfaceCacheHandler;
}
@ -199,7 +199,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
if (isDisposing)
{
if (!Ryujinx.Common.SystemInfo.SystemInfo.IsBionic)
if (!Ryujinx.Common.PlatformInfo.IsBionic)
{
NetworkChange.NetworkAddressChanged -= LocalInterfaceCacheHandler;
}

View File

@ -96,11 +96,6 @@ namespace Ryujinx.Memory
}
}
/// <inheritdoc/>
public void Reprotect(ulong va, ulong size, MemoryPermission permission)
{
}
/// <inheritdoc/>
public T Read<T>(ulong va) where T : unmanaged
{

View File

@ -44,14 +44,6 @@ namespace Ryujinx.Memory
/// <param name="size">Size of the range to be unmapped</param>
void Unmap(ulong va, ulong size);
/// <summary>
/// Reprotects a previously mapped range of virtual memory.
/// </summary>
/// <param name="va">Virtual address of the range to be reprotected</param>
/// <param name="size">Size of the range to be reprotected</param>
/// <param name="permission">New protection of the memory range</param>
void Reprotect(ulong va, ulong size, MemoryPermission permission);
/// <summary>
/// Reads data from CPU mapped memory.
/// </summary>

View File

@ -426,7 +426,7 @@ namespace Ryujinx.Memory
return OperatingSystem.IsWindowsVersionAtLeast(10, 0, 17134);
}
return OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid();
return OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic;
}
return true;

View File

@ -10,7 +10,7 @@ namespace Ryujinx.Memory
{
return MemoryManagementWindows.Allocate((IntPtr)size);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
return MemoryManagementUnix.Allocate(size, forJit);
}
@ -26,7 +26,7 @@ namespace Ryujinx.Memory
{
return MemoryManagementWindows.Reserve((IntPtr)size, viewCompatible);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
return MemoryManagementUnix.Reserve(size, forJit);
}
@ -42,7 +42,7 @@ namespace Ryujinx.Memory
{
MemoryManagementWindows.Commit(address, (IntPtr)size);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
MemoryManagementUnix.Commit(address, size, forJit);
}
@ -58,7 +58,7 @@ namespace Ryujinx.Memory
{
MemoryManagementWindows.Decommit(address, (IntPtr)size);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
MemoryManagementUnix.Decommit(address, size);
}
@ -74,7 +74,7 @@ namespace Ryujinx.Memory
{
MemoryManagementWindows.MapView(sharedMemory, srcOffset, address, (IntPtr)size, owner);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
MemoryManagementUnix.MapView(sharedMemory, srcOffset, address, size);
}
@ -90,7 +90,7 @@ namespace Ryujinx.Memory
{
MemoryManagementWindows.UnmapView(sharedMemory, address, (IntPtr)size, owner);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
MemoryManagementUnix.UnmapView(address, size);
}
@ -108,7 +108,7 @@ namespace Ryujinx.Memory
{
result = MemoryManagementWindows.Reprotect(address, (IntPtr)size, permission, forView);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
result = MemoryManagementUnix.Reprotect(address, size, permission);
}
@ -129,7 +129,7 @@ namespace Ryujinx.Memory
{
return MemoryManagementWindows.Free(address, (IntPtr)size);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
return MemoryManagementUnix.Free(address);
}
@ -145,7 +145,7 @@ namespace Ryujinx.Memory
{
return MemoryManagementWindows.CreateSharedMemory((IntPtr)size, reserve);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
return MemoryManagementUnix.CreateSharedMemory(size, reserve);
}
@ -161,7 +161,7 @@ namespace Ryujinx.Memory
{
MemoryManagementWindows.DestroySharedMemory(handle);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
MemoryManagementUnix.DestroySharedMemory(handle);
}
@ -177,7 +177,7 @@ namespace Ryujinx.Memory
{
return MemoryManagementWindows.MapSharedMemory(handle);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
return MemoryManagementUnix.MapSharedMemory(handle, size);
}
@ -193,7 +193,7 @@ namespace Ryujinx.Memory
{
MemoryManagementWindows.UnmapSharedMemory(address);
}
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS() || Ryujinx.Common.PlatformInfo.IsBionic)
{
MemoryManagementUnix.UnmapSharedMemory(address, size);
}

View File

@ -159,7 +159,7 @@ namespace Ryujinx.Memory
}
}
}
else if (Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
else if (Ryujinx.Common.PlatformInfo.IsBionic)
{
byte[] memName = "Ryujinx-XXXXXX"u8.ToArray();

View File

@ -113,7 +113,7 @@ namespace Ryujinx.Memory
if (flags.HasFlag(MmapFlags.MAP_ANONYMOUS))
{
if (OperatingSystem.IsLinux() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (OperatingSystem.IsLinux() || Ryujinx.Common.PlatformInfo.IsBionic)
{
result |= MAP_ANONYMOUS_LINUX_GENERIC;
}
@ -129,7 +129,7 @@ namespace Ryujinx.Memory
if (flags.HasFlag(MmapFlags.MAP_NORESERVE))
{
if (OperatingSystem.IsLinux() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (OperatingSystem.IsLinux() || Ryujinx.Common.PlatformInfo.IsBionic)
{
result |= MAP_NORESERVE_LINUX_GENERIC;
}
@ -145,7 +145,7 @@ namespace Ryujinx.Memory
if (flags.HasFlag(MmapFlags.MAP_UNLOCKED))
{
if (OperatingSystem.IsLinux() || Ryujinx.Common.SystemInfo.SystemInfo.IsAndroid())
if (OperatingSystem.IsLinux() || Ryujinx.Common.PlatformInfo.IsBionic)
{
result |= MAP_UNLOCKED_LINUX_GENERIC;
}

View File

@ -9,7 +9,6 @@ namespace Ryujinx.Ui.Common.SystemInfo
{
public class SystemInfo
{
public static bool IsBionic { get; set; }
public string OsDescription { get; protected set; }
public string CpuName { get; protected set; }
public ulong RamTotal { get; protected set; }
@ -76,10 +75,5 @@ namespace Ryujinx.Ui.Common.SystemInfo
return string.IsNullOrEmpty(name) ? null : name;
}
public static bool IsAndroid()
{
return OperatingSystem.IsAndroid() || IsBionic;
}
}
}