mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-11 18:38:53 +02:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0042df343 | ||
|
|
4b6330374c | ||
|
|
7e209bfe8f | ||
|
|
a5c54d324d | ||
|
|
766b86ff8b | ||
|
|
9494a59d51 | ||
|
|
9b0db4d4a8 | ||
|
|
a289a05055 | ||
|
|
473b92136c | ||
|
|
fc4c45ef1d | ||
|
|
52c6a1890e | ||
|
|
2288084b53 | ||
|
|
dd519a32b6 | ||
|
|
7be8829b0a | ||
|
|
6225e142fc | ||
|
|
9e3c03a606 | ||
|
|
8e9bcb2a8e | ||
|
|
7101f52c01 | ||
|
|
e80fc00462 | ||
|
|
33cbd29c23 | ||
|
|
cfc7c6039f | ||
|
|
ac6db0fe76 |
@@ -8,14 +8,14 @@
|
|||||||
<PackageVersion Include="Avalonia.Desktop" Version="12.1.1" />
|
<PackageVersion Include="Avalonia.Desktop" Version="12.1.1" />
|
||||||
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3" />
|
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3" />
|
||||||
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="12.1.1" />
|
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="12.1.1" />
|
||||||
<PackageVersion Include="Svg.Controls.Avalonia" Version="12.0.0.13" />
|
<PackageVersion Include="Svg.Controls.Avalonia" Version="12.0.0.15" />
|
||||||
<PackageVersion Include="Svg.Controls.Skia.Avalonia" Version="12.0.0.13" />
|
<PackageVersion Include="Svg.Controls.Skia.Avalonia" Version="12.0.0.15" />
|
||||||
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
||||||
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||||
<PackageVersion Include="Concentus" Version="2.2.2" />
|
<PackageVersion Include="Concentus" Version="2.2.2" />
|
||||||
<PackageVersion Include="DiscordRichPresence" Version="1.6.1.70" />
|
<PackageVersion Include="DiscordRichPresence" Version="1.6.1.70" />
|
||||||
<PackageVersion Include="DynamicData" Version="9.4.33" />
|
<PackageVersion Include="DynamicData" Version="9.4.33" />
|
||||||
<PackageVersion Include="FluentAvaloniaUI" Version="3.0.2" />
|
<PackageVersion Include="FluentAvaloniaUI" Version="3.1.0" />
|
||||||
<PackageVersion Include="Gommon" Version="2.8.1.2" />
|
<PackageVersion Include="Gommon" Version="2.8.1.2" />
|
||||||
<PackageVersion Include="Humanizer" Version="3.0.10" />
|
<PackageVersion Include="Humanizer" Version="3.0.10" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<PackageVersion Include="SkiaSharp" Version="3.119.4" />
|
<PackageVersion Include="SkiaSharp" Version="3.119.4" />
|
||||||
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4" />
|
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4" />
|
||||||
<PackageVersion Include="SPB" Version="0.0.4-build32" />
|
<PackageVersion Include="SPB" Version="0.0.4-build32" />
|
||||||
<PackageVersion Include="System.IO.Hashing" Version="10.0.10" />
|
<PackageVersion Include="System.IO.Hashing" Version="10.0.11" />
|
||||||
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.1.0" />
|
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -32,14 +32,11 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
||||||
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
||||||
|
|
||||||
private const uint InternalVersion = 7020; //! To be incremented manually for each change to the ARMeilleure project.
|
private const uint InternalVersion = 7031; //! To be incremented manually for each change to the ARMeilleure project.
|
||||||
|
|
||||||
private const string ActualDir = "0";
|
private const string ActualDir = "0";
|
||||||
private const string BackupDir = "1";
|
private const string BackupDir = "1";
|
||||||
|
|
||||||
private const string TitleIdTextDefault = "0000000000000000";
|
|
||||||
private const string DisplayVersionDefault = "0";
|
|
||||||
|
|
||||||
public static readonly Symbol PageTableSymbol = new(SymbolType.Special, 1);
|
public static readonly Symbol PageTableSymbol = new(SymbolType.Special, 1);
|
||||||
public static readonly Symbol CountTableSymbol = new(SymbolType.Special, 2);
|
public static readonly Symbol CountTableSymbol = new(SymbolType.Special, 2);
|
||||||
public static readonly Symbol DispatchStubSymbol = new(SymbolType.Special, 3);
|
public static readonly Symbol DispatchStubSymbol = new(SymbolType.Special, 3);
|
||||||
@@ -67,8 +64,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public string TitleIdText { get; private set; }
|
public PtcCacheInfo CacheInfo { get; private set; }
|
||||||
public string DisplayVersion { get; private set; }
|
|
||||||
|
|
||||||
private MemoryManagerType _memoryMode;
|
private MemoryManagerType _memoryMode;
|
||||||
|
|
||||||
@@ -97,8 +93,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
|
|
||||||
_disposed = false;
|
_disposed = false;
|
||||||
|
|
||||||
TitleIdText = TitleIdTextDefault;
|
CacheInfo = new PtcCacheInfo(0, null, null, 0, null, "Unknown", "default");
|
||||||
DisplayVersion = DisplayVersionDefault;
|
|
||||||
|
|
||||||
CachePathActual = string.Empty;
|
CachePathActual = string.Empty;
|
||||||
CachePathBackup = string.Empty;
|
CachePathBackup = string.Empty;
|
||||||
@@ -106,20 +101,24 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
Disable();
|
Disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(string titleIdText, string displayVersion, bool enabled, MemoryManagerType memoryMode, string cacheSelector)
|
public void Initialize(PtcCacheInfo cacheInfo, bool enabled, MemoryManagerType memoryMode)
|
||||||
{
|
{
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
Profiler.Wait();
|
Profiler.Wait();
|
||||||
Profiler.ClearEntries();
|
Profiler.ClearEntries();
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Ptc, $"Initializing Profiled Persistent Translation Cache v{InternalVersion}\n\t\t (title: {titleIdText}, version: '{displayVersion}', selector: '{cacheSelector}', enabled: {enabled}).");
|
CacheInfo = cacheInfo;
|
||||||
|
|
||||||
if (!enabled || string.IsNullOrEmpty(titleIdText) || titleIdText == TitleIdTextDefault)
|
Logger.Info?.Print(
|
||||||
|
LogClass.Ptc,
|
||||||
|
$"Initializing Profiled Persistent Translation Cache v{InternalVersion}\n\t\t " +
|
||||||
|
$"(pid: {cacheInfo.ProcessId}, title: {cacheInfo.TitleIdText}, application: {cacheInfo.ApplicationIdText}, " +
|
||||||
|
$"programIndex: {cacheInfo.ProgramIndex}, version: '{cacheInfo.DisplayVersion}', kind: {cacheInfo.ProcessKind}, " +
|
||||||
|
$"selector: '{cacheInfo.CacheSelector}', key: '{cacheInfo.CacheKey}', enabled: {enabled}).");
|
||||||
|
|
||||||
|
if (!enabled || cacheInfo.TitleIdText == PtcCacheInfo.TitleIdTextDefault)
|
||||||
{
|
{
|
||||||
TitleIdText = TitleIdTextDefault;
|
|
||||||
DisplayVersion = DisplayVersionDefault;
|
|
||||||
|
|
||||||
CachePathActual = string.Empty;
|
CachePathActual = string.Empty;
|
||||||
CachePathBackup = string.Empty;
|
CachePathBackup = string.Empty;
|
||||||
|
|
||||||
@@ -128,12 +127,10 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleIdText = titleIdText;
|
|
||||||
DisplayVersion = !string.IsNullOrEmpty(displayVersion) ? displayVersion : DisplayVersionDefault;
|
|
||||||
_memoryMode = memoryMode;
|
_memoryMode = memoryMode;
|
||||||
|
|
||||||
string workPathActual = Path.Combine(AppDataManager.GamesDirPath, TitleIdText, "cache", "cpu", ActualDir);
|
string workPathActual = Path.Combine(AppDataManager.GamesDirPath, CacheInfo.TitleIdText, "cache", "cpu", ActualDir);
|
||||||
string workPathBackup = Path.Combine(AppDataManager.GamesDirPath, TitleIdText, "cache", "cpu", BackupDir);
|
string workPathBackup = Path.Combine(AppDataManager.GamesDirPath, CacheInfo.TitleIdText, "cache", "cpu", BackupDir);
|
||||||
|
|
||||||
if (!Directory.Exists(workPathActual))
|
if (!Directory.Exists(workPathActual))
|
||||||
{
|
{
|
||||||
@@ -145,8 +142,14 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
Directory.CreateDirectory(workPathBackup);
|
Directory.CreateDirectory(workPathBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
CachePathActual = Path.Combine(workPathActual, DisplayVersion) + "-" + cacheSelector;
|
CachePathActual = Path.Combine(workPathActual, CacheInfo.DisplayVersion) + "-" + CacheInfo.CacheSelector;
|
||||||
CachePathBackup = Path.Combine(workPathBackup, DisplayVersion) + "-" + cacheSelector;
|
CachePathBackup = Path.Combine(workPathBackup, CacheInfo.DisplayVersion) + "-" + CacheInfo.CacheSelector;
|
||||||
|
|
||||||
|
Logger.Info?.Print(
|
||||||
|
LogClass.Ptc,
|
||||||
|
$"PPTC cache owner selected (pid: {CacheInfo.ProcessId}, title: {CacheInfo.TitleIdText}, application: {CacheInfo.ApplicationIdText}, " +
|
||||||
|
$"version: '{CacheInfo.DisplayVersion}', kind: {CacheInfo.ProcessKind}, selector: '{CacheInfo.CacheSelector}', " +
|
||||||
|
$"key: '{CacheInfo.CacheKey}', path: '{CachePathActual}').");
|
||||||
|
|
||||||
PreLoad();
|
PreLoad();
|
||||||
Profiler.PreLoad();
|
Profiler.PreLoad();
|
||||||
@@ -370,7 +373,12 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
|
|
||||||
long fileSize = new FileInfo(fileName).Length;
|
long fileSize = new FileInfo(fileName).Length;
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Ptc, $"{(isBackup ? "Loaded Backup Translation Cache" : "Loaded Translation Cache")} (size: {fileSize} bytes, translated functions: {GetEntriesCount()}).");
|
Logger.Info?.Print(
|
||||||
|
LogClass.Ptc,
|
||||||
|
$"{(isBackup ? "Loaded Backup Translation Cache" : "Loaded Translation Cache")} " +
|
||||||
|
$"(pid: {CacheInfo.ProcessId}, title: {CacheInfo.TitleIdText}, version: '{CacheInfo.DisplayVersion}', kind: {CacheInfo.ProcessKind}, " +
|
||||||
|
$"selector: '{CacheInfo.CacheSelector}', key: '{CacheInfo.CacheKey}', path: '{fileName}', " +
|
||||||
|
$"size: {fileSize} bytes, translated functions: {GetEntriesCount()}).");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
namespace ARMeilleure.Translation.PTC
|
||||||
|
{
|
||||||
|
public readonly struct PtcCacheInfo
|
||||||
|
{
|
||||||
|
public const string TitleIdTextDefault = "0000000000000000";
|
||||||
|
public const string ApplicationIdTextDefault = "0000000000000000";
|
||||||
|
public const string DisplayVersionDefault = "0";
|
||||||
|
|
||||||
|
public ulong ProcessId { get; }
|
||||||
|
public string TitleIdText { get; }
|
||||||
|
public string ApplicationIdText { get; }
|
||||||
|
public byte ProgramIndex { get; }
|
||||||
|
public string DisplayVersion { get; }
|
||||||
|
public string ProcessKind { get; }
|
||||||
|
public string CacheSelector { get; }
|
||||||
|
|
||||||
|
public string CacheKey => $"{DisplayVersion}-{CacheSelector}";
|
||||||
|
|
||||||
|
public PtcCacheInfo(
|
||||||
|
ulong processId,
|
||||||
|
string titleIdText,
|
||||||
|
string applicationIdText,
|
||||||
|
byte programIndex,
|
||||||
|
string displayVersion,
|
||||||
|
string processKind,
|
||||||
|
string cacheSelector)
|
||||||
|
{
|
||||||
|
ProcessId = processId;
|
||||||
|
TitleIdText = !string.IsNullOrEmpty(titleIdText) ? titleIdText : TitleIdTextDefault;
|
||||||
|
ApplicationIdText = !string.IsNullOrEmpty(applicationIdText) ? applicationIdText : ApplicationIdTextDefault;
|
||||||
|
ProgramIndex = programIndex;
|
||||||
|
DisplayVersion = !string.IsNullOrEmpty(displayVersion) ? displayVersion : DisplayVersionDefault;
|
||||||
|
ProcessKind = processKind ?? string.Empty;
|
||||||
|
CacheSelector = string.IsNullOrEmpty(cacheSelector) ? "default" : cacheSelector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
{
|
{
|
||||||
private const string OuterHeaderMagicString = "Pohd\0\0\0\0";
|
private const string OuterHeaderMagicString = "Pohd\0\0\0\0";
|
||||||
|
|
||||||
private const uint InternalVersion = 6698; //! Not to be incremented manually for each change to the ARMeilleure project.
|
private const uint InternalVersion = 7031; //! Not to be incremented manually for each change to the ARMeilleure project.
|
||||||
|
|
||||||
private static readonly uint[] _migrateInternalVersions =
|
private static readonly uint[] _migrateInternalVersions =
|
||||||
[
|
[
|
||||||
@@ -254,7 +254,12 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
|
|
||||||
long fileSize = new FileInfo(fileName).Length;
|
long fileSize = new FileInfo(fileName).Length;
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Ptc, $"{(isBackup ? "Loaded Backup Profiling Info" : "Loaded Profiling Info")} (size: {fileSize} bytes, profiled functions: {ProfiledFuncs.Count}).");
|
Logger.Info?.Print(
|
||||||
|
LogClass.Ptc,
|
||||||
|
$"{(isBackup ? "Loaded Backup Profiling Info" : "Loaded Profiling Info")} " +
|
||||||
|
$"(pid: {_ptc.CacheInfo.ProcessId}, title: {_ptc.CacheInfo.TitleIdText}, version: '{_ptc.CacheInfo.DisplayVersion}', " +
|
||||||
|
$"kind: {_ptc.CacheInfo.ProcessKind}, selector: '{_ptc.CacheInfo.CacheSelector}', key: '{_ptc.CacheInfo.CacheKey}', " +
|
||||||
|
$"path: '{fileName}', size: {fileSize} bytes, profiled functions: {ProfiledFuncs.Count}).");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -375,7 +380,11 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
|
|
||||||
if (fileSize != 0L)
|
if (fileSize != 0L)
|
||||||
{
|
{
|
||||||
Logger.Info?.Print(LogClass.Ptc, $"Saved Profiling Info (size: {fileSize} bytes, profiled functions: {profiledFuncsCount}).");
|
Logger.Info?.Print(
|
||||||
|
LogClass.Ptc,
|
||||||
|
$"Saved Profiling Info (pid: {_ptc.CacheInfo.ProcessId}, title: {_ptc.CacheInfo.TitleIdText}, version: '{_ptc.CacheInfo.DisplayVersion}', " +
|
||||||
|
$"kind: {_ptc.CacheInfo.ProcessKind}, selector: '{_ptc.CacheInfo.CacheSelector}', key: '{_ptc.CacheInfo.CacheKey}', " +
|
||||||
|
$"path: '{fileName}', size: {fileSize} bytes, profiled functions: {profiledFuncsCount}).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ namespace ARMeilleure.Translation
|
|||||||
FunctionTable.Fill = (ulong)Stubs.SlowDispatchStub;
|
FunctionTable.Fill = (ulong)Stubs.SlowDispatchStub;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPtcLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled, string cacheSelector)
|
public IPtcLoadState LoadDiskCache(PtcCacheInfo cacheInfo, bool enabled)
|
||||||
{
|
{
|
||||||
_ptc.Initialize(titleIdText, displayVersion, enabled, Memory.Type, cacheSelector);
|
_ptc.Initialize(cacheInfo, enabled, Memory.Type);
|
||||||
return _ptc;
|
return _ptc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
|
using ARMeilleure.Translation.PTC;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Cpu.AppleHv
|
namespace Ryujinx.Cpu.AppleHv
|
||||||
@@ -32,7 +33,7 @@ namespace Ryujinx.Cpu.AppleHv
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled, string cacheSelector)
|
public IDiskCacheLoadState LoadDiskCache(PtcCacheInfo cacheInfo, bool enabled)
|
||||||
{
|
{
|
||||||
return new DummyDiskCacheLoadState();
|
return new DummyDiskCacheLoadState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using ARMeilleure.Translation.PTC;
|
||||||
|
|
||||||
namespace Ryujinx.Cpu
|
namespace Ryujinx.Cpu
|
||||||
{
|
{
|
||||||
@@ -44,11 +45,10 @@ namespace Ryujinx.Cpu
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If the execution engine is recompiling guest code, this can be used to load cached code from disk.
|
/// If the execution engine is recompiling guest code, this can be used to load cached code from disk.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="titleIdText">Title ID of the application in padded hex form</param>
|
/// <param name="cacheInfo">Identity and selector for the process-owned disk cache</param>
|
||||||
/// <param name="displayVersion">Version of the application</param>
|
|
||||||
/// <param name="enabled">True if the cache should be loaded from disk if it exists, false otherwise</param>
|
/// <param name="enabled">True if the cache should be loaded from disk if it exists, false otherwise</param>
|
||||||
/// <returns>Disk cache load progress reporter and manager</returns>
|
/// <returns>Disk cache load progress reporter and manager</returns>
|
||||||
IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled, string cacheSelector);
|
IDiskCacheLoadState LoadDiskCache(PtcCacheInfo cacheInfo, bool enabled);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates that code has been loaded into guest memory, and that it might be executed in the future.
|
/// Indicates that code has been loaded into guest memory, and that it might be executed in the future.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using ARMeilleure.Common;
|
using ARMeilleure.Common;
|
||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
using ARMeilleure.Translation;
|
using ARMeilleure.Translation;
|
||||||
|
using ARMeilleure.Translation.PTC;
|
||||||
using Ryujinx.Cpu.Signal;
|
using Ryujinx.Cpu.Signal;
|
||||||
|
|
||||||
namespace Ryujinx.Cpu.Jit
|
namespace Ryujinx.Cpu.Jit
|
||||||
@@ -51,9 +52,9 @@ namespace Ryujinx.Cpu.Jit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled, string cacheSelector)
|
public IDiskCacheLoadState LoadDiskCache(PtcCacheInfo cacheInfo, bool enabled)
|
||||||
{
|
{
|
||||||
return new JitDiskCacheLoadState(_translator.LoadDiskCache(titleIdText, displayVersion, enabled, cacheSelector));
|
return new JitDiskCacheLoadState(_translator.LoadDiskCache(cacheInfo, enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using ARMeilleure.Common;
|
using ARMeilleure.Common;
|
||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
|
using ARMeilleure.Translation.PTC;
|
||||||
using Ryujinx.Cpu.Jit;
|
using Ryujinx.Cpu.Jit;
|
||||||
using Ryujinx.Cpu.LightningJit.State;
|
using Ryujinx.Cpu.LightningJit.State;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled, string cacheSelector)
|
public IDiskCacheLoadState LoadDiskCache(PtcCacheInfo cacheInfo, bool enabled)
|
||||||
{
|
{
|
||||||
return new DummyDiskCacheLoadState();
|
return new DummyDiskCacheLoadState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,18 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
|
|
||||||
public static class TargetExtensions
|
public static class TargetExtensions
|
||||||
{
|
{
|
||||||
public static bool IsMultisample(this Target target)
|
extension(Target target)
|
||||||
{
|
{
|
||||||
return target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray;
|
public bool IsMultisample => target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray;
|
||||||
}
|
|
||||||
|
|
||||||
public static bool HasDepthOrLayers(this Target target)
|
public bool HasDepthOrLayers =>
|
||||||
{
|
target is
|
||||||
return target is Target.Texture3D
|
Target.Texture3D or
|
||||||
or Target.Texture1DArray
|
Target.Texture1DArray or
|
||||||
or Target.Texture2DArray
|
Target.Texture2DArray or
|
||||||
or Target.Texture2DMultisampleArray
|
Target.Texture2DMultisampleArray or
|
||||||
or Target.Cubemap
|
Target.Cubemap or
|
||||||
or Target.CubemapArray;
|
Target.CubemapArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1117,7 +1117,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <returns>True if data was flushed, false otherwise</returns>
|
/// <returns>True if data was flushed, false otherwise</returns>
|
||||||
public bool FlushModified(bool tracked = true)
|
public bool FlushModified(bool tracked = true)
|
||||||
{
|
{
|
||||||
return TextureCompatibility.CanTextureFlush(this, _context.Capabilities) && Group.FlushModified(this, tracked);
|
return TextureCompatibility.CanTextureFlush(Info, _context.Capabilities) && Group.FlushModified(this, tracked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1131,7 +1131,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <param name="tracked">Whether or not the flush triggers write tracking. If it doesn't, the texture will not be blacklisted for scaling either.</param>
|
/// <param name="tracked">Whether or not the flush triggers write tracking. If it doesn't, the texture will not be blacklisted for scaling either.</param>
|
||||||
public void Flush(bool tracked)
|
public void Flush(bool tracked)
|
||||||
{
|
{
|
||||||
if (TextureCompatibility.CanTextureFlush(this, _context.Capabilities))
|
if (TextureCompatibility.CanTextureFlush(Info, _context.Capabilities))
|
||||||
{
|
{
|
||||||
FlushTextureDataToGuest(tracked);
|
FlushTextureDataToGuest(tracked);
|
||||||
}
|
}
|
||||||
@@ -1336,7 +1336,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
result = TextureCompatibility.PropagateViewCompatibility(result, TextureCompatibility.ViewTargetCompatible(Info, info, ref caps));
|
result = TextureCompatibility.PropagateViewCompatibility(result, TextureCompatibility.ViewTargetCompatible(Info, info, ref caps));
|
||||||
|
|
||||||
bool bothMs = Info.Target.IsMultisample() && info.Target.IsMultisample();
|
bool bothMs = Info.Target.IsMultisample && info.Target.IsMultisample;
|
||||||
if (bothMs && (Info.SamplesInX != info.SamplesInX || Info.SamplesInY != info.SamplesInY))
|
if (bothMs && (Info.SamplesInX != info.SamplesInX || Info.SamplesInY != info.SamplesInY))
|
||||||
{
|
{
|
||||||
result = TextureViewCompatibility.Incompatible;
|
result = TextureViewCompatibility.Incompatible;
|
||||||
|
|||||||
@@ -195,16 +195,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines whether a texture can flush its data back to guest memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info">Texture that will have its data flushed</param>
|
|
||||||
/// <param name="caps">Host GPU Capabilities</param>
|
|
||||||
/// <returns>True if the texture can flush, false otherwise</returns>
|
|
||||||
public static bool CanTextureFlush(Texture texture, in Capabilities caps)
|
|
||||||
{
|
|
||||||
return !texture.HasImportOverride() && CanTextureFlush(texture.Info, caps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether a texture can flush its data back to guest memory.
|
/// Determines whether a texture can flush its data back to guest memory.
|
||||||
@@ -212,14 +202,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <param name="info">Texture information</param>
|
/// <param name="info">Texture information</param>
|
||||||
/// <param name="caps">Host GPU Capabilities</param>
|
/// <param name="caps">Host GPU Capabilities</param>
|
||||||
/// <returns>True if the texture can flush, false otherwise</returns>
|
/// <returns>True if the texture can flush, false otherwise</returns>
|
||||||
private static bool CanTextureFlush(TextureInfo info, in Capabilities caps)
|
public static bool CanTextureFlush(TextureInfo info, Capabilities caps)
|
||||||
{
|
{
|
||||||
if (IsFormatHostIncompatible(info, in caps))
|
if (IsFormatHostIncompatible(info, caps))
|
||||||
{
|
{
|
||||||
return false; // Flushing this format is not supported, as it may have been converted to another host format.
|
return false; // Flushing this format is not supported, as it may have been converted to another host format.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.Target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray)
|
if (info.Target is Target.Texture2DMultisample or
|
||||||
|
Target.Texture2DMultisampleArray)
|
||||||
{
|
{
|
||||||
return false; // Flushing multisample textures is not supported, the host does not allow getting their data.
|
return false; // Flushing multisample textures is not supported, the host does not allow getting their data.
|
||||||
}
|
}
|
||||||
@@ -381,12 +372,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Some APIs align the width for copy and render target textures,
|
// Some APIs align the width for copy and render target textures,
|
||||||
// so the width may not match in this case for different uses of the same texture.
|
// so the width may not match for different uses of the same texture.
|
||||||
// To account for this, we compare the aligned width here.
|
// To account for this, we compare the aligned width here.
|
||||||
// We expect height to always match exactly, if the texture is the same.
|
// However, matching block footprints are not sufficient for compressed textures;
|
||||||
|
// their logical dimensions must also match.
|
||||||
if (alignedWidthMatches && lhsSize.Height == rhsSize.Height)
|
if (alignedWidthMatches && lhsSize.Height == rhsSize.Height)
|
||||||
{
|
{
|
||||||
return (exact && lhsSize.Width != rhsSize.Width) || lhsSize.Width < rhsSize.Width
|
return ((lhs.FormatInfo.IsCompressed || rhs.FormatInfo.IsCompressed) &&
|
||||||
|
(Math.Max(1, lhs.Width >> level) != rhs.Width || Math.Max(1, lhs.Height >> level) != rhs.Height)) ||
|
||||||
|
(exact && lhsSize.Width != rhsSize.Width) || lhsSize.Width < rhsSize.Width
|
||||||
? TextureViewCompatibility.CopyOnly
|
? TextureViewCompatibility.CopyOnly
|
||||||
: result;
|
: result;
|
||||||
}
|
}
|
||||||
@@ -397,7 +391,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
return stride == rhs.Stride ? TextureViewCompatibility.CopyOnly : TextureViewCompatibility.LayoutIncompatible;
|
return stride == rhs.Stride ? TextureViewCompatibility.CopyOnly : TextureViewCompatibility.LayoutIncompatible;
|
||||||
}
|
}
|
||||||
else if (lhs.Target.IsMultisample() != rhs.Target.IsMultisample() && alignedWidthMatches && lhsAlignedSize.Height == rhsAlignedSize.Height)
|
else if (lhs.Target.IsMultisample != rhs.Target.IsMultisample && alignedWidthMatches && lhsAlignedSize.Height == rhsAlignedSize.Height)
|
||||||
{
|
{
|
||||||
// Copy between multisample and non-multisample textures with mismatching size is allowed,
|
// Copy between multisample and non-multisample textures with mismatching size is allowed,
|
||||||
// as long aligned size matches.
|
// as long aligned size matches.
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
_allOffsets = size.AllOffsets;
|
_allOffsets = size.AllOffsets;
|
||||||
_sliceSizes = size.SliceSizes;
|
_sliceSizes = size.SliceSizes;
|
||||||
|
|
||||||
if (Storage.Target.HasDepthOrLayers() && Storage.Info.GetSlices() > GranularLayerThreshold)
|
if (Storage.Target.HasDepthOrLayers && Storage.Info.GetSlices() > GranularLayerThreshold)
|
||||||
{
|
{
|
||||||
_hasLayerViews = true;
|
_hasLayerViews = true;
|
||||||
_hasMipViews = true;
|
_hasMipViews = true;
|
||||||
@@ -182,7 +182,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
foreach (TextureIncompatibleOverlap overlap in _incompatibleOverlaps)
|
foreach (TextureIncompatibleOverlap overlap in _incompatibleOverlaps)
|
||||||
{
|
{
|
||||||
if (overlap.Compatibility <= TextureViewCompatibility.LayoutIncompatible)
|
// LayoutIncompatible and better may still use a regular texture copy dependency.
|
||||||
|
// Fully Incompatible pairs are not copy compatible in general, but may still qualify for an
|
||||||
|
// exact raw byte copy dependency (checked internally by CreateCopyDependency) when they map
|
||||||
|
// to exactly the same guest memory, such as differently typed/sized aliases of the same data.
|
||||||
|
if (overlap.Compatibility <= TextureViewCompatibility.Incompatible)
|
||||||
{
|
{
|
||||||
CreateCopyDependency(overlap.Group, false, overlap.Compatibility);
|
CreateCopyDependency(overlap.Group, false, overlap.Compatibility);
|
||||||
}
|
}
|
||||||
@@ -226,7 +230,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Flushes incompatible overlaps if the storage format requires it, and they have been modified.
|
/// Flushes incompatible overlaps if the storage format requires it, and they have been modified.
|
||||||
/// This allows unsupported host formats to accept data written to format aliased textures.
|
/// This allows unsupported host formats to accept data written to format aliased textures.
|
||||||
@@ -324,7 +327,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
FlushIncompatibleOverlapsIfNeeded();
|
FlushIncompatibleOverlapsIfNeeded();
|
||||||
|
|
||||||
EvaluateRelevantHandles(texture, (baseHandle, regionCount, split, _) =>
|
EvaluateRelevantHandles(texture, (baseHandle, regionCount, split, bound) =>
|
||||||
{
|
{
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
bool anyModified = false;
|
bool anyModified = false;
|
||||||
@@ -479,7 +482,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <param name="texture">The texture to synchronize dependents of</param>
|
/// <param name="texture">The texture to synchronize dependents of</param>
|
||||||
public void SynchronizeDependents(Texture texture)
|
public void SynchronizeDependents(Texture texture)
|
||||||
{
|
{
|
||||||
EvaluateRelevantHandles(texture, (baseHandle, regionCount, _, _) =>
|
EvaluateRelevantHandles(texture, (baseHandle, regionCount, split, bound) =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < regionCount; i++)
|
for (int i = 0; i < regionCount; i++)
|
||||||
{
|
{
|
||||||
@@ -571,7 +574,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
tracked = tracked || ShouldFlushTriggerTracking();
|
tracked = tracked || ShouldFlushTriggerTracking();
|
||||||
bool flushed = false;
|
bool flushed = false;
|
||||||
|
|
||||||
EvaluateRelevantHandles(texture, (baseHandle, regionCount, split, _) =>
|
EvaluateRelevantHandles(texture, (baseHandle, regionCount, split, bound) =>
|
||||||
{
|
{
|
||||||
int startSlice = 0;
|
int startSlice = 0;
|
||||||
int endSlice = 0;
|
int endSlice = 0;
|
||||||
@@ -652,14 +655,14 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (_flushBuffer == BufferHandle.Null)
|
if (_flushBuffer == BufferHandle.Null)
|
||||||
{
|
{
|
||||||
if (!TextureCompatibility.CanTextureFlush(Storage, _context.Capabilities))
|
if (!TextureCompatibility.CanTextureFlush(Storage.Info, _context.Capabilities))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel;
|
bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel;
|
||||||
|
|
||||||
IntPtr hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0;
|
nint hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0;
|
||||||
|
|
||||||
if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size))
|
if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size))
|
||||||
{
|
{
|
||||||
@@ -716,7 +719,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
ClearIncompatibleOverlaps(texture);
|
ClearIncompatibleOverlaps(texture);
|
||||||
|
|
||||||
EvaluateRelevantHandles(texture, (baseHandle, regionCount, _, _) =>
|
EvaluateRelevantHandles(texture, (baseHandle, regionCount, split, bound) =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < regionCount; i++)
|
for (int i = 0; i < regionCount; i++)
|
||||||
{
|
{
|
||||||
@@ -1049,7 +1052,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
int endOffset = _allOffsets[viewEnd] + _sliceSizes[lastLevel];
|
int endOffset = _allOffsets[viewEnd] + _sliceSizes[lastLevel];
|
||||||
int size = endOffset - offset;
|
int size = endOffset - offset;
|
||||||
|
|
||||||
List<RegionHandle> result = new();
|
List<RegionHandle> result = [];
|
||||||
|
|
||||||
for (int i = 0; i < TextureRange.Count; i++)
|
for (int i = 0; i < TextureRange.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -1163,7 +1166,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
SignalAllDirty();
|
SignalAllDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a view from the group, removing it from all overlap lists.
|
/// Removes a view from the group, removing it from all overlap lists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1385,7 +1387,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (_is3D)
|
if (_is3D)
|
||||||
{
|
{
|
||||||
List<TextureGroupHandle> handlesList = new();
|
List<TextureGroupHandle> handlesList = [];
|
||||||
|
|
||||||
for (int i = 0; i < levelHandles; i++)
|
for (int i = 0; i < levelHandles; i++)
|
||||||
{
|
{
|
||||||
@@ -1468,15 +1470,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
// Get the location of each texture within its storage, so we can find the handles to apply the dependency to.
|
// Get the location of each texture within its storage, so we can find the handles to apply the dependency to.
|
||||||
// This can consist of multiple disjoint regions, for example if this is a mip slice of an array texture.
|
// This can consist of multiple disjoint regions, for example if this is a mip slice of an array texture.
|
||||||
|
|
||||||
List<(int BaseHandle, int RegionCount)> targetRange = new();
|
List<(int BaseHandle, int RegionCount)> targetRange = [];
|
||||||
List<(int BaseHandle, int RegionCount)> otherRange = new();
|
List<(int BaseHandle, int RegionCount)> otherRange = [];
|
||||||
|
|
||||||
EvaluateRelevantHandles(firstLayer, firstLevel, other.Info.GetSlices(), other.Info.Levels, (baseHandle, regionCount, _, _) =>
|
EvaluateRelevantHandles(firstLayer, firstLevel, other.Info.GetSlices(), other.Info.Levels, (baseHandle, regionCount, split, specialData) =>
|
||||||
{
|
{
|
||||||
targetRange.Add((baseHandle, regionCount));
|
targetRange.Add((baseHandle, regionCount));
|
||||||
return true;
|
return true;
|
||||||
}, out _);
|
}, out _);
|
||||||
otherGroup.EvaluateRelevantHandles(other, (baseHandle, regionCount, _, _) =>
|
otherGroup.EvaluateRelevantHandles(other, (baseHandle, regionCount, split, specialData) =>
|
||||||
{
|
{
|
||||||
otherRange.Add((baseHandle, regionCount));
|
otherRange.Add((baseHandle, regionCount));
|
||||||
return true;
|
return true;
|
||||||
@@ -1601,7 +1603,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
TextureInfo info = Storage.Info;
|
TextureInfo info = Storage.Info;
|
||||||
TextureInfo otherInfo = other.Storage.Info;
|
TextureInfo otherInfo = other.Storage.Info;
|
||||||
|
|
||||||
bool textureCopy = TextureCompatibility.ViewLayoutCompatible(info, otherInfo, level, otherLevel) &&
|
// ViewLayoutCompatible/CopySizeMatches only reason about textures with some genuine
|
||||||
|
// format relationship (LayoutIncompatible or better) - they are not aware of, and must
|
||||||
|
// never be used to justify, a plain texture-to-texture copy (which some backends
|
||||||
|
// implement via a reinterpreting view) between fully Incompatible aliases such as a
|
||||||
|
// depth format and an unrelated color format. For Incompatible pairs, only the strict
|
||||||
|
// raw byte copy dependency below (which explicitly excludes depth/stencil formats) may
|
||||||
|
// be used.
|
||||||
|
bool textureCopy = compatibility != TextureViewCompatibility.Incompatible &&
|
||||||
|
TextureCompatibility.ViewLayoutCompatible(info, otherInfo, level, otherLevel) &&
|
||||||
TextureCompatibility.CopySizeMatches(info, otherInfo, level, otherLevel);
|
TextureCompatibility.CopySizeMatches(info, otherInfo, level, otherLevel);
|
||||||
|
|
||||||
if (textureCopy || rawCopy)
|
if (textureCopy || rawCopy)
|
||||||
@@ -1659,9 +1669,12 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
if (!_incompatibleOverlaps.Any(overlap => overlap.Group == other.Group))
|
if (!_incompatibleOverlaps.Any(overlap => overlap.Group == other.Group))
|
||||||
{
|
{
|
||||||
if (copy && other.Compatibility <= TextureViewCompatibility.LayoutIncompatible)
|
if (copy && other.Compatibility <= TextureViewCompatibility.Incompatible)
|
||||||
{
|
{
|
||||||
// Any of the group's views may share compatibility, even if the parents do not fully.
|
// Any of the group's views may share compatibility, even if the parents do not fully.
|
||||||
|
// Fully Incompatible groups are also let through here, since CreateCopyDependency will
|
||||||
|
// fall back to an exact raw byte copy dependency for them when the strict requirements
|
||||||
|
// for one are met (see CanCreateRawCopyDependency).
|
||||||
CreateCopyDependency(other.Group, false, other.Compatibility);
|
CreateCopyDependency(other.Group, false, other.Compatibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1763,7 +1776,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextureCompatibility.CanTextureFlush(Storage, _context.Capabilities) && !(inBuffer && _flushBufferImported))
|
if (TextureCompatibility.CanTextureFlush(Storage.Info, _context.Capabilities) && !(inBuffer && _flushBufferImported))
|
||||||
{
|
{
|
||||||
FlushSliceRange(false, handle.BaseSlice, handle.BaseSlice + handle.SliceCount, inBuffer, Storage.GetFlushTexture());
|
FlushSliceRange(false, handle.BaseSlice, handle.BaseSlice + handle.SliceCount, inBuffer, Storage.GetFlushTexture());
|
||||||
}
|
}
|
||||||
@@ -1803,4 +1816,3 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -717,6 +717,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeferredCopy = old.DeferredCopy;
|
DeferredCopy = old.DeferredCopy;
|
||||||
|
DeferredCopyRaw = old.DeferredCopyRaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,27 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
private int _colorsCount;
|
private int _colorsCount;
|
||||||
private bool _dualSourceBlend;
|
private bool _dualSourceBlend;
|
||||||
|
|
||||||
|
public bool HasAttachments
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_depthStencil != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < _colors.Length; index++)
|
||||||
|
{
|
||||||
|
if (_colors[index] != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Framebuffer()
|
public Framebuffer()
|
||||||
{
|
{
|
||||||
Handle = GL.GenFramebuffer();
|
Handle = GL.GenFramebuffer();
|
||||||
@@ -34,6 +55,12 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
return Handle;
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetDefaultSize(int width, int height)
|
||||||
|
{
|
||||||
|
GL.FramebufferParameter(FramebufferTarget.Framebuffer, FramebufferDefaultParameter.FramebufferDefaultWidth, Math.Max(1, width));
|
||||||
|
GL.FramebufferParameter(FramebufferTarget.Framebuffer, FramebufferDefaultParameter.FramebufferDefaultHeight, Math.Max(1, height));
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void AttachColor(int index, TextureView color)
|
public void AttachColor(int index, TextureView color)
|
||||||
{
|
{
|
||||||
@@ -105,13 +132,20 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
_colorsCount = colorsCount;
|
_colorsCount = colorsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetDrawBuffersImpl(int colorsCount)
|
private void SetDrawBuffersImpl(int colorsCount)
|
||||||
{
|
{
|
||||||
DrawBuffersEnum[] drawBuffers = new DrawBuffersEnum[colorsCount];
|
DrawBuffersEnum[] drawBuffers = new DrawBuffersEnum[colorsCount];
|
||||||
|
|
||||||
for (int index = 0; index < colorsCount; index++)
|
for (int index = 0; index < colorsCount; index++)
|
||||||
{
|
{
|
||||||
drawBuffers[index] = DrawBuffersEnum.ColorAttachment0 + index;
|
if (_colors[index] != null)
|
||||||
|
{
|
||||||
|
drawBuffers[index] = DrawBuffersEnum.ColorAttachment0 + index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawBuffers[index] = DrawBuffersEnum.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL.DrawBuffers(colorsCount, drawBuffers);
|
GL.DrawBuffers(colorsCount, drawBuffers);
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
{
|
{
|
||||||
TextureView destinationView = (TextureView)destination;
|
TextureView destinationView = (TextureView)destination;
|
||||||
|
|
||||||
bool srcIsMultisample = Target.IsMultisample();
|
bool srcIsMultisample = Target.IsMultisample;
|
||||||
bool dstIsMultisample = destinationView.Target.IsMultisample();
|
bool dstIsMultisample = destinationView.Target.IsMultisample;
|
||||||
|
|
||||||
if (dstIsMultisample != srcIsMultisample && Info.Format.IsDepthOrStencil())
|
if (dstIsMultisample != srcIsMultisample && Info.Format.IsDepthOrStencil())
|
||||||
{
|
{
|
||||||
@@ -172,8 +172,8 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
{
|
{
|
||||||
TextureView destinationView = (TextureView)destination;
|
TextureView destinationView = (TextureView)destination;
|
||||||
|
|
||||||
bool srcIsMultisample = Target.IsMultisample();
|
bool srcIsMultisample = Target.IsMultisample;
|
||||||
bool dstIsMultisample = destinationView.Target.IsMultisample();
|
bool dstIsMultisample = destinationView.Target.IsMultisample;
|
||||||
|
|
||||||
if (dstIsMultisample != srcIsMultisample && Info.Format.IsDepthOrStencil())
|
if (dstIsMultisample != srcIsMultisample && Info.Format.IsDepthOrStencil())
|
||||||
{
|
{
|
||||||
@@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||||||
Extents2D srcRegion = new(0, 0, Width, Height);
|
Extents2D srcRegion = new(0, 0, Width, Height);
|
||||||
Extents2D dstRegion = new(0, 0, destinationView.Width, destinationView.Height);
|
Extents2D dstRegion = new(0, 0, destinationView.Width, destinationView.Height);
|
||||||
|
|
||||||
if (destinationView.Target.IsMultisample())
|
if (destinationView.Target.IsMultisample)
|
||||||
{
|
{
|
||||||
TextureView intermmediate = _renderer.TextureCopy.IntermediatePool.GetOrCreateWithAtLeast(
|
TextureView intermmediate = _renderer.TextureCopy.IntermediatePool.GetOrCreateWithAtLeast(
|
||||||
Info.Target,
|
Info.Target,
|
||||||
|
|||||||
@@ -1537,6 +1537,11 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
{
|
{
|
||||||
DrawCount++;
|
DrawCount++;
|
||||||
|
|
||||||
|
if (!_framebuffer.HasAttachments && _viewportArray.Length >= 4)
|
||||||
|
{
|
||||||
|
_framebuffer.SetDefaultSize((int)_viewportArray[2], (int)_viewportArray[3]);
|
||||||
|
}
|
||||||
|
|
||||||
_unit0Texture?.Bind(0);
|
_unit0Texture?.Bind(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,19 +70,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
|
|
||||||
Operand bindlessHandle = texOp.GetSource(0);
|
Operand bindlessHandle = texOp.GetSource(0);
|
||||||
|
|
||||||
if (bindlessHandle.AsgOp is PhiNode phi)
|
if (!IsBindlessAccessAllowed(bindlessHandle))
|
||||||
{
|
|
||||||
for (int srcIndex = 0; srcIndex < phi.SourcesCount; srcIndex++)
|
|
||||||
{
|
|
||||||
Operand phiSource = phi.GetSource(srcIndex);
|
|
||||||
|
|
||||||
if (phiSource.AsgOp is not PhiNode && !IsBindlessAccessAllowed(phiSource))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!IsBindlessAccessAllowed(bindlessHandle))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -100,7 +88,10 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
|
|
||||||
texOp.SetSource(0, textureIndex);
|
texOp.SetSource(0, textureIndex);
|
||||||
|
|
||||||
bool hasSampler = !texOp.Inst.IsImage();
|
// Buffer textures use a TIC/BufferView only and never consume a sampler.
|
||||||
|
// Avoiding a sampler descriptor array here is especially important for bindless
|
||||||
|
// texture buffers, where the array can span the entire sampler pool for no benefit.
|
||||||
|
bool hasSampler = !texOp.Inst.IsImage() && texOp.Type != SamplerType.TextureBuffer;
|
||||||
|
|
||||||
SetBindingPair textureSetAndBinding = resourceManager.GetTextureOrImageBinding(
|
SetBindingPair textureSetAndBinding = resourceManager.GetTextureOrImageBinding(
|
||||||
texOp.Inst,
|
texOp.Inst,
|
||||||
@@ -143,26 +134,112 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
|
|
||||||
private static bool IsBindlessAccessAllowed(Operand bindlessHandle)
|
private static bool IsBindlessAccessAllowed(Operand bindlessHandle)
|
||||||
{
|
{
|
||||||
if (bindlessHandle.Type == OperandType.ConstantBuffer)
|
// Walk only SSA merges and integer operations that can transparently construct
|
||||||
{
|
// or select a packed texture/sampler handle. Do not walk arbitrary operations:
|
||||||
// Bindless access with handles from constant buffer is allowed.
|
// finding an unrelated resource load elsewhere in the SSA graph must not enable
|
||||||
|
// descriptor-array access for this handle.
|
||||||
|
const int MaxVisitedOperands = 256;
|
||||||
|
const int MaxDepth = 64;
|
||||||
|
|
||||||
return true;
|
Stack<(Operand Operand, int Depth)> work = new();
|
||||||
|
HashSet<Operand> visited = new();
|
||||||
|
|
||||||
|
work.Push((bindlessHandle, 0));
|
||||||
|
|
||||||
|
while (work.Count != 0 && visited.Count < MaxVisitedOperands)
|
||||||
|
{
|
||||||
|
(Operand operand, int depth) = work.Pop();
|
||||||
|
|
||||||
|
if (operand == null || depth > MaxDepth || !visited.Add(operand))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operand.Type == OperandType.ConstantBuffer)
|
||||||
|
{
|
||||||
|
// Constant buffers are accepted by the existing direct-handle path and
|
||||||
|
// remain accepted when SSA merges or integer handle arithmetic obscure them.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operand.AsgOp is PhiNode phi)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < phi.SourcesCount; index++)
|
||||||
|
{
|
||||||
|
Operand source = phi.GetSource(index);
|
||||||
|
|
||||||
|
if (source.Type != OperandType.Undefined)
|
||||||
|
{
|
||||||
|
work.Push((source, depth + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operand.AsgOp is not Operation operation)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction inst = operation.Inst & Instruction.Mask;
|
||||||
|
|
||||||
|
if (inst == Instruction.Load)
|
||||||
|
{
|
||||||
|
// Preserve the performance restriction. Static CBUF operands are already
|
||||||
|
// accepted above; accept their dynamically indexed Load form as the same
|
||||||
|
// resource class, plus the existing shader-input and storage-buffer sources.
|
||||||
|
// Other loads remain traversal barriers and cannot authorize a pool array.
|
||||||
|
if (operation.StorageKind == StorageKind.ConstantBuffer ||
|
||||||
|
operation.StorageKind == StorageKind.Input ||
|
||||||
|
operation.StorageKind == StorageKind.StorageBuffer)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsHandleConstructionOperation(inst))
|
||||||
|
{
|
||||||
|
// Texture/image operations, arbitrary loads, floating-point conversions,
|
||||||
|
// calls and other unrelated calculations are deliberate traversal barriers.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < operation.SourcesCount; index++)
|
||||||
|
{
|
||||||
|
work.Push((operation.GetSource(index), depth + 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bindlessHandle.AsgOp is not Operation handleOp ||
|
return false;
|
||||||
handleOp.Inst != Instruction.Load ||
|
}
|
||||||
(handleOp.StorageKind != StorageKind.Input && handleOp.StorageKind != StorageKind.StorageBuffer))
|
|
||||||
{
|
|
||||||
// Right now, we only allow bindless access when the handle comes from a shader input or storage buffer.
|
|
||||||
// This is an artificial limitation to prevent it from being used in cases where it
|
|
||||||
// would have a large performance impact of loading all textures in the pool.
|
|
||||||
// It might be removed in the future, if we can mitigate the performance impact.
|
|
||||||
|
|
||||||
return false;
|
private static bool IsHandleConstructionOperation(Instruction inst)
|
||||||
}
|
{
|
||||||
|
return inst is
|
||||||
return true;
|
Instruction.Add or
|
||||||
|
Instruction.Subtract or
|
||||||
|
Instruction.Multiply or
|
||||||
|
Instruction.MultiplyHighS32 or
|
||||||
|
Instruction.MultiplyHighU32 or
|
||||||
|
Instruction.BitwiseAnd or
|
||||||
|
Instruction.BitwiseExclusiveOr or
|
||||||
|
Instruction.BitwiseNot or
|
||||||
|
Instruction.BitwiseOr or
|
||||||
|
Instruction.BitfieldExtractS32 or
|
||||||
|
Instruction.BitfieldExtractU32 or
|
||||||
|
Instruction.BitfieldInsert or
|
||||||
|
Instruction.ShiftLeft or
|
||||||
|
Instruction.ShiftRightS32 or
|
||||||
|
Instruction.ShiftRightU32 or
|
||||||
|
Instruction.MinimumU32 or
|
||||||
|
Instruction.MaximumU32 or
|
||||||
|
Instruction.ClampU32 or
|
||||||
|
Instruction.ConditionalSelect or
|
||||||
|
Instruction.Copy or
|
||||||
|
Instruction.VectorExtract;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryConvertBindless(BasicBlock block, ResourceManager resourceManager, IGpuAccessor gpuAccessor, TextureOperation texOp)
|
private static bool TryConvertBindless(BasicBlock block, ResourceManager resourceManager, IGpuAccessor gpuAccessor, TextureOperation texOp)
|
||||||
|
|||||||
@@ -32,6 +32,29 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
public bool HasDepthStencil { get; private set; }
|
public bool HasDepthStencil { get; private set; }
|
||||||
public int ColorAttachmentsCount => AttachmentsCount - (HasDepthStencil ? 1 : 0);
|
public int ColorAttachmentsCount => AttachmentsCount - (HasDepthStencil ? 1 : 0);
|
||||||
|
|
||||||
|
public bool SetVirtualSize(uint width, uint height, uint layers)
|
||||||
|
{
|
||||||
|
if (AttachmentsCount != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Math.Max(1u, width);
|
||||||
|
height = Math.Max(1u, height);
|
||||||
|
layers = Math.Max(1u, layers);
|
||||||
|
|
||||||
|
if (Width == width && Height == height && Layers == layers)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Width = width;
|
||||||
|
Height = height;
|
||||||
|
Layers = layers;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public FramebufferParams(Device device, TextureView view, uint width, uint height)
|
public FramebufferParams(Device device, TextureView view, uint width, uint height)
|
||||||
{
|
{
|
||||||
Format format = view.Info.Format;
|
Format format = view.Info.Format;
|
||||||
|
|||||||
@@ -406,10 +406,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
if (dstIsDepthOrStencil)
|
if (dstIsDepthOrStencil)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
_pipeline.SetProgram(src.Info.Target.IsMultisample ? _programDepthBlitMs : _programDepthBlit);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
||||||
}
|
}
|
||||||
else if (src.Info.Target.IsMultisample())
|
else if (src.Info.Target.IsMultisample)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(_programColorBlitMs);
|
_pipeline.SetProgram(_programColorBlitMs);
|
||||||
}
|
}
|
||||||
@@ -566,12 +566,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
if (isDepth)
|
if (isDepth)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
_pipeline.SetProgram(src.Info.Target.IsMultisample ? _programDepthBlitMs : _programDepthBlit);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programStencilBlitMs : _programStencilBlit);
|
_pipeline.SetProgram(src.Info.Target.IsMultisample ? _programStencilBlitMs : _programStencilBlit);
|
||||||
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -843,6 +843,11 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
public void SetImage(ShaderStage stage, int binding, ITexture image)
|
public void SetImage(ShaderStage stage, int binding, ITexture image)
|
||||||
{
|
{
|
||||||
_descriptorSetUpdater.SetImage(Cbs, stage, binding, image);
|
_descriptorSetUpdater.SetImage(Cbs, stage, binding, image);
|
||||||
|
|
||||||
|
if (stage == ShaderStage.Fragment && image is TextureView view)
|
||||||
|
{
|
||||||
|
FramebufferParams?.SetVirtualSize((uint)view.Width, (uint)view.Height, (uint)view.Layers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetImage(int binding, Auto<DisposableImageView> image)
|
public void SetImage(int binding, Auto<DisposableImageView> image)
|
||||||
@@ -1607,6 +1612,24 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
private bool RecreateGraphicsPipelineIfNeeded()
|
private bool RecreateGraphicsPipelineIfNeeded()
|
||||||
{
|
{
|
||||||
|
if (FramebufferParams != null &&
|
||||||
|
FramebufferParams.AttachmentsCount == 0 &&
|
||||||
|
FramebufferParams.Width == 1 &&
|
||||||
|
FramebufferParams.Height == 1 &&
|
||||||
|
DynamicState.ViewportsCount != 0)
|
||||||
|
{
|
||||||
|
// An attachmentless fragment pass can reach its first draw before the storage
|
||||||
|
// image descriptor is rebound. At that point the null framebuffer still has
|
||||||
|
// its constructor fallback of 1x1, even though the guest viewport already
|
||||||
|
// describes the real render area. Seed the virtual framebuffer from that
|
||||||
|
// viewport so the first storage-image draw is not clipped to one pixel.
|
||||||
|
Silk.NET.Vulkan.Viewport viewport = DynamicState.Viewports[0];
|
||||||
|
uint width = (uint)Math.Max(1f, Math.Abs(viewport.Width));
|
||||||
|
uint height = (uint)Math.Max(1f, Math.Abs(viewport.Height));
|
||||||
|
|
||||||
|
FramebufferParams.SetVirtualSize(width, height, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (AutoFlush.ShouldFlushDraw(DrawCount))
|
if (AutoFlush.ShouldFlushDraw(DrawCount))
|
||||||
{
|
{
|
||||||
Gd.FlushAllCommands();
|
Gd.FlushAllCommands();
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
_device = device;
|
_device = device;
|
||||||
_info = info;
|
_info = info;
|
||||||
|
|
||||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample();
|
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample;
|
||||||
|
|
||||||
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
||||||
uint levels = (uint)info.Levels;
|
uint levels = (uint)info.Levels;
|
||||||
@@ -323,7 +323,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
usage |= ImageUsageFlags.ColorAttachmentBit;
|
usage |= ImageUsageFlags.ColorAttachmentBit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.IsImageCompatible() && (isMsImageStorageSupported || !target.IsMultisample()))
|
if (format.IsImageCompatible() && (isMsImageStorageSupported || !target.IsMultisample))
|
||||||
{
|
{
|
||||||
usage |= ImageUsageFlags.StorageBit;
|
usage |= ImageUsageFlags.StorageBit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
gd.Textures.Add(this);
|
gd.Textures.Add(this);
|
||||||
|
|
||||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample();
|
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample;
|
||||||
|
|
||||||
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
||||||
ImageUsageFlags usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities, isMsImageStorageSupported) & storage.UsageFlags;
|
ImageUsageFlags usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities, isMsImageStorageSupported) & storage.UsageFlags;
|
||||||
@@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
ImageUsageFlags shaderUsage = ImageUsageFlags.SampledBit;
|
ImageUsageFlags shaderUsage = ImageUsageFlags.SampledBit;
|
||||||
|
|
||||||
if (info.Format.IsImageCompatible() && (_gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample()))
|
if (info.Format.IsImageCompatible() && (_gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample))
|
||||||
{
|
{
|
||||||
shaderUsage |= ImageUsageFlags.StorageBit;
|
shaderUsage |= ImageUsageFlags.StorageBit;
|
||||||
}
|
}
|
||||||
@@ -225,12 +225,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
Image srcImage = src.GetImage().Get(cbs).Value;
|
Image srcImage = src.GetImage().Get(cbs).Value;
|
||||||
Image dstImage = dst.GetImage().Get(cbs).Value;
|
Image dstImage = dst.GetImage().Get(cbs).Value;
|
||||||
|
|
||||||
if (!dst.Info.Target.IsMultisample() && Info.Target.IsMultisample())
|
if (!dst.Info.Target.IsMultisample && Info.Target.IsMultisample)
|
||||||
{
|
{
|
||||||
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
||||||
_gd.HelperShader.CopyMSToNonMS(_gd, cbs, src, dst, 0, firstLayer, layers);
|
_gd.HelperShader.CopyMSToNonMS(_gd, cbs, src, dst, 0, firstLayer, layers);
|
||||||
}
|
}
|
||||||
else if (dst.Info.Target.IsMultisample() && !Info.Target.IsMultisample())
|
else if (dst.Info.Target.IsMultisample && !Info.Target.IsMultisample)
|
||||||
{
|
{
|
||||||
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
||||||
_gd.HelperShader.CopyNonMSToMS(_gd, cbs, src, dst, 0, firstLayer, layers);
|
_gd.HelperShader.CopyNonMSToMS(_gd, cbs, src, dst, 0, firstLayer, layers);
|
||||||
@@ -287,11 +287,11 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
Image srcImage = src.GetImage().Get(cbs).Value;
|
Image srcImage = src.GetImage().Get(cbs).Value;
|
||||||
Image dstImage = dst.GetImage().Get(cbs).Value;
|
Image dstImage = dst.GetImage().Get(cbs).Value;
|
||||||
|
|
||||||
if (!dst.Info.Target.IsMultisample() && Info.Target.IsMultisample())
|
if (!dst.Info.Target.IsMultisample && Info.Target.IsMultisample)
|
||||||
{
|
{
|
||||||
_gd.HelperShader.CopyMSToNonMS(_gd, cbs, src, dst, srcLayer, dstLayer, 1);
|
_gd.HelperShader.CopyMSToNonMS(_gd, cbs, src, dst, srcLayer, dstLayer, 1);
|
||||||
}
|
}
|
||||||
else if (dst.Info.Target.IsMultisample() && !Info.Target.IsMultisample())
|
else if (dst.Info.Target.IsMultisample && !Info.Target.IsMultisample)
|
||||||
{
|
{
|
||||||
_gd.HelperShader.CopyNonMSToMS(_gd, cbs, src, dst, srcLayer, dstLayer, 1);
|
_gd.HelperShader.CopyNonMSToMS(_gd, cbs, src, dst, srcLayer, dstLayer, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
|
using ARMeilleure.Translation.PTC;
|
||||||
using Ryujinx.Cpu;
|
using Ryujinx.Cpu;
|
||||||
using Ryujinx.Graphics.Gpu;
|
using Ryujinx.Graphics.Gpu;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||||
@@ -9,12 +10,10 @@ namespace Ryujinx.HLE.HOS
|
|||||||
interface IArmProcessContext : IProcessContext
|
interface IArmProcessContext : IProcessContext
|
||||||
{
|
{
|
||||||
IDiskCacheLoadState Initialize(
|
IDiskCacheLoadState Initialize(
|
||||||
string titleIdText,
|
PtcCacheInfo cacheInfo,
|
||||||
string displayVersion,
|
|
||||||
bool diskCacheEnabled,
|
bool diskCacheEnabled,
|
||||||
ulong codeAddress,
|
ulong codeAddress,
|
||||||
ulong codeSize,
|
ulong codeSize);
|
||||||
string cacheSelector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArmProcessContext<T> : IArmProcessContext where T : class, IVirtualMemoryManagerTracked, IMemoryManager
|
class ArmProcessContext<T> : IArmProcessContext where T : class, IVirtualMemoryManagerTracked, IMemoryManager
|
||||||
@@ -64,15 +63,13 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IDiskCacheLoadState Initialize(
|
public IDiskCacheLoadState Initialize(
|
||||||
string titleIdText,
|
PtcCacheInfo cacheInfo,
|
||||||
string displayVersion,
|
|
||||||
bool diskCacheEnabled,
|
bool diskCacheEnabled,
|
||||||
ulong codeAddress,
|
ulong codeAddress,
|
||||||
ulong codeSize,
|
ulong codeSize)
|
||||||
string cacheSelector)
|
|
||||||
{
|
{
|
||||||
_cpuContext.PrepareCodeRange(codeAddress, codeSize);
|
_cpuContext.PrepareCodeRange(codeAddress, codeSize);
|
||||||
return _cpuContext.LoadDiskCache(titleIdText, displayVersion, diskCacheEnabled, cacheSelector);
|
return _cpuContext.LoadDiskCache(cacheInfo, diskCacheEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InvalidateCacheRegion(ulong address, ulong size)
|
public void InvalidateCacheRegion(ulong address, ulong size)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using ARMeilleure.Translation.PTC;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Cpu;
|
using Ryujinx.Cpu;
|
||||||
@@ -7,6 +8,7 @@ using Ryujinx.Cpu.LightningJit;
|
|||||||
using Ryujinx.Graphics.Gpu;
|
using Ryujinx.Graphics.Gpu;
|
||||||
using Ryujinx.HLE.HOS.Kernel;
|
using Ryujinx.HLE.HOS.Kernel;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||||
|
using Ryujinx.HLE.Loaders.Processes;
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -17,8 +19,10 @@ namespace Ryujinx.HLE.HOS
|
|||||||
{
|
{
|
||||||
private readonly ITickSource _tickSource;
|
private readonly ITickSource _tickSource;
|
||||||
private readonly GpuContext _gpu;
|
private readonly GpuContext _gpu;
|
||||||
private readonly string _titleIdText;
|
private readonly ulong _programId;
|
||||||
|
private readonly byte _programIndex;
|
||||||
private readonly string _displayVersion;
|
private readonly string _displayVersion;
|
||||||
|
private readonly ProcessKind _processKind;
|
||||||
private readonly bool _diskCacheEnabled;
|
private readonly bool _diskCacheEnabled;
|
||||||
private readonly string _diskCacheSelector;
|
private readonly string _diskCacheSelector;
|
||||||
private readonly ulong _codeAddress;
|
private readonly ulong _codeAddress;
|
||||||
@@ -29,8 +33,10 @@ namespace Ryujinx.HLE.HOS
|
|||||||
public ArmProcessContextFactory(
|
public ArmProcessContextFactory(
|
||||||
ITickSource tickSource,
|
ITickSource tickSource,
|
||||||
GpuContext gpu,
|
GpuContext gpu,
|
||||||
string titleIdText,
|
ulong programId,
|
||||||
|
byte programIndex,
|
||||||
string displayVersion,
|
string displayVersion,
|
||||||
|
ProcessKind processKind,
|
||||||
bool diskCacheEnabled,
|
bool diskCacheEnabled,
|
||||||
string diskCacheSelector,
|
string diskCacheSelector,
|
||||||
ulong codeAddress,
|
ulong codeAddress,
|
||||||
@@ -38,8 +44,10 @@ namespace Ryujinx.HLE.HOS
|
|||||||
{
|
{
|
||||||
_tickSource = tickSource;
|
_tickSource = tickSource;
|
||||||
_gpu = gpu;
|
_gpu = gpu;
|
||||||
_titleIdText = titleIdText;
|
_programId = programId;
|
||||||
|
_programIndex = programIndex;
|
||||||
_displayVersion = displayVersion;
|
_displayVersion = displayVersion;
|
||||||
|
_processKind = processKind;
|
||||||
_diskCacheEnabled = diskCacheEnabled;
|
_diskCacheEnabled = diskCacheEnabled;
|
||||||
_diskCacheSelector = diskCacheSelector;
|
_diskCacheSelector = diskCacheSelector;
|
||||||
_codeAddress = codeAddress;
|
_codeAddress = codeAddress;
|
||||||
@@ -121,8 +129,18 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
string cacheSelector = _diskCacheSelector ?? "default";
|
string cacheSelector = _diskCacheSelector ?? "default";
|
||||||
|
string programIdText = _programId == 0 ? string.Empty : $"{_programId:x16}";
|
||||||
|
string applicationIdText = _programId == 0 ? string.Empty : $"{_programId & ~0xFul:x16}";
|
||||||
|
PtcCacheInfo cacheInfo = new(
|
||||||
|
pid,
|
||||||
|
programIdText,
|
||||||
|
applicationIdText,
|
||||||
|
_programIndex,
|
||||||
|
_displayVersion,
|
||||||
|
_processKind.ToString(),
|
||||||
|
cacheSelector);
|
||||||
|
|
||||||
DiskCacheLoadState = processContext.Initialize(_titleIdText, _displayVersion, _diskCacheEnabled, _codeAddress, _codeSize, cacheSelector);
|
DiskCacheLoadState = processContext.Initialize(cacheInfo, _diskCacheEnabled, _codeAddress, _codeSize);
|
||||||
|
|
||||||
return processContext;
|
return processContext;
|
||||||
}
|
}
|
||||||
|
|||||||
+173
-2
@@ -12,12 +12,23 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
{
|
{
|
||||||
class ICommonStateGetter : DisposableIpcService
|
class ICommonStateGetter : DisposableIpcService
|
||||||
{
|
{
|
||||||
|
// Nintendo serves the VR goggle commands based on Title ID, apparently.
|
||||||
|
private static ReadOnlySpan<ulong> _supportedVRGoggleTitles =>
|
||||||
|
[
|
||||||
|
0x0100CA001D972000, // Nintendo Classics: Virtual Boy NSO
|
||||||
|
0x0100BFC01D976000 // Nintendo Classics: Virtual Boy NSO
|
||||||
|
];
|
||||||
|
|
||||||
|
private int _resolutionWidth = 1280;
|
||||||
|
private int _resolutionHeight = 720;
|
||||||
|
|
||||||
private readonly ServiceCtx _context;
|
private readonly ServiceCtx _context;
|
||||||
|
|
||||||
private readonly Apm.ManagerServer _apmManagerServer;
|
private readonly Apm.ManagerServer _apmManagerServer;
|
||||||
private readonly Apm.SystemManagerServer _apmSystemManagerServer;
|
private readonly Apm.SystemManagerServer _apmSystemManagerServer;
|
||||||
|
|
||||||
private bool _vrModeEnabled;
|
private bool _vrModeEnabled;
|
||||||
|
private bool _vrMode3dEnabled;
|
||||||
#pragma warning disable CS0414, IDE0052 // Remove unread private member
|
#pragma warning disable CS0414, IDE0052 // Remove unread private member
|
||||||
private bool _lcdBacklighOffEnabled;
|
private bool _lcdBacklighOffEnabled;
|
||||||
private bool _requestExitToLibraryAppletAtExecuteNextProgramEnabled;
|
private bool _requestExitToLibraryAppletAtExecuteNextProgramEnabled;
|
||||||
@@ -153,6 +164,47 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandCmif(30)]
|
||||||
|
// GetHomeButtonReaderLockAccessor() -> nn::am::service::ILockAccessor
|
||||||
|
public ResultCode GetHomeButtonReaderLockAccessor(ServiceCtx context)
|
||||||
|
{
|
||||||
|
// We currently do not have any home button functionality, so it's fine to stub this for now.
|
||||||
|
// Similar to using GetReaderLockAccessorEx() with inval=0.
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
MakeObject(context, new ILockAccessor(context));
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(31)] // 2.0.0 +
|
||||||
|
// GetReaderLockAccessorEx(uint unknown) -> nn::am::service::ILockAccessor
|
||||||
|
public ResultCode GetReaderLockAccessorEx(ServiceCtx context)
|
||||||
|
{
|
||||||
|
uint unknown = context.RequestData.ReadUInt32();
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown });
|
||||||
|
if (unknown < 0 || unknown > 3)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(unknown));
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeObject(context, new ILockAccessor(context));
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(32)] // 2.0.0+
|
||||||
|
// GetWriterLockAccessorEx(uint unknown) -> nn::am::service::ILockAccessor
|
||||||
|
public ResultCode GetWriterLockAccessorEx(ServiceCtx context)
|
||||||
|
{
|
||||||
|
uint unknown = context.RequestData.ReadUInt32();
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown });
|
||||||
|
if (unknown < 0 || unknown > 3)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(unknown));
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeObject(context, new ILockAccessor(context));
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandCmif(50)] // 3.0.0+
|
[CommandCmif(50)] // 3.0.0+
|
||||||
// IsVrModeEnabled() -> b8
|
// IsVrModeEnabled() -> b8
|
||||||
public ResultCode IsVrModeEnabled(ServiceCtx context)
|
public ResultCode IsVrModeEnabled(ServiceCtx context)
|
||||||
@@ -177,8 +229,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
// SetLcdBacklighOffEnabled(b8)
|
// SetLcdBacklighOffEnabled(b8)
|
||||||
public ResultCode SetLcdBacklighOffEnabled(ServiceCtx context)
|
public ResultCode SetLcdBacklighOffEnabled(ServiceCtx context)
|
||||||
{
|
{
|
||||||
// NOTE: Service sets a private field here, maybe this field is used somewhere else to turned off the backlight.
|
// NOTE: Service sets a private field here, maybe this field is used somewhere else to turn off the backlight.
|
||||||
// Since we don't support backlight, it's fine to do nothing.
|
// Since we don't support the backlight feature, it's fine to stub it.
|
||||||
|
|
||||||
_lcdBacklighOffEnabled = context.RequestData.ReadBoolean();
|
_lcdBacklighOffEnabled = context.RequestData.ReadBoolean();
|
||||||
|
|
||||||
@@ -298,6 +350,22 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
return (ResultCode)_apmSystemManagerServer.GetCurrentPerformanceConfiguration(context);
|
return (ResultCode)_apmSystemManagerServer.GetCurrentPerformanceConfiguration(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandCmif(130)] // 21.0.0+
|
||||||
|
// EnableStartupLogoDisappearedMessage()
|
||||||
|
public ResultCode EnableStartupLogoDisappearedMessage(ServiceCtx context)
|
||||||
|
{
|
||||||
|
// NOTE: Service only delivers the message once the startup logo has actually
|
||||||
|
// disappeared. We never display one, so it is already deliverable. Callers
|
||||||
|
// gate their first frame on this message and hang without it.
|
||||||
|
|
||||||
|
AppletStateMgr appletState = context.Device.System.AppletState;
|
||||||
|
|
||||||
|
appletState.Messages.Enqueue(AppletMessage.StartupLogoDisappeared);
|
||||||
|
appletState.MessageEvent.ReadableEvent.Signal();
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandCmif(300)] // 9.0.0+
|
[CommandCmif(300)] // 9.0.0+
|
||||||
// GetSettingsPlatformRegion() -> u8
|
// GetSettingsPlatformRegion() -> u8
|
||||||
public ResultCode GetSettingsPlatformRegion(ServiceCtx context)
|
public ResultCode GetSettingsPlatformRegion(ServiceCtx context)
|
||||||
@@ -310,6 +378,15 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandCmif(610)] // 21.0.0+
|
||||||
|
// UnknownCommand610(long unknown)
|
||||||
|
public ResultCode UnknownCommand610(ServiceCtx context)
|
||||||
|
{
|
||||||
|
long unknown = context.RequestData.ReadInt64();
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown });
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandCmif(900)] // 11.0.0+
|
[CommandCmif(900)] // 11.0.0+
|
||||||
// SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled()
|
// SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled()
|
||||||
public ResultCode SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(ServiceCtx context)
|
public ResultCode SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(ServiceCtx context)
|
||||||
@@ -320,6 +397,100 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1000)] // 19.0.0+
|
||||||
|
// BeginVrMode3d()
|
||||||
|
public ResultCode BeginVrMode3d(ServiceCtx context)
|
||||||
|
{
|
||||||
|
// NOTE: Service also applies a stereo scale to the goggle display, which we don't
|
||||||
|
// model, so only the state is kept here.
|
||||||
|
|
||||||
|
_vrMode3dEnabled = true;
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1001)] // 19.0.0+
|
||||||
|
// EndVrMode3d()
|
||||||
|
public ResultCode EndVrMode3d(ServiceCtx context)
|
||||||
|
{
|
||||||
|
_vrMode3dEnabled = false;
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1002)] // 19.0.0+
|
||||||
|
// IsVrModeEnabled3d() -> b8
|
||||||
|
public ResultCode IsVrModeEnabled3d(ServiceCtx context)
|
||||||
|
{
|
||||||
|
context.ResponseData.Write(_vrMode3dEnabled);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1003)] // 21.0.0+
|
||||||
|
// GetVrLaboGoggleViewport() -> (s32 x, s32 y, s32 width, s32 height)
|
||||||
|
public ResultCode GetVrLaboGoggleViewport(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (!IsVrLaboGoggleSupportedTitle(context))
|
||||||
|
{
|
||||||
|
return ResultCode.ObjectInvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VrDisplayCoordinateX = 0;
|
||||||
|
int VrDisplayCoordinateY = 0;
|
||||||
|
int VrDisplayWidth = _resolutionWidth;
|
||||||
|
int VrDisplayHeight = _resolutionHeight;
|
||||||
|
|
||||||
|
context.ResponseData.Write(VrDisplayCoordinateX);
|
||||||
|
context.ResponseData.Write(VrDisplayCoordinateY);
|
||||||
|
context.ResponseData.Write(VrDisplayWidth);
|
||||||
|
context.ResponseData.Write(VrDisplayHeight);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1004)] // 21.0.0+
|
||||||
|
// GetPanelPhysicalSizeForSpecificTitle() -> (f32 width, f32 height)
|
||||||
|
public ResultCode GetPanelPhysicalSizeForSpecificTitle(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (!IsVrLaboGoggleSupportedTitle(context))
|
||||||
|
{
|
||||||
|
return ResultCode.ObjectInvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The switch provides micrometres, but the command reports millimetres.
|
||||||
|
// 6.2 inch 16:9 panel.
|
||||||
|
float PanelPhysicalWidthMicroMeters = 137250f;
|
||||||
|
float PanelPhysicalHeightMicroMeters = 77200f;
|
||||||
|
|
||||||
|
context.ResponseData.Write(PanelPhysicalWidthMicroMeters / 1000f);
|
||||||
|
context.ResponseData.Write(PanelPhysicalHeightMicroMeters / 1000f);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1005)] // 21.0.0+
|
||||||
|
// GetPanelResolutionForSpecificTitle() -> (s32 width, s32 height)
|
||||||
|
public ResultCode GetPanelResolutionForSpecificTitle(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (!IsVrLaboGoggleSupportedTitle(context))
|
||||||
|
{
|
||||||
|
return ResultCode.ObjectInvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.ResponseData.Write(_resolutionWidth);
|
||||||
|
context.ResponseData.Write(_resolutionHeight);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsVrLaboGoggleSupportedTitle(ServiceCtx context)
|
||||||
|
{
|
||||||
|
ulong programId = context.Device.Processes.ActiveApplication.ProgramId;
|
||||||
|
|
||||||
|
return _supportedVRGoggleTitles.Contains(programId);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
if (isDisposing)
|
if (isDisposing)
|
||||||
|
|||||||
+80
@@ -0,0 +1,80 @@
|
|||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
|
||||||
|
{
|
||||||
|
class ILockAccessor : IpcService
|
||||||
|
{
|
||||||
|
private readonly ServiceCtx _context;
|
||||||
|
|
||||||
|
private readonly Apm.ManagerServer _apmManagerServer;
|
||||||
|
private readonly Apm.SystemManagerServer _apmSystemManagerServer;
|
||||||
|
|
||||||
|
private readonly KEvent _lockEvent;
|
||||||
|
private int _lockEventHandle;
|
||||||
|
|
||||||
|
public ILockAccessor(ServiceCtx context)
|
||||||
|
{
|
||||||
|
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
_apmManagerServer = new Apm.ManagerServer(context);
|
||||||
|
_apmSystemManagerServer = new Apm.SystemManagerServer(context);
|
||||||
|
|
||||||
|
_lockEvent = new KEvent(context.Device.System.KernelContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1)]
|
||||||
|
// TryLock(unknown u8 bool) -> unknown u8 bool
|
||||||
|
public ResultCode TryLock(ServiceCtx context)
|
||||||
|
{
|
||||||
|
// Official sw only uses inflag=false.
|
||||||
|
// Official sw just closes the output handle.
|
||||||
|
// The input flag controls whether this returns the output handle.
|
||||||
|
bool unknown = context.RequestData.ReadBoolean();
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown });
|
||||||
|
|
||||||
|
context.ResponseData.Write(false);
|
||||||
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_lockEventHandle);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(2)]
|
||||||
|
// Unlock()
|
||||||
|
public ResultCode Unlock(ServiceCtx context)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(3)]
|
||||||
|
// GetEvent() -> EventHandle w/ autoclear = false
|
||||||
|
public ResultCode GetEvent(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (_lockEventHandle == 0)
|
||||||
|
{
|
||||||
|
if (context.Process.HandleTable.GenerateHandle(_lockEvent.ReadableEvent, out _lockEventHandle) != Result.Success)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Out of handles!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_lockEventHandle);
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(4)] // 10.0.0+
|
||||||
|
// IsLocked() -> unknown u8 bool
|
||||||
|
public ResultCode IsLocked(ServiceCtx context)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
context.ResponseData.Write(false);
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -32,5 +32,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
DetectShortPressingCaptureButton = 90,
|
DetectShortPressingCaptureButton = 90,
|
||||||
AlbumScreenShotTaken = 92,
|
AlbumScreenShotTaken = 92,
|
||||||
AlbumRecordingSaved = 93,
|
AlbumRecordingSaved = 93,
|
||||||
|
StartupLogoDisappeared = 95, // 21.0.0+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,8 +182,10 @@ namespace Ryujinx.HLE.Loaders.Processes
|
|||||||
ArmProcessContextFactory processContextFactory = new(
|
ArmProcessContextFactory processContextFactory = new(
|
||||||
context.Device.System.TickSource,
|
context.Device.System.TickSource,
|
||||||
context.Device.Gpu,
|
context.Device.Gpu,
|
||||||
string.Empty,
|
kip.ProgramId,
|
||||||
string.Empty,
|
0,
|
||||||
|
kip.Version.ToString(),
|
||||||
|
ProcessResult.GetProcessKind(kip.ProgramId),
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
codeAddress,
|
codeAddress,
|
||||||
@@ -377,8 +379,10 @@ namespace Ryujinx.HLE.Loaders.Processes
|
|||||||
ArmProcessContextFactory processContextFactory = new(
|
ArmProcessContextFactory processContextFactory = new(
|
||||||
context.Device.System.TickSource,
|
context.Device.System.TickSource,
|
||||||
context.Device.Gpu,
|
context.Device.Gpu,
|
||||||
$"{programId:x16}",
|
programId,
|
||||||
|
programIndex,
|
||||||
displayVersion,
|
displayVersion,
|
||||||
|
ProcessResult.GetProcessKind(programId),
|
||||||
diskCacheEnabled,
|
diskCacheEnabled,
|
||||||
diskCacheSelector,
|
diskCacheSelector,
|
||||||
codeStart,
|
codeStart,
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
|||||||
AllowCodeMemoryForJit = allowCodeMemoryForJit;
|
AllowCodeMemoryForJit = allowCodeMemoryForJit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProcessKind GetProcessKind(ulong programId)
|
internal static ProcessKind GetProcessKind(ulong programId)
|
||||||
{
|
{
|
||||||
if (programId == 0)
|
if (programId == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
+20
-4
@@ -45,6 +45,7 @@ using Ryujinx.UI.Common.Configuration;
|
|||||||
using Ryujinx.UI.Common.Helper;
|
using Ryujinx.UI.Common.Helper;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
using SPB.Graphics.Exceptions;
|
||||||
using SPB.Graphics.Vulkan;
|
using SPB.Graphics.Vulkan;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -654,8 +655,22 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
if (RendererHost.EmbeddedWindow is EmbeddedWindowOpenGL openGlWindow)
|
if (RendererHost.EmbeddedWindow is EmbeddedWindowOpenGL openGlWindow)
|
||||||
{
|
{
|
||||||
// Try to bind the OpenGL context before calling the shutdown event.
|
try
|
||||||
openGlWindow.MakeCurrent(false, false);
|
{
|
||||||
|
// Try to bind the OpenGL context before disposing GPU resources.
|
||||||
|
openGlWindow.MakeCurrent();
|
||||||
|
}
|
||||||
|
catch (ContextException e) when (_userChannelPersistence.ShouldRestart)
|
||||||
|
{
|
||||||
|
// ExecuteProgram may detach the old native window before GPU
|
||||||
|
// disposal. Allow the old context to be released with the window
|
||||||
|
// and continue the requested program relaunch.
|
||||||
|
Logger.Warning?.Print(
|
||||||
|
LogClass.UI,
|
||||||
|
$"Failed to bind OpenGL context during program relaunch: {e}");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Device.DisposeGpu();
|
Device.DisposeGpu();
|
||||||
|
|
||||||
@@ -1075,9 +1090,10 @@ namespace Ryujinx.Ava
|
|||||||
{
|
{
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
if (_viewModel.StartGamesInFullscreen)
|
if (_viewModel.StartGamesInFullscreen && _viewModel.WindowState is not WindowState.FullScreen)
|
||||||
{
|
{
|
||||||
_viewModel.WindowState = WindowState.FullScreen;
|
// Use the view model toggle so decoration ordering matches user toggles.
|
||||||
|
_viewModel.ToggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_viewModel.WindowState == WindowState.FullScreen || _viewModel.StartGamesWithoutUI)
|
if (_viewModel.WindowState == WindowState.FullScreen || _viewModel.StartGamesWithoutUI)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ using Ryujinx.Ava.Common.Locale;
|
|||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.UI.Common.Models;
|
using Ryujinx.UI.Common.Models;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Windows
|
namespace Ryujinx.Ava.UI.Windows
|
||||||
@@ -81,20 +83,17 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
|
|
||||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (object content in e.AddedItems)
|
List<XCITrimmerFileModel> added = [.. e.AddedItems.OfType<XCITrimmerFileModel>()];
|
||||||
|
List<XCITrimmerFileModel> removed = [.. e.RemovedItems.OfType<XCITrimmerFileModel>()];
|
||||||
|
|
||||||
|
foreach (XCITrimmerFileModel applicationData in added)
|
||||||
{
|
{
|
||||||
if (content is XCITrimmerFileModel applicationData)
|
ViewModel.Select(applicationData);
|
||||||
{
|
|
||||||
ViewModel.Select(applicationData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (object content in e.RemovedItems)
|
foreach (XCITrimmerFileModel applicationData in removed)
|
||||||
{
|
{
|
||||||
if (content is XCITrimmerFileModel applicationData)
|
ViewModel.Deselect(applicationData);
|
||||||
{
|
|
||||||
ViewModel.Deselect(applicationData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user