mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-11-11 02:12:44 -05:00
Compare commits
3 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f463ea1c5d | ||
|
|
1dd69912b1 | ||
|
|
1fbb0d8e7d |
@@ -8,7 +8,20 @@ namespace Ryujinx.Common
|
||||
{
|
||||
public static class TitleIDs
|
||||
{
|
||||
public static Optional<string> CurrentApplication;
|
||||
private static string _currentApplication;
|
||||
|
||||
public static Optional<string> CurrentApplication
|
||||
{
|
||||
get => _currentApplication;
|
||||
set
|
||||
{
|
||||
_currentApplication = value.OrElse(null);
|
||||
|
||||
CurrentApplicationChanged?.Invoke(_currentApplication);
|
||||
}
|
||||
}
|
||||
|
||||
public static event Action<Optional<string>> CurrentApplicationChanged;
|
||||
|
||||
public static GraphicsBackend SelectGraphicsBackend(string titleId, GraphicsBackend currentBackend)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,12 @@ namespace Ryujinx.Graphics.Gpu
|
||||
/// Enables or disables high-level emulation of common GPU Macro code.
|
||||
/// </summary>
|
||||
public static bool EnableMacroHLE = true;
|
||||
|
||||
/// <summary>
|
||||
/// Title id of the current running game.
|
||||
/// Used by the shader cache.
|
||||
/// </summary>
|
||||
public static string TitleId;
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the shader cache.
|
||||
|
||||
@@ -117,8 +117,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
/// </summary>
|
||||
private static string GetDiskCachePath()
|
||||
{
|
||||
return GraphicsConfig.EnableShaderCache && TitleIDs.CurrentApplication.HasValue
|
||||
? Path.Combine(AppDataManager.GamesDirPath, TitleIDs.CurrentApplication, "cache", "shader")
|
||||
return GraphicsConfig.EnableShaderCache && GraphicsConfig.TitleId != null
|
||||
? Path.Combine(AppDataManager.GamesDirPath, GraphicsConfig.TitleId, "cache", "shader")
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,15 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
private int _requestedWidth;
|
||||
private int _requestedHeight;
|
||||
|
||||
// private bool _vsyncEnabled;
|
||||
|
||||
private AntiAliasing _currentAntiAliasing;
|
||||
private bool _updateEffect;
|
||||
private IPostProcessingEffect _effect;
|
||||
private IScalingFilter _scalingFilter;
|
||||
private bool _isLinear;
|
||||
|
||||
public bool IsVSyncEnabled => _metalLayer.DisplaySyncEnabled;
|
||||
|
||||
// private float _scalingFilterLevel;
|
||||
private bool _updateScalingFilter;
|
||||
private ScalingFilter _currentScalingFilter;
|
||||
@@ -40,7 +42,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
_metalLayer = metalLayer;
|
||||
}
|
||||
|
||||
private unsafe void ResizeIfNeeded()
|
||||
private void ResizeIfNeeded()
|
||||
{
|
||||
if (_requestedWidth != 0 && _requestedHeight != 0)
|
||||
{
|
||||
@@ -54,7 +56,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
|
||||
public void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
|
||||
{
|
||||
if (_renderer.Pipeline is Pipeline pipeline && texture is Texture tex)
|
||||
{
|
||||
@@ -141,15 +143,7 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
public void ChangeVSyncMode(VSyncMode vSyncMode)
|
||||
{
|
||||
switch (vSyncMode)
|
||||
{
|
||||
case VSyncMode.Unbounded:
|
||||
_metalLayer.DisplaySyncEnabled = false;
|
||||
break;
|
||||
case VSyncMode.Switch:
|
||||
_metalLayer.DisplaySyncEnabled = true;
|
||||
break;
|
||||
}
|
||||
_metalLayer.DisplaySyncEnabled = vSyncMode is VSyncMode.Switch;
|
||||
}
|
||||
|
||||
public void SetAntiAliasing(AntiAliasing effect)
|
||||
|
||||
@@ -7,6 +7,7 @@ using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.HLE.Loaders.Executables;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
@@ -103,7 +104,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
}
|
||||
|
||||
// Initialize GPU.
|
||||
TitleIDs.CurrentApplication = programId.ToString("X16");
|
||||
GraphicsConfig.TitleId = programId.ToString("X16");
|
||||
device.Gpu.HostInitalized.Set();
|
||||
|
||||
if (!MemoryBlock.SupportsFlags(MemoryAllocationFlags.ViewCompatible))
|
||||
|
||||
@@ -8,6 +8,7 @@ using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.HLE.Loaders.Executables;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using System;
|
||||
@@ -60,6 +61,8 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
{
|
||||
_latestPid = processResult.ProcessId;
|
||||
|
||||
TitleIDs.CurrentApplication = processResult.ProgramIdText;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -87,6 +90,8 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
{
|
||||
_latestPid = processResult.ProcessId;
|
||||
|
||||
TitleIDs.CurrentApplication = processResult.ProgramIdText;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -114,6 +119,8 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
if (processResult.ProgramId > 0x01000000000007FF)
|
||||
{
|
||||
_latestPid = processResult.ProcessId;
|
||||
|
||||
TitleIDs.CurrentApplication = processResult.ProgramIdText;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -133,6 +140,8 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
{
|
||||
_latestPid = processResult.ProcessId;
|
||||
|
||||
TitleIDs.CurrentApplication = processResult.ProgramIdText;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -184,14 +193,17 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
if (nacpData.Value.PresenceGroupId != 0)
|
||||
{
|
||||
programId = nacpData.Value.PresenceGroupId;
|
||||
TitleIDs.CurrentApplication = programId.ToString("X16");
|
||||
}
|
||||
else if (nacpData.Value.SaveDataOwnerId != 0)
|
||||
{
|
||||
programId = nacpData.Value.SaveDataOwnerId;
|
||||
TitleIDs.CurrentApplication = programId.ToString("X16");
|
||||
}
|
||||
else if (nacpData.Value.AddOnContentBaseId != 0)
|
||||
{
|
||||
programId = nacpData.Value.AddOnContentBaseId - 0x1000;
|
||||
TitleIDs.CurrentApplication = programId.ToString("X16");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +217,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
}
|
||||
|
||||
// Explicitly null TitleId to disable the shader cache.
|
||||
TitleIDs.CurrentApplication = default;
|
||||
GraphicsConfig.TitleId = null;
|
||||
_device.Gpu.HostInitalized.Set();
|
||||
|
||||
ProcessResult processResult = ProcessLoaderHelper.LoadNsos(_device,
|
||||
|
||||
@@ -2,6 +2,7 @@ using LibHac.Common;
|
||||
using LibHac.Ns;
|
||||
using Ryujinx.Audio.Backends.CompatLayer;
|
||||
using Ryujinx.Audio.Integration;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
@@ -17,6 +18,8 @@ namespace Ryujinx.HLE
|
||||
{
|
||||
public class Switch : IDisposable
|
||||
{
|
||||
public static Switch Shared { get; private set; }
|
||||
|
||||
public HLEConfiguration Configuration { get; }
|
||||
public IHardwareDeviceDriver AudioDeviceDriver { get; }
|
||||
public MemoryBlock Memory { get; }
|
||||
@@ -77,6 +80,8 @@ namespace Ryujinx.HLE
|
||||
DirtyHacks = Configuration.Hacks;
|
||||
UpdateVSyncInterval();
|
||||
#pragma warning restore IDE0055
|
||||
|
||||
Shared = this;
|
||||
}
|
||||
|
||||
public void ProcessFrame()
|
||||
@@ -145,6 +150,9 @@ namespace Ryujinx.HLE
|
||||
AudioDeviceDriver.Dispose();
|
||||
FileSystem.Dispose();
|
||||
Memory.Dispose();
|
||||
|
||||
TitleIDs.CurrentApplication = null;
|
||||
Shared = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using DiscordRPC;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using Ryujinx.UI.App.Common;
|
||||
using Ryujinx.UI.Common.Configuration;
|
||||
@@ -44,6 +45,16 @@ namespace Ryujinx.UI.Common
|
||||
};
|
||||
|
||||
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
|
||||
TitleIDs.CurrentApplicationChanged += titleId =>
|
||||
{
|
||||
if (titleId)
|
||||
SwitchToPlayingState(
|
||||
ApplicationLibrary.LoadAndSaveMetaData(titleId),
|
||||
Switch.Shared.Processes.ActiveApplication
|
||||
);
|
||||
else
|
||||
SwitchToMainState();
|
||||
};
|
||||
}
|
||||
|
||||
private static void Update(object sender, ReactiveEventArgs<bool> evnt)
|
||||
@@ -69,7 +80,7 @@ namespace Ryujinx.UI.Common
|
||||
}
|
||||
}
|
||||
|
||||
public static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes)
|
||||
private static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes)
|
||||
{
|
||||
_discordClient?.SetPresence(new RichPresence
|
||||
{
|
||||
@@ -88,7 +99,7 @@ namespace Ryujinx.UI.Common
|
||||
});
|
||||
}
|
||||
|
||||
public static void SwitchToMainState() => _discordClient?.SetPresence(_discordPresenceMain);
|
||||
private static void SwitchToMainState() => _discordClient?.SetPresence(_discordPresenceMain);
|
||||
|
||||
private static string TruncateToByteLength(string input)
|
||||
{
|
||||
|
||||
@@ -578,7 +578,6 @@ namespace Ryujinx.Ava
|
||||
public void Stop()
|
||||
{
|
||||
_isActive = false;
|
||||
DiscordIntegrationModule.SwitchToMainState();
|
||||
}
|
||||
|
||||
private void Exit()
|
||||
@@ -862,13 +861,11 @@ namespace Ryujinx.Ava
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText,
|
||||
|
||||
ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText,
|
||||
appMetadata => appMetadata.UpdatePreGame()
|
||||
);
|
||||
|
||||
DiscordIntegrationModule.SwitchToPlayingState(appMeta, Device.Processes.ActiveApplication);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user