mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-08 18:48:51 +02:00
Snapdragon 8 Elite (& Adreno 8xx) Fixes
See merge request kenji-nx/ryujinx!20
This commit is contained in:
@@ -321,7 +321,7 @@ namespace LibKenjinx
|
||||
[UnmanagedCallersOnly(EntryPoint = "deviceReloadFilesystem")]
|
||||
public static void JnaReloadFileSystem()
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call: deviceReloadFilesystem");
|
||||
SwitchDevice?.ReloadFileSystem();
|
||||
}
|
||||
|
||||
@@ -423,21 +423,21 @@ namespace LibKenjinx
|
||||
[UnmanagedCallersOnly(EntryPoint = "deviceSignalEmulationClose")]
|
||||
public static void JniSignalEmulationCloseNative()
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call: deviceSignalEmulationClose");
|
||||
SignalEmulationClose();
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "deviceCloseEmulation")]
|
||||
public static void JniCloseEmulationNative()
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call: deviceCloseEmulation");
|
||||
CloseEmulation();
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "deviceReinitEmulation")]
|
||||
public static void JniReinitEmulationNative()
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call: deviceReinitEmulation");
|
||||
ReinitEmulation();
|
||||
}
|
||||
|
||||
@@ -923,6 +923,7 @@ namespace LibKenjinx
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "[JNI] deviceRecreateSwapchain");
|
||||
if (Renderer?.Window == null)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, "[JNI] deviceRecreateSwapchain: Renderer.Window == null");
|
||||
@@ -995,6 +996,7 @@ namespace LibKenjinx
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "[JNI] graphicsRendererRecreateSurface");
|
||||
_ = (Renderer as VulkanRenderer)?.RecreateSurface();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1003,6 +1005,15 @@ namespace LibKenjinx
|
||||
}
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
[UnmanagedCallersOnly(EntryPoint = "graphicsSetFullscreenStretch")]
|
||||
public static void JniGraphicsSetFullscreenStretch(bool enable)
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, $"[JNI] graphicsSetFullscreenStretch({enable})");
|
||||
ApplyFullscreenStretch(enable);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Used by MainActivity/GameHost
|
||||
[UnmanagedCallersOnly(EntryPoint = "reattachWindowIfReady")]
|
||||
public static bool JniReattachWindowIfReady()
|
||||
|
||||
@@ -212,12 +212,12 @@ namespace LibKenjinx
|
||||
_touchScreenManager?.Dispose();
|
||||
_touchScreenManager = null;
|
||||
|
||||
_gpuDoneEvent.WaitOne(3000);
|
||||
_gpuDoneEvent.Dispose();
|
||||
_gpuDoneEvent?.WaitOne(3000);
|
||||
_gpuDoneEvent?.Dispose();
|
||||
_gpuDoneEvent = null;
|
||||
|
||||
_gpuCancellationTokenSource.Cancel();
|
||||
_gpuCancellationTokenSource.Dispose();
|
||||
_gpuCancellationTokenSource?.Cancel();
|
||||
_gpuCancellationTokenSource?.Dispose();
|
||||
_gpuCancellationTokenSource = null;
|
||||
|
||||
SwitchDevice.Dispose();
|
||||
|
||||
@@ -13,24 +13,11 @@ using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if !ANDROID
|
||||
namespace LibKenjinx
|
||||
{
|
||||
public static partial class LibKenjinx
|
||||
{
|
||||
private unsafe static IntPtr CreateStringArray(List<string> strings)
|
||||
{
|
||||
uint size = (uint)(Marshal.SizeOf<IntPtr>() * (strings.Count + 1));
|
||||
var array = (char**)Marshal.AllocHGlobal((int)size);
|
||||
Unsafe.InitBlockUnaligned(array, 0, size);
|
||||
|
||||
for (int i = 0; i < strings.Count; i++)
|
||||
{
|
||||
array[i] = (char*)Marshal.StringToHGlobalAnsi(strings[i]);
|
||||
}
|
||||
|
||||
return (nint)array;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "device_initialize")]
|
||||
public static bool InitializeDeviceNative(MemoryManagerMode memoryManagerMode,
|
||||
bool useHypervisor,
|
||||
@@ -469,28 +456,6 @@ namespace LibKenjinx
|
||||
CloseUser(userId);
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// Stretch: Helper + Exports
|
||||
// ----------------------
|
||||
|
||||
// central logic (managed)
|
||||
private static void ApplyFullscreenStretch(bool enable)
|
||||
{
|
||||
var ar = enable ? AspectRatio.Stretched : AspectRatio.Fixed16x9;
|
||||
|
||||
// Retrieve, modify, write back struct
|
||||
var cfg = GraphicsConfiguration;
|
||||
cfg.AspectRatio = ar;
|
||||
GraphicsConfiguration = cfg;
|
||||
|
||||
// Hot-Apply for running emulation
|
||||
var dev = SwitchDevice?.EmulationContext;
|
||||
if (dev != null)
|
||||
{
|
||||
try { dev.Configuration.AspectRatio = ar; } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
// CamelCase Export (JNA calls it here)
|
||||
[UnmanagedCallersOnly(EntryPoint = "graphicsSetFullscreenStretch")]
|
||||
public static void GraphicsSetFullscreenStretchNativeAlias(bool enable)
|
||||
@@ -499,3 +464,4 @@ namespace LibKenjinx
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using Ryujinx.Common.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibKenjinx
|
||||
{
|
||||
public static partial class LibKenjinx
|
||||
{
|
||||
private unsafe static IntPtr CreateStringArray(List<string> strings)
|
||||
{
|
||||
uint size = (uint)(Marshal.SizeOf<IntPtr>() * (strings.Count + 1));
|
||||
var array = (char**)Marshal.AllocHGlobal((int)size);
|
||||
Unsafe.InitBlockUnaligned(array, 0, size);
|
||||
|
||||
for (int i = 0; i < strings.Count; i++)
|
||||
{
|
||||
array[i] = (char*)Marshal.StringToHGlobalAnsi(strings[i]);
|
||||
}
|
||||
|
||||
return (nint)array;
|
||||
}
|
||||
|
||||
private static void ApplyFullscreenStretch(bool enable)
|
||||
{
|
||||
var ar = enable ? AspectRatio.Stretched : AspectRatio.Fixed16x9;
|
||||
|
||||
var cfg = GraphicsConfiguration;
|
||||
cfg.AspectRatio = ar;
|
||||
GraphicsConfiguration = cfg;
|
||||
|
||||
var dev = SwitchDevice?.EmulationContext;
|
||||
if (dev != null)
|
||||
{
|
||||
try { dev.Configuration.AspectRatio = ar; } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,11 @@ namespace LibKenjinx
|
||||
|
||||
Logger.Notice.Print(LogClass.Application, "Initializing...");
|
||||
Logger.Notice.Print(LogClass.Application, $"Using base path: {AppDataManager.BaseDirPath}");
|
||||
#if ANDROID
|
||||
Logger.Notice.Print(LogClass.Application, "Build flags: ANDROID enabled");
|
||||
#else
|
||||
Logger.Warning?.Print(LogClass.Application, "Build flags: ANDROID disabled (unexpected for Android build)");
|
||||
#endif
|
||||
AndroidFileSystem = VirtualFileSystem.CreateInstance();
|
||||
SwitchDevice = new SwitchDevice(AndroidFileSystem);
|
||||
}
|
||||
@@ -751,6 +756,7 @@ namespace LibKenjinx
|
||||
|
||||
{
|
||||
private readonly SystemVersion _firmwareVersion;
|
||||
private int _contextDisposeState;
|
||||
public VirtualFileSystem VirtualFileSystem { get; set; }
|
||||
public ContentManager ContentManager { get; set; }
|
||||
public AccountManager AccountManager { get; set; }
|
||||
@@ -764,10 +770,17 @@ namespace LibKenjinx
|
||||
|
||||
public bool EnableFsIntegrityChecks { get; set; }
|
||||
|
||||
internal void DisposeContext()
|
||||
private void DisposeEmulationContext()
|
||||
{
|
||||
if (EmulationContext == null)
|
||||
if (System.Threading.Interlocked.Exchange(ref _contextDisposeState, 1) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (EmulationContext == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, "Disposing EmulationContext");
|
||||
|
||||
@@ -779,25 +792,21 @@ namespace LibKenjinx
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Error disposing EmulationContext: {ex.Message}");
|
||||
Logger.Error?.Print(LogClass.Application, $"Error disposing EmulationContext: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
internal void DisposeContext()
|
||||
{
|
||||
DisposeEmulationContext();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, "Disposing SwitchDevice");
|
||||
|
||||
try
|
||||
{
|
||||
EmulationContext?.Dispose();
|
||||
EmulationContext?.DisposeGpu();
|
||||
EmulationContext = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Error disposing EmulationContext: {ex.Message}");
|
||||
}
|
||||
DisposeEmulationContext();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
<LinkerFlavor Condition="'$(RuntimeIdentifier)'=='linux-bionic-arm64'">lld</LinkerFlavor>
|
||||
<DefineConstants>$(DefineConstants);FORCE_EXTERNAL_BASE_DIR</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(RuntimeIdentifier)'=='linux-bionic-arm64'">
|
||||
<DefineConstants>$(DefineConstants);ANDROID</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(RuntimeIdentifier)'=='linux-bionic-arm64'">
|
||||
<Compile Remove="LibKenjinx.Native.cs" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PublishAot>true</PublishAot>
|
||||
<PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack>
|
||||
|
||||
Reference in New Issue
Block a user