Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
332891b5ff | ||
|
7df4fcada7 | ||
|
d6698680be | ||
|
e5c9838b0b | ||
|
f8ec878796 | ||
|
9ff21f9ab6 | ||
|
aa021085cf | ||
|
1f5d881860 | ||
|
1f664100bd | ||
|
1f5e1ffa80 | ||
|
264438ff19 | ||
|
3b8ac1641a |
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
SCRIPT_DIR=$(dirname $(realpath $0))
|
SCRIPT_DIR=$(dirname "$(realpath "$0")")
|
||||||
RYUJINX_BIN="Ryujinx"
|
RYUJINX_BIN="Ryujinx"
|
||||||
|
|
||||||
if [ -f "$SCRIPT_DIR/Ryujinx.Ava" ]; then
|
if [ -f "$SCRIPT_DIR/Ryujinx.Ava" ]; then
|
||||||
|
@@ -233,8 +233,13 @@ namespace Ryujinx.Ava.Common
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IFileSystem ncaFileSystem = patchNca != null
|
bool sectionExistsInPatch = false;
|
||||||
? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
if (patchNca != null)
|
||||||
|
{
|
||||||
|
sectionExistsInPatch = patchNca.CanOpenSection(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
IFileSystem ncaFileSystem = sectionExistsInPatch ? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
||||||
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
|
||||||
FileSystemClient fsClient = _horizonClient.Fs;
|
FileSystemClient fsClient = _horizonClient.Fs;
|
||||||
|
@@ -103,50 +103,6 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</AvaloniaResource>
|
</AvaloniaResource>
|
||||||
<AvaloniaResource Include="Assets\Styles\Styles.xaml" />
|
<AvaloniaResource Include="Assets\Styles\Styles.xaml" />
|
||||||
|
|
||||||
<Compile Update="App.axaml.cs">
|
|
||||||
<DependentUpon>App.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Windows\MainWindow.axaml.cs">
|
|
||||||
<DependentUpon>MainWindow.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Windows\AboutWindow.axaml.cs">
|
|
||||||
<DependentUpon>AboutWindow.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Applet\ErrorAppletWindow.axaml.cs">
|
|
||||||
<DependentUpon>ProfileWindow.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Applet\SwkbdAppletWindow.axaml.cs">
|
|
||||||
<DependentUpon>ProfileWindow.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Controls\InputDialog.axaml.cs">
|
|
||||||
<DependentUpon>InputDialog.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Windows\ContentDialogOverlay.xaml.cs">
|
|
||||||
<DependentUpon>ContentDialogOverlay.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Ui\Controls\GameListView.axaml.cs">
|
|
||||||
<DependentUpon>GameListView.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="UI\Views\User\UserEditorView.axaml.cs">
|
|
||||||
<DependentUpon>UserEditor.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="UI\Views\User\UserRecovererView.axaml.cs">
|
|
||||||
<DependentUpon>UserRecoverer.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="UI\Views\User\UserSelectorView.axaml.cs">
|
|
||||||
<DependentUpon>UserSelector.axaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
80
src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml
Normal file
80
src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<MenuFlyout
|
||||||
|
x:Class="Ryujinx.Ava.UI.Controls.ApplicationContextMenu"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale">
|
||||||
|
<MenuItem
|
||||||
|
Click="ToggleFavorite_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuToggleFavorite}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuToggleFavoriteToolTip}" />
|
||||||
|
<Separator />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenUserSaveDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuOpenUserSaveDirectory}"
|
||||||
|
IsEnabled="{Binding OpenUserSaveDirectoryEnabled}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuOpenUserSaveDirectoryToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenDeviceSaveDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuOpenDeviceSaveDirectory}"
|
||||||
|
IsEnabled="{Binding OpenDeviceSaveDirectoryEnabled}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuOpenDeviceSaveDirectoryToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenBcatSaveDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuOpenBcatSaveDirectory}"
|
||||||
|
IsEnabled="{Binding OpenBcatSaveDirectoryEnabled}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuOpenBcatSaveDirectoryToolTip}" />
|
||||||
|
<Separator />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenTitleUpdateManager_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuManageTitleUpdates}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleUpdatesToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenDownloadableContentManager_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuManageDlc}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuManageDlcToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenCheatManager_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuManageCheat}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuManageCheatToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenModsDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuOpenModsDirectory}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuOpenModsDirectoryToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenSdModsDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuOpenSdModsDirectory}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuOpenSdModsDirectoryToolTip}" />
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="{locale:Locale GameListContextMenuCacheManagement}">
|
||||||
|
<MenuItem
|
||||||
|
Click="PurgePtcCache_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuCacheManagementPurgePptc}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementPurgePptcToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="PurgeShaderCache_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementPurgeShaderCacheToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenPtcDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuCacheManagementOpenPptcDirectory}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementOpenPptcDirectoryToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="OpenShaderCacheDirectory_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuCacheManagementOpenShaderCacheDirectory}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementOpenShaderCacheDirectoryToolTip}" />
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="{locale:Locale GameListContextMenuExtractData}">
|
||||||
|
<MenuItem
|
||||||
|
Click="ExtractApplicationExeFs_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuExtractDataExeFS}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataExeFSToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="ExtractApplicationRomFs_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuExtractDataRomFS}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="ExtractApplicationLogo_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
||||||
|
</MenuItem>
|
||||||
|
</MenuFlyout>
|
322
src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs
Normal file
322
src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
|
using Ryujinx.Ava.Common;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using Ryujinx.Ava.UI.Windows;
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Ryujinx.HLE.HOS;
|
||||||
|
using Ryujinx.Ui.Common.Helper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using Path = System.IO.Path;
|
||||||
|
using UserId = LibHac.Fs.UserId;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Controls
|
||||||
|
{
|
||||||
|
public class ApplicationContextMenu : MenuFlyout
|
||||||
|
{
|
||||||
|
public ApplicationContextMenu()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToggleFavorite_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite;
|
||||||
|
|
||||||
|
viewModel.ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.TitleId, appMetadata =>
|
||||||
|
{
|
||||||
|
appMetadata.Favorite = viewModel.SelectedApplication.Favorite;
|
||||||
|
});
|
||||||
|
|
||||||
|
viewModel.RefreshView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenUserSaveDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
if ((sender as MenuItem)?.DataContext is MainWindowViewModel viewModel)
|
||||||
|
{
|
||||||
|
OpenSaveDirectory(viewModel, SaveDataType.Account, userId: new UserId((ulong)viewModel.AccountManager.LastOpenedUser.UserId.High, (ulong)viewModel.AccountManager.LastOpenedUser.UserId.Low));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenDeviceSaveDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
OpenSaveDirectory(viewModel, SaveDataType.Device, userId: default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenBcatSaveDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
OpenSaveDirectory(viewModel, SaveDataType.Bcat, userId: default);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OpenSaveDirectory(MainWindowViewModel viewModel, SaveDataType saveDataType, UserId userId)
|
||||||
|
{
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
if (!ulong.TryParse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber))
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogRyujinxErrorMessage], LocaleManager.Instance[LocaleKeys.DialogInvalidTitleIdErrorMessage]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var saveDataFilter = SaveDataFilter.Make(titleIdNumber, saveDataType, userId, saveDataId: default, index: default);
|
||||||
|
|
||||||
|
ApplicationHelper.OpenSaveDir(in saveDataFilter, titleIdNumber, viewModel.SelectedApplication.ControlHolder, viewModel.SelectedApplication.TitleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void OpenTitleUpdateManager_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
await TitleUpdateWindow.Show(viewModel.VirtualFileSystem, ulong.Parse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber), viewModel.SelectedApplication.TitleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void OpenDownloadableContentManager_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
await DownloadableContentManagerWindow.Show(viewModel.VirtualFileSystem, ulong.Parse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber), viewModel.SelectedApplication.TitleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void OpenCheatManager_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
await new CheatWindow(viewModel.VirtualFileSystem, viewModel.SelectedApplication.TitleId, viewModel.SelectedApplication.TitleName).ShowDialog(viewModel.TopLevel as Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenModsDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
string modsBasePath = ModLoader.GetModsBasePath();
|
||||||
|
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, viewModel.SelectedApplication.TitleId);
|
||||||
|
|
||||||
|
OpenHelper.OpenFolder(titleModsPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenSdModsDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
string sdModsBasePath = ModLoader.GetSdModsBasePath();
|
||||||
|
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, viewModel.SelectedApplication.TitleId);
|
||||||
|
|
||||||
|
OpenHelper.OpenFolder(titleModsPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void PurgePtcCache_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||||
|
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionMessage, viewModel.SelectedApplication.TitleName),
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||||
|
|
||||||
|
if (result == UserResult.Yes)
|
||||||
|
{
|
||||||
|
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "cpu", "0"));
|
||||||
|
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "cpu", "1"));
|
||||||
|
|
||||||
|
List<FileInfo> cacheFiles = new();
|
||||||
|
|
||||||
|
if (mainDir.Exists)
|
||||||
|
{
|
||||||
|
cacheFiles.AddRange(mainDir.EnumerateFiles("*.cache"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backupDir.Exists)
|
||||||
|
{
|
||||||
|
cacheFiles.AddRange(backupDir.EnumerateFiles("*.cache"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cacheFiles.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (FileInfo file in cacheFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionErrorMessage, file.Name, ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void PurgeShaderCache_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||||
|
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogShaderDeletionMessage, viewModel.SelectedApplication.TitleName),
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||||
|
|
||||||
|
if (result == UserResult.Yes)
|
||||||
|
{
|
||||||
|
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "shader"));
|
||||||
|
|
||||||
|
List<DirectoryInfo> oldCacheDirectories = new();
|
||||||
|
List<FileInfo> newCacheFiles = new();
|
||||||
|
|
||||||
|
if (shaderCacheDir.Exists)
|
||||||
|
{
|
||||||
|
oldCacheDirectories.AddRange(shaderCacheDir.EnumerateDirectories("*"));
|
||||||
|
newCacheFiles.AddRange(shaderCacheDir.GetFiles("*.toc"));
|
||||||
|
newCacheFiles.AddRange(shaderCacheDir.GetFiles("*.data"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldCacheDirectories.Count > 0 || newCacheFiles.Count > 0))
|
||||||
|
{
|
||||||
|
foreach (DirectoryInfo directory in oldCacheDirectories)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
directory.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionErrorMessage, directory.Name, ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (FileInfo file in newCacheFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.ShaderCachePurgeError, file.Name, ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenPtcDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
string ptcDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "cpu");
|
||||||
|
string mainDir = Path.Combine(ptcDir, "0");
|
||||||
|
string backupDir = Path.Combine(ptcDir, "1");
|
||||||
|
|
||||||
|
if (!Directory.Exists(ptcDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(ptcDir);
|
||||||
|
Directory.CreateDirectory(mainDir);
|
||||||
|
Directory.CreateDirectory(backupDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenHelper.OpenFolder(ptcDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenShaderCacheDirectory_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "shader");
|
||||||
|
|
||||||
|
if (!Directory.Exists(shaderCacheDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(shaderCacheDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenHelper.OpenFolder(shaderCacheDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void ExtractApplicationExeFs_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
await ApplicationHelper.ExtractSection(NcaSectionType.Code, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void ExtractApplicationRomFs_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
await ApplicationHelper.ExtractSection(NcaSectionType.Data, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void ExtractApplicationLogo_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
|
if (viewModel?.SelectedApplication != null)
|
||||||
|
{
|
||||||
|
await ApplicationHelper.ExtractSection(NcaSectionType.Logo, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml
Normal file
102
src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="Ryujinx.Ava.UI.Controls.ApplicationGridView"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:controls="clr-namespace:Ryujinx.Ava.UI.Controls"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
||||||
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
d:DesignHeight="450"
|
||||||
|
d:DesignWidth="800"
|
||||||
|
Focusable="True"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
|
<controls:ApplicationContextMenu x:Key="ApplicationContextMenu" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ListBox
|
||||||
|
Grid.Row="0"
|
||||||
|
Padding="8"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
ContextFlyout="{StaticResource ApplicationContextMenu}"
|
||||||
|
DoubleTapped="GameList_DoubleTapped"
|
||||||
|
Items="{Binding AppsObservableList}"
|
||||||
|
SelectionChanged="GameList_SelectionChanged">
|
||||||
|
<ListBox.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<flex:FlexPanel
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
AlignContent="FlexStart"
|
||||||
|
JustifyContent="Center" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ListBox.ItemsPanel>
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="Margin" Value="5" />
|
||||||
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBoxItem:selected /template/ Border#SelectionIndicator">
|
||||||
|
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].DataContext.GridItemSelectorSize}" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid>
|
||||||
|
<Border
|
||||||
|
Margin="10"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Classes.huge="{Binding $parent[UserControl].DataContext.IsGridHuge}"
|
||||||
|
Classes.large="{Binding $parent[UserControl].DataContext.IsGridLarge}"
|
||||||
|
Classes.normal="{Binding $parent[UserControl].DataContext.IsGridMedium}"
|
||||||
|
Classes.small="{Binding $parent[UserControl].DataContext.IsGridSmall}"
|
||||||
|
ClipToBounds="True"
|
||||||
|
CornerRadius="4">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Image
|
||||||
|
Grid.Row="0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Source="{Binding Icon, Converter={StaticResource ByteImage}}" />
|
||||||
|
<Panel
|
||||||
|
Grid.Row="1"
|
||||||
|
Height="50"
|
||||||
|
Margin="0,10,0,0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
IsVisible="{Binding $parent[UserControl].DataContext.ShowNames}">
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding TitleName}"
|
||||||
|
TextAlignment="Center"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
</Panel>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<ui:SymbolIcon
|
||||||
|
Margin="5,5,0,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
FontSize="16"
|
||||||
|
Foreground="{DynamicResource SystemAccentColor}"
|
||||||
|
IsVisible="{Binding Favorite}"
|
||||||
|
Symbol="StarFilled" />
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
@@ -9,10 +9,10 @@ using System;
|
|||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
namespace Ryujinx.Ava.UI.Controls
|
||||||
{
|
{
|
||||||
public partial class GameGridView : UserControl
|
public partial class ApplicationGridView : UserControl
|
||||||
{
|
{
|
||||||
public static readonly RoutedEvent<ApplicationOpenedEventArgs> ApplicationOpenedEvent =
|
public static readonly RoutedEvent<ApplicationOpenedEventArgs> ApplicationOpenedEvent =
|
||||||
RoutedEvent.Register<GameGridView, ApplicationOpenedEventArgs>(nameof(ApplicationOpened), RoutingStrategies.Bubble);
|
RoutedEvent.Register<ApplicationGridView, ApplicationOpenedEventArgs>(nameof(ApplicationOpened), RoutingStrategies.Bubble);
|
||||||
|
|
||||||
public event EventHandler<ApplicationOpenedEventArgs> ApplicationOpened
|
public event EventHandler<ApplicationOpenedEventArgs> ApplicationOpened
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
remove { RemoveHandler(ApplicationOpenedEvent, value); }
|
remove { RemoveHandler(ApplicationOpenedEvent, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameGridView()
|
public ApplicationGridView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBox_OnKeyUp(object sender, KeyEventArgs e)
|
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
|
||||||
{
|
{
|
||||||
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
||||||
}
|
}
|
@@ -1,10 +1,10 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.GameListView"
|
x:Class="Ryujinx.Ava.UI.Controls.ApplicationListView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:controls="clr-namespace:Ryujinx.Ava.UI.Controls"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
@@ -13,82 +13,7 @@
|
|||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
<MenuFlyout x:Key="GameContextMenu">
|
<controls:ApplicationContextMenu x:Key="ApplicationContextMenu" />
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ToggleFavorite}"
|
|
||||||
Header="{locale:Locale GameListContextMenuToggleFavorite}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuToggleFavoriteToolTip}" />
|
|
||||||
<Separator />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenUserSaveDirectory}"
|
|
||||||
IsEnabled="{Binding EnabledUserSaveDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenUserSaveDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenUserSaveDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenDeviceSaveDirectory}"
|
|
||||||
IsEnabled="{Binding EnabledDeviceSaveDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenDeviceSaveDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenDeviceSaveDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenBcatSaveDirectory}"
|
|
||||||
IsEnabled="{Binding EnabledBcatSaveDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenBcatSaveDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenBcatSaveDirectoryToolTip}" />
|
|
||||||
<Separator />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenTitleUpdateManager}"
|
|
||||||
Header="{locale:Locale GameListContextMenuManageTitleUpdates}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleUpdatesToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenDownloadableContentManager}"
|
|
||||||
Header="{locale:Locale GameListContextMenuManageDlc}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageDlcToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenCheatManager}"
|
|
||||||
Header="{locale:Locale GameListContextMenuManageCheat}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageCheatToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenModsDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenModsDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenModsDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenSdModsDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenSdModsDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenSdModsDirectoryToolTip}" />
|
|
||||||
<Separator />
|
|
||||||
<MenuItem Header="{locale:Locale GameListContextMenuCacheManagement}">
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding PurgePtcCache}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementPurgePptc}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementPurgePptcToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding PurgeShaderCache}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementPurgeShaderCacheToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenPtcDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementOpenPptcDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementOpenPptcDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenShaderCacheDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementOpenShaderCacheDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementOpenShaderCacheDirectoryToolTip}" />
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="{locale:Locale GameListContextMenuExtractData}">
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ExtractExeFs}"
|
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataExeFS}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataExeFSToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ExtractRomFs}"
|
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataRomFS}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ExtractLogo}"
|
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
|
||||||
</MenuItem>
|
|
||||||
</MenuFlyout>
|
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -100,7 +25,7 @@
|
|||||||
Padding="8"
|
Padding="8"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
ContextFlyout="{StaticResource GameContextMenu}"
|
ContextFlyout="{StaticResource ApplicationContextMenu}"
|
||||||
DoubleTapped="GameList_DoubleTapped"
|
DoubleTapped="GameList_DoubleTapped"
|
||||||
Items="{Binding AppsObservableList}"
|
Items="{Binding AppsObservableList}"
|
||||||
SelectionChanged="GameList_SelectionChanged">
|
SelectionChanged="GameList_SelectionChanged">
|
@@ -9,10 +9,10 @@ using System;
|
|||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
namespace Ryujinx.Ava.UI.Controls
|
||||||
{
|
{
|
||||||
public partial class GameListView : UserControl
|
public partial class ApplicationListView : UserControl
|
||||||
{
|
{
|
||||||
public static readonly RoutedEvent<ApplicationOpenedEventArgs> ApplicationOpenedEvent =
|
public static readonly RoutedEvent<ApplicationOpenedEventArgs> ApplicationOpenedEvent =
|
||||||
RoutedEvent.Register<GameGridView, ApplicationOpenedEventArgs>(nameof(ApplicationOpened), RoutingStrategies.Bubble);
|
RoutedEvent.Register<ApplicationListView, ApplicationOpenedEventArgs>(nameof(ApplicationOpened), RoutingStrategies.Bubble);
|
||||||
|
|
||||||
public event EventHandler<ApplicationOpenedEventArgs> ApplicationOpened
|
public event EventHandler<ApplicationOpenedEventArgs> ApplicationOpened
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
remove { RemoveHandler(ApplicationOpenedEvent, value); }
|
remove { RemoveHandler(ApplicationOpenedEvent, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameListView()
|
public ApplicationListView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBox_OnKeyUp(object sender, KeyEventArgs e)
|
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
|
||||||
{
|
{
|
||||||
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
||||||
}
|
}
|
@@ -1,177 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.GameGridView"
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
|
||||||
d:DesignHeight="450"
|
|
||||||
d:DesignWidth="800"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Focusable="True">
|
|
||||||
<UserControl.Resources>
|
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
|
||||||
<MenuFlyout x:Key="GameContextMenu">
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ToggleFavorite}"
|
|
||||||
Header="{locale:Locale GameListContextMenuToggleFavorite}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuToggleFavoriteToolTip}" />
|
|
||||||
<Separator />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenUserSaveDirectory}"
|
|
||||||
IsEnabled="{Binding EnabledUserSaveDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenUserSaveDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenUserSaveDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenDeviceSaveDirectory}"
|
|
||||||
IsEnabled="{Binding EnabledDeviceSaveDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenDeviceSaveDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenDeviceSaveDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenBcatSaveDirectory}"
|
|
||||||
IsEnabled="{Binding EnabledBcatSaveDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenBcatSaveDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenBcatSaveDirectoryToolTip}" />
|
|
||||||
<Separator />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenTitleUpdateManager}"
|
|
||||||
Header="{locale:Locale GameListContextMenuManageTitleUpdates}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleUpdatesToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenDownloadableContentManager}"
|
|
||||||
Header="{locale:Locale GameListContextMenuManageDlc}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageDlcToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenCheatManager}"
|
|
||||||
Header="{locale:Locale GameListContextMenuManageCheat}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageCheatToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenModsDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenModsDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenModsDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenSdModsDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuOpenSdModsDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenSdModsDirectoryToolTip}" />
|
|
||||||
<Separator />
|
|
||||||
<MenuItem Header="{locale:Locale GameListContextMenuCacheManagement}">
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding PurgePtcCache}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementPurgePptc}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementPurgePptcToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding PurgeShaderCache}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementPurgeShaderCacheToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenPtcDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementOpenPptcDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementOpenPptcDirectoryToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding OpenShaderCacheDirectory}"
|
|
||||||
Header="{locale:Locale GameListContextMenuCacheManagementOpenShaderCacheDirectory}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCacheManagementOpenShaderCacheDirectoryToolTip}" />
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="{locale:Locale GameListContextMenuExtractData}">
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ExtractExeFs}"
|
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataExeFS}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataExeFSToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ExtractRomFs}"
|
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataRomFS}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" />
|
|
||||||
<MenuItem
|
|
||||||
Command="{Binding ExtractLogo}"
|
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
|
||||||
</MenuItem>
|
|
||||||
</MenuFlyout>
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<ListBox
|
|
||||||
Grid.Row="0"
|
|
||||||
Padding="8"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
ContextFlyout="{StaticResource GameContextMenu}"
|
|
||||||
DoubleTapped="GameList_DoubleTapped"
|
|
||||||
Items="{Binding AppsObservableList}"
|
|
||||||
SelectionChanged="GameList_SelectionChanged">
|
|
||||||
<ListBox.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<flex:FlexPanel
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
AlignContent="FlexStart"
|
|
||||||
JustifyContent="Center" />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ListBox.ItemsPanel>
|
|
||||||
<ListBox.Styles>
|
|
||||||
<Style Selector="ListBoxItem">
|
|
||||||
<Setter Property="Margin" Value="5" />
|
|
||||||
<Setter Property="CornerRadius" Value="4" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem:selected /template/ Border#SelectionIndicator">
|
|
||||||
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].DataContext.GridItemSelectorSize}" />
|
|
||||||
</Style>
|
|
||||||
</ListBox.Styles>
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Grid>
|
|
||||||
<Border
|
|
||||||
Margin="10"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Classes.huge="{Binding $parent[UserControl].DataContext.IsGridHuge}"
|
|
||||||
Classes.large="{Binding $parent[UserControl].DataContext.IsGridLarge}"
|
|
||||||
Classes.normal="{Binding $parent[UserControl].DataContext.IsGridMedium}"
|
|
||||||
Classes.small="{Binding $parent[UserControl].DataContext.IsGridSmall}"
|
|
||||||
ClipToBounds="True"
|
|
||||||
CornerRadius="4">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Image
|
|
||||||
Grid.Row="0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Source="{Binding Icon, Converter={StaticResource ByteImage}}" />
|
|
||||||
<Panel
|
|
||||||
Grid.Row="1"
|
|
||||||
Height="50"
|
|
||||||
Margin="0 10 0 0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
IsVisible="{Binding $parent[UserControl].DataContext.ShowNames}">
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding TitleName}"
|
|
||||||
TextAlignment="Center"
|
|
||||||
TextWrapping="Wrap" />
|
|
||||||
</Panel>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
<ui:SymbolIcon
|
|
||||||
Margin="5,5,0,0"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
FontSize="16"
|
|
||||||
Foreground="{DynamicResource SystemAccentColor}"
|
|
||||||
IsVisible="{Binding Favorite}"
|
|
||||||
Symbol="StarFilled" />
|
|
||||||
</Grid>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
@@ -6,8 +6,6 @@ using Avalonia.Threading;
|
|||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
|
||||||
using Ryujinx.Ava.Common;
|
using Ryujinx.Ava.Common;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.Input;
|
using Ryujinx.Ava.Input;
|
||||||
@@ -33,13 +31,11 @@ using SixLabors.ImageSharp.PixelFormats;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Path = System.IO.Path;
|
using Path = System.IO.Path;
|
||||||
using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
|
using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
|
||||||
using UserId = LibHac.Fs.UserId;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
@@ -346,11 +342,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnabledUserSaveDirectory => !Utilities.IsZeros(SelectedApplication.ControlHolder.ByteSpan) && SelectedApplication.ControlHolder.Value.UserAccountSaveDataSize > 0;
|
public bool OpenUserSaveDirectoryEnabled => !Utilities.IsZeros(SelectedApplication.ControlHolder.ByteSpan) && SelectedApplication.ControlHolder.Value.UserAccountSaveDataSize > 0;
|
||||||
|
|
||||||
public bool EnabledDeviceSaveDirectory => !Utilities.IsZeros(SelectedApplication.ControlHolder.ByteSpan) && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0;
|
public bool OpenDeviceSaveDirectoryEnabled => !Utilities.IsZeros(SelectedApplication.ControlHolder.ByteSpan) && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0;
|
||||||
|
|
||||||
public bool EnabledBcatSaveDirectory => !Utilities.IsZeros(SelectedApplication.ControlHolder.ByteSpan) && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
|
public bool OpenBcatSaveDirectoryEnabled => !Utilities.IsZeros(SelectedApplication.ControlHolder.ByteSpan) && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
|
||||||
|
|
||||||
public string LoadHeading
|
public string LoadHeading
|
||||||
{
|
{
|
||||||
@@ -941,7 +937,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshView()
|
public void RefreshView()
|
||||||
{
|
{
|
||||||
RefreshGrid();
|
RefreshGrid();
|
||||||
}
|
}
|
||||||
@@ -1116,30 +1112,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ExtractLogo()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
await ApplicationHelper.ExtractSection(NcaSectionType.Logo, SelectedApplication.Path, SelectedApplication.TitleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ExtractRomFs()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
await ApplicationHelper.ExtractSection(NcaSectionType.Data, SelectedApplication.Path, SelectedApplication.TitleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ExtractExeFs()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
await ApplicationHelper.ExtractSection(NcaSectionType.Code, SelectedApplication.Path, SelectedApplication.TitleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PrepareLoadScreen()
|
private void PrepareLoadScreen()
|
||||||
{
|
{
|
||||||
using MemoryStream stream = new(SelectedIcon);
|
using MemoryStream stream = new(SelectedIcon);
|
||||||
@@ -1383,241 +1355,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient);
|
await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenPtcDirectory()
|
|
||||||
{
|
|
||||||
ApplicationData selection = SelectedApplication;
|
|
||||||
if (selection != null)
|
|
||||||
{
|
|
||||||
string ptcDir = Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "cpu");
|
|
||||||
string mainPath = Path.Combine(ptcDir, "0");
|
|
||||||
string backupPath = Path.Combine(ptcDir, "1");
|
|
||||||
|
|
||||||
if (!Directory.Exists(ptcDir))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ptcDir);
|
|
||||||
Directory.CreateDirectory(mainPath);
|
|
||||||
Directory.CreateDirectory(backupPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenHelper.OpenFolder(ptcDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void PurgePtcCache()
|
|
||||||
{
|
|
||||||
ApplicationData selection = SelectedApplication;
|
|
||||||
if (selection != null)
|
|
||||||
{
|
|
||||||
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "cpu", "0"));
|
|
||||||
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "cpu", "1"));
|
|
||||||
|
|
||||||
// FIXME: Found a way to reproduce the bold effect on the title name (fork?).
|
|
||||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
|
||||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionMessage, selection.TitleName),
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
||||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
|
||||||
|
|
||||||
List<FileInfo> cacheFiles = new();
|
|
||||||
|
|
||||||
if (mainDir.Exists)
|
|
||||||
{
|
|
||||||
cacheFiles.AddRange(mainDir.EnumerateFiles("*.cache"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backupDir.Exists)
|
|
||||||
{
|
|
||||||
cacheFiles.AddRange(backupDir.EnumerateFiles("*.cache"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cacheFiles.Count > 0 && result == UserResult.Yes)
|
|
||||||
{
|
|
||||||
foreach (FileInfo file in cacheFiles)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionErrorMessage, file.Name, e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenShaderCacheDirectory()
|
|
||||||
{
|
|
||||||
ApplicationData selection = SelectedApplication;
|
|
||||||
if (selection != null)
|
|
||||||
{
|
|
||||||
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "shader");
|
|
||||||
|
|
||||||
if (!Directory.Exists(shaderCacheDir))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(shaderCacheDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenHelper.OpenFolder(shaderCacheDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SimulateWakeUpMessage()
|
public void SimulateWakeUpMessage()
|
||||||
{
|
{
|
||||||
AppHost.Device.System.SimulateWakeUpMessage();
|
AppHost.Device.System.SimulateWakeUpMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void PurgeShaderCache()
|
|
||||||
{
|
|
||||||
ApplicationData selection = SelectedApplication;
|
|
||||||
if (selection != null)
|
|
||||||
{
|
|
||||||
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "shader"));
|
|
||||||
|
|
||||||
// FIXME: Found a way to reproduce the bold effect on the title name (fork?).
|
|
||||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
|
||||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogShaderDeletionMessage, selection.TitleName),
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
||||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
|
||||||
|
|
||||||
List<DirectoryInfo> oldCacheDirectories = new();
|
|
||||||
List<FileInfo> newCacheFiles = new();
|
|
||||||
|
|
||||||
if (shaderCacheDir.Exists)
|
|
||||||
{
|
|
||||||
oldCacheDirectories.AddRange(shaderCacheDir.EnumerateDirectories("*"));
|
|
||||||
newCacheFiles.AddRange(shaderCacheDir.GetFiles("*.toc"));
|
|
||||||
newCacheFiles.AddRange(shaderCacheDir.GetFiles("*.data"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((oldCacheDirectories.Count > 0 || newCacheFiles.Count > 0) && result == UserResult.Yes)
|
|
||||||
{
|
|
||||||
foreach (DirectoryInfo directory in oldCacheDirectories)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
directory.Delete(true);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionErrorMessage, directory.Name, e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (FileInfo file in newCacheFiles)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.ShaderCachePurgeError, file.Name, e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ToggleFavorite()
|
|
||||||
{
|
|
||||||
ApplicationData selection = SelectedApplication;
|
|
||||||
if (selection != null)
|
|
||||||
{
|
|
||||||
selection.Favorite = !selection.Favorite;
|
|
||||||
|
|
||||||
ApplicationLibrary.LoadAndSaveMetaData(selection.TitleId, appMetadata =>
|
|
||||||
{
|
|
||||||
appMetadata.Favorite = selection.Favorite;
|
|
||||||
});
|
|
||||||
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenUserSaveDirectory()
|
|
||||||
{
|
|
||||||
OpenSaveDirectory(SaveDataType.Account, userId: new UserId((ulong)AccountManager.LastOpenedUser.UserId.High, (ulong)AccountManager.LastOpenedUser.UserId.Low));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenDeviceSaveDirectory()
|
|
||||||
{
|
|
||||||
OpenSaveDirectory(SaveDataType.Device, userId: default);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenBcatSaveDirectory()
|
|
||||||
{
|
|
||||||
OpenSaveDirectory(SaveDataType.Bcat, userId: default);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenSaveDirectory(SaveDataType saveDataType, UserId userId)
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
if (!ulong.TryParse(SelectedApplication.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber))
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
|
||||||
{
|
|
||||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogRyujinxErrorMessage], LocaleManager.Instance[LocaleKeys.DialogInvalidTitleIdErrorMessage]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var saveDataFilter = SaveDataFilter.Make(titleIdNumber, saveDataType, userId, saveDataId: default, index: default);
|
|
||||||
|
|
||||||
ApplicationHelper.OpenSaveDir(in saveDataFilter, titleIdNumber, SelectedApplication.ControlHolder, SelectedApplication.TitleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenModsDirectory()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
string modsBasePath = VirtualFileSystem.ModLoader.GetModsBasePath();
|
|
||||||
string titleModsPath = VirtualFileSystem.ModLoader.GetTitleDir(modsBasePath, SelectedApplication.TitleId);
|
|
||||||
|
|
||||||
OpenHelper.OpenFolder(titleModsPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenSdModsDirectory()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
string sdModsBasePath = VirtualFileSystem.ModLoader.GetSdModsBasePath();
|
|
||||||
string titleModsPath = VirtualFileSystem.ModLoader.GetTitleDir(sdModsBasePath, SelectedApplication.TitleId);
|
|
||||||
|
|
||||||
OpenHelper.OpenFolder(titleModsPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void OpenTitleUpdateManager()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
await TitleUpdateWindow.Show(VirtualFileSystem, ulong.Parse(SelectedApplication.TitleId, NumberStyles.HexNumber), SelectedApplication.TitleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void OpenDownloadableContentManager()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
await DownloadableContentManagerWindow.Show(VirtualFileSystem, ulong.Parse(SelectedApplication.TitleId, NumberStyles.HexNumber), SelectedApplication.TitleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void OpenCheatManager()
|
|
||||||
{
|
|
||||||
if (SelectedApplication != null)
|
|
||||||
{
|
|
||||||
await new CheatWindow(VirtualFileSystem, SelectedApplication.TitleId, SelectedApplication.TitleName).ShowDialog(TopLevel as Window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void LoadApplications()
|
public async void LoadApplications()
|
||||||
{
|
{
|
||||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
@@ -35,8 +35,8 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
string modsBasePath = virtualFileSystem.ModLoader.GetModsBasePath();
|
string modsBasePath = ModLoader.GetModsBasePath();
|
||||||
string titleModsPath = virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, titleId);
|
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId);
|
||||||
ulong titleIdValue = ulong.Parse(titleId, System.Globalization.NumberStyles.HexNumber);
|
ulong titleIdValue = ulong.Parse(titleId, System.Globalization.NumberStyles.HexNumber);
|
||||||
|
|
||||||
_enabledCheatsPath = Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
_enabledCheatsPath = Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
||||||
|
@@ -88,16 +88,16 @@
|
|||||||
<main:MainViewControls
|
<main:MainViewControls
|
||||||
Name="ViewControls"
|
Name="ViewControls"
|
||||||
Grid.Row="0"/>
|
Grid.Row="0"/>
|
||||||
<controls:GameListView
|
<controls:ApplicationListView
|
||||||
x:Name="GameList"
|
x:Name="ApplicationList"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
VerticalContentAlignment="Stretch"
|
VerticalContentAlignment="Stretch"
|
||||||
IsVisible="{Binding IsList}" />
|
IsVisible="{Binding IsList}" />
|
||||||
<controls:GameGridView
|
<controls:ApplicationGridView
|
||||||
x:Name="GameGrid"
|
x:Name="ApplicationGrid"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
@@ -288,13 +288,13 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
{
|
{
|
||||||
StatusBarView.VolumeStatus.Click += VolumeStatus_CheckedChanged;
|
StatusBarView.VolumeStatus.Click += VolumeStatus_CheckedChanged;
|
||||||
|
|
||||||
GameGrid.ApplicationOpened += Application_Opened;
|
ApplicationGrid.ApplicationOpened += Application_Opened;
|
||||||
|
|
||||||
GameGrid.DataContext = ViewModel;
|
ApplicationGrid.DataContext = ViewModel;
|
||||||
|
|
||||||
GameList.ApplicationOpened += Application_Opened;
|
ApplicationList.ApplicationOpened += Application_Opened;
|
||||||
|
|
||||||
GameList.DataContext = ViewModel;
|
ApplicationList.DataContext = ViewModel;
|
||||||
|
|
||||||
LoadHotKeys();
|
LoadHotKeys();
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
using Ryujinx.Memory.Tracking;
|
using Ryujinx.Memory.Tracking;
|
||||||
@@ -822,21 +821,21 @@ namespace Ryujinx.Cpu.AppleHv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuRegionHandle BeginTracking(ulong address, ulong size, int id)
|
public RegionHandle BeginTracking(ulong address, ulong size, int id)
|
||||||
{
|
{
|
||||||
return new CpuRegionHandle(Tracking.BeginTracking(address, size, id));
|
return Tracking.BeginTracking(address, size, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
|
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
|
||||||
{
|
{
|
||||||
return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id));
|
return Tracking.BeginGranularTracking(address, size, handles, granularity, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
||||||
{
|
{
|
||||||
return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id));
|
return Tracking.BeginSmartGranularTracking(address, size, granularity, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Ryujinx.Cpu.Tracking;
|
using Ryujinx.Memory;
|
||||||
using Ryujinx.Memory;
|
|
||||||
using Ryujinx.Memory.Tracking;
|
using Ryujinx.Memory.Tracking;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -30,7 +29,7 @@ namespace Ryujinx.Cpu
|
|||||||
/// <param name="size">Size of the region</param>
|
/// <param name="size">Size of the region</param>
|
||||||
/// <param name="id">Handle ID</param>
|
/// <param name="id">Handle ID</param>
|
||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
CpuRegionHandle BeginTracking(ulong address, ulong size, int id);
|
RegionHandle BeginTracking(ulong address, ulong size, int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Obtains a memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with.
|
/// Obtains a memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with.
|
||||||
@@ -41,7 +40,7 @@ namespace Ryujinx.Cpu
|
|||||||
/// <param name="granularity">Desired granularity of write tracking</param>
|
/// <param name="granularity">Desired granularity of write tracking</param>
|
||||||
/// <param name="id">Handle ID</param>
|
/// <param name="id">Handle ID</param>
|
||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id);
|
MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Obtains a smart memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with.
|
/// Obtains a smart memory tracking handle for the given virtual region, with a specified granularity. This should be disposed when finished with.
|
||||||
@@ -51,6 +50,6 @@ namespace Ryujinx.Cpu
|
|||||||
/// <param name="granularity">Desired granularity of write tracking</param>
|
/// <param name="granularity">Desired granularity of write tracking</param>
|
||||||
/// <param name="id">Handle ID</param>
|
/// <param name="id">Handle ID</param>
|
||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id);
|
SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
using Ryujinx.Memory.Tracking;
|
using Ryujinx.Memory.Tracking;
|
||||||
@@ -629,21 +628,21 @@ namespace Ryujinx.Cpu.Jit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuRegionHandle BeginTracking(ulong address, ulong size, int id)
|
public RegionHandle BeginTracking(ulong address, ulong size, int id)
|
||||||
{
|
{
|
||||||
return new CpuRegionHandle(Tracking.BeginTracking(address, size, id));
|
return Tracking.BeginTracking(address, size, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
|
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
|
||||||
{
|
{
|
||||||
return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id));
|
return Tracking.BeginGranularTracking(address, size, handles, granularity, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
||||||
{
|
{
|
||||||
return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id));
|
return Tracking.BeginSmartGranularTracking(address, size, granularity, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
using Ryujinx.Memory.Tracking;
|
using Ryujinx.Memory.Tracking;
|
||||||
@@ -706,21 +705,21 @@ namespace Ryujinx.Cpu.Jit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuRegionHandle BeginTracking(ulong address, ulong size, int id)
|
public RegionHandle BeginTracking(ulong address, ulong size, int id)
|
||||||
{
|
{
|
||||||
return new CpuRegionHandle(Tracking.BeginTracking(address, size, id));
|
return Tracking.BeginTracking(address, size, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
|
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id)
|
||||||
{
|
{
|
||||||
return new CpuMultiRegionHandle(Tracking.BeginGranularTracking(address, size, handles, granularity, id));
|
return Tracking.BeginGranularTracking(address, size, handles, granularity, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
||||||
{
|
{
|
||||||
return new CpuSmartMultiRegionHandle(Tracking.BeginSmartGranularTracking(address, size, granularity, id));
|
return Tracking.BeginSmartGranularTracking(address, size, granularity, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
using Ryujinx.Memory.Tracking;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Ryujinx.Cpu.Tracking
|
|
||||||
{
|
|
||||||
public class CpuMultiRegionHandle : IMultiRegionHandle
|
|
||||||
{
|
|
||||||
private readonly MultiRegionHandle _impl;
|
|
||||||
|
|
||||||
public bool Dirty => _impl.Dirty;
|
|
||||||
|
|
||||||
internal CpuMultiRegionHandle(MultiRegionHandle impl)
|
|
||||||
{
|
|
||||||
_impl = impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() => _impl.Dispose();
|
|
||||||
public void ForceDirty(ulong address, ulong size) => _impl.ForceDirty(address, size);
|
|
||||||
public IEnumerable<IRegionHandle> GetHandles() => _impl.GetHandles();
|
|
||||||
public void QueryModified(Action<ulong, ulong> modifiedAction) => _impl.QueryModified(modifiedAction);
|
|
||||||
public void QueryModified(ulong address, ulong size, Action<ulong, ulong> modifiedAction) => _impl.QueryModified(address, size, modifiedAction);
|
|
||||||
public void QueryModified(ulong address, ulong size, Action<ulong, ulong> modifiedAction, int sequenceNumber) => _impl.QueryModified(address, size, modifiedAction, sequenceNumber);
|
|
||||||
public void RegisterAction(ulong address, ulong size, RegionSignal action) => _impl.RegisterAction(address, size, action);
|
|
||||||
public void RegisterPreciseAction(ulong address, ulong size, PreciseRegionSignal action) => _impl.RegisterPreciseAction(address, size, action);
|
|
||||||
public void SignalWrite() => _impl.SignalWrite();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
using Ryujinx.Memory.Tracking;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Cpu.Tracking
|
|
||||||
{
|
|
||||||
public class CpuRegionHandle : IRegionHandle
|
|
||||||
{
|
|
||||||
private readonly RegionHandle _impl;
|
|
||||||
|
|
||||||
public bool Dirty => _impl.Dirty;
|
|
||||||
public bool Unmapped => _impl.Unmapped;
|
|
||||||
public ulong Address => _impl.Address;
|
|
||||||
public ulong Size => _impl.Size;
|
|
||||||
public ulong EndAddress => _impl.EndAddress;
|
|
||||||
|
|
||||||
internal CpuRegionHandle(RegionHandle impl)
|
|
||||||
{
|
|
||||||
_impl = impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() => _impl.Dispose();
|
|
||||||
public bool DirtyOrVolatile() => _impl.DirtyOrVolatile();
|
|
||||||
public void ForceDirty() => _impl.ForceDirty();
|
|
||||||
public IRegionHandle GetHandle() => _impl;
|
|
||||||
public void RegisterAction(RegionSignal action) => _impl.RegisterAction(action);
|
|
||||||
public void RegisterPreciseAction(PreciseRegionSignal action) => _impl.RegisterPreciseAction(action);
|
|
||||||
public void RegisterDirtyEvent(Action action) => _impl.RegisterDirtyEvent(action);
|
|
||||||
public void Reprotect(bool asDirty = false) => _impl.Reprotect(asDirty);
|
|
||||||
|
|
||||||
public bool OverlapsWith(ulong address, ulong size) => _impl.OverlapsWith(address, size);
|
|
||||||
|
|
||||||
public bool RangeEquals(CpuRegionHandle other)
|
|
||||||
{
|
|
||||||
return _impl.RealAddress == other._impl.RealAddress && _impl.RealSize == other._impl.RealSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
using Ryujinx.Memory.Tracking;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Cpu.Tracking
|
|
||||||
{
|
|
||||||
public class CpuSmartMultiRegionHandle : IMultiRegionHandle
|
|
||||||
{
|
|
||||||
private readonly SmartMultiRegionHandle _impl;
|
|
||||||
|
|
||||||
public bool Dirty => _impl.Dirty;
|
|
||||||
|
|
||||||
internal CpuSmartMultiRegionHandle(SmartMultiRegionHandle impl)
|
|
||||||
{
|
|
||||||
_impl = impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() => _impl.Dispose();
|
|
||||||
public void ForceDirty(ulong address, ulong size) => _impl.ForceDirty(address, size);
|
|
||||||
public void RegisterAction(RegionSignal action) => _impl.RegisterAction(action);
|
|
||||||
public void RegisterPreciseAction(PreciseRegionSignal action) => _impl.RegisterPreciseAction(action);
|
|
||||||
public void QueryModified(Action<ulong, ulong> modifiedAction) => _impl.QueryModified(modifiedAction);
|
|
||||||
public void QueryModified(ulong address, ulong size, Action<ulong, ulong> modifiedAction) => _impl.QueryModified(address, size, modifiedAction);
|
|
||||||
public void QueryModified(ulong address, ulong size, Action<ulong, ulong> modifiedAction, int sequenceNumber) => _impl.QueryModified(address, size, modifiedAction, sequenceNumber);
|
|
||||||
public void SignalWrite() => _impl.SignalWrite();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -157,11 +157,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||||||
{
|
{
|
||||||
BufferDescriptor sb = info.SBuffers[index];
|
BufferDescriptor sb = info.SBuffers[index];
|
||||||
|
|
||||||
ulong sbDescAddress = _channel.BufferManager.GetComputeUniformBufferAddress(0);
|
ulong sbDescAddress = _channel.BufferManager.GetComputeUniformBufferAddress(sb.SbCbSlot);
|
||||||
|
sbDescAddress += (ulong)sb.SbCbOffset * 4;
|
||||||
int sbDescOffset = 0x310 + sb.Slot * 0x10;
|
|
||||||
|
|
||||||
sbDescAddress += (ulong)sbDescOffset;
|
|
||||||
|
|
||||||
SbDescriptor sbDescriptor = _channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
SbDescriptor sbDescriptor = _channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
||||||
|
|
||||||
|
@@ -351,11 +351,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
{
|
{
|
||||||
BufferDescriptor sb = info.SBuffers[index];
|
BufferDescriptor sb = info.SBuffers[index];
|
||||||
|
|
||||||
ulong sbDescAddress = _channel.BufferManager.GetGraphicsUniformBufferAddress(stage, 0);
|
ulong sbDescAddress = _channel.BufferManager.GetGraphicsUniformBufferAddress(stage, sb.SbCbSlot);
|
||||||
|
sbDescAddress += (ulong)sb.SbCbOffset * 4;
|
||||||
int sbDescOffset = 0x110 + stage * 0x100 + sb.Slot * 0x10;
|
|
||||||
|
|
||||||
sbDescAddress += (ulong)sbDescOffset;
|
|
||||||
|
|
||||||
SbDescriptor sbDescriptor = _channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
SbDescriptor sbDescriptor = _channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
|
using Ryujinx.Memory.Tracking;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong Size { get; }
|
public ulong Size { get; }
|
||||||
|
|
||||||
private readonly CpuMultiRegionHandle _memoryTracking;
|
private readonly MultiRegionHandle _memoryTracking;
|
||||||
private readonly Action<ulong, ulong> _modifiedDelegate;
|
private readonly Action<ulong, ulong> _modifiedDelegate;
|
||||||
|
|
||||||
private int _modifiedSequenceOffset;
|
private int _modifiedSequenceOffset;
|
||||||
|
@@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
if (hostTexture != null && texture.Target == Target.TextureBuffer)
|
if (hostTexture != null && texture.Target == Target.TextureBuffer)
|
||||||
{
|
{
|
||||||
// Ensure that the buffer texture is using the correct buffer as storage.
|
// Ensure that the buffer texture is using the correct buffer as storage.
|
||||||
// Buffers are frequently re-created to accomodate larger data, so we need to re-bind
|
// Buffers are frequently re-created to accommodate larger data, so we need to re-bind
|
||||||
// to ensure we're not using a old buffer that was already deleted.
|
// to ensure we're not using a old buffer that was already deleted.
|
||||||
_channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, texture.Range.GetSubRange(0).Address, texture.Size, bindingInfo, bindingInfo.Format, false);
|
_channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, texture.Range.GetSubRange(0).Address, texture.Size, bindingInfo, bindingInfo.Format, false);
|
||||||
|
|
||||||
@@ -666,7 +666,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
if (hostTexture != null && texture.Target == Target.TextureBuffer)
|
if (hostTexture != null && texture.Target == Target.TextureBuffer)
|
||||||
{
|
{
|
||||||
// Ensure that the buffer texture is using the correct buffer as storage.
|
// Ensure that the buffer texture is using the correct buffer as storage.
|
||||||
// Buffers are frequently re-created to accomodate larger data, so we need to re-bind
|
// Buffers are frequently re-created to accommodate larger data, so we need to re-bind
|
||||||
// to ensure we're not using a old buffer that was already deleted.
|
// to ensure we're not using a old buffer that was already deleted.
|
||||||
|
|
||||||
Format format = bindingInfo.Format;
|
Format format = bindingInfo.Format;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
using Ryujinx.Common.Memory;
|
using Ryujinx.Common.Memory;
|
||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
using Ryujinx.Graphics.Texture;
|
using Ryujinx.Graphics.Texture;
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
|
using Ryujinx.Memory.Tracking;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -255,7 +255,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
TextureGroupHandle group = _handles[baseHandle + i];
|
TextureGroupHandle group = _handles[baseHandle + i];
|
||||||
|
|
||||||
foreach (CpuRegionHandle handle in group.Handles)
|
foreach (RegionHandle handle in group.Handles)
|
||||||
{
|
{
|
||||||
if (handle.Dirty)
|
if (handle.Dirty)
|
||||||
{
|
{
|
||||||
@@ -296,7 +296,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
bool handleDirty = false;
|
bool handleDirty = false;
|
||||||
bool handleUnmapped = false;
|
bool handleUnmapped = false;
|
||||||
|
|
||||||
foreach (CpuRegionHandle handle in group.Handles)
|
foreach (RegionHandle handle in group.Handles)
|
||||||
{
|
{
|
||||||
if (handle.Dirty)
|
if (handle.Dirty)
|
||||||
{
|
{
|
||||||
@@ -703,7 +703,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <param name="group">The group to register an action for</param>
|
/// <param name="group">The group to register an action for</param>
|
||||||
public void RegisterAction(TextureGroupHandle group)
|
public void RegisterAction(TextureGroupHandle group)
|
||||||
{
|
{
|
||||||
foreach (CpuRegionHandle handle in group.Handles)
|
foreach (RegionHandle handle in group.Handles)
|
||||||
{
|
{
|
||||||
handle.RegisterAction((address, size) => FlushAction(group, address, size));
|
handle.RegisterAction((address, size) => FlushAction(group, address, size));
|
||||||
}
|
}
|
||||||
@@ -985,7 +985,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <param name="address">The start address of the tracked region</param>
|
/// <param name="address">The start address of the tracked region</param>
|
||||||
/// <param name="size">The size of the tracked region</param>
|
/// <param name="size">The size of the tracked region</param>
|
||||||
/// <returns>A CpuRegionHandle covering the given range</returns>
|
/// <returns>A CpuRegionHandle covering the given range</returns>
|
||||||
private CpuRegionHandle GenerateHandle(ulong address, ulong size)
|
private RegionHandle GenerateHandle(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
return _physicalMemory.BeginTracking(address, size, ResourceKind.Texture);
|
return _physicalMemory.BeginTracking(address, size, ResourceKind.Texture);
|
||||||
}
|
}
|
||||||
@@ -1005,7 +1005,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;
|
||||||
|
|
||||||
var result = new List<CpuRegionHandle>();
|
var result = new List<RegionHandle>();
|
||||||
|
|
||||||
for (int i = 0; i < TextureRange.Count; i++)
|
for (int i = 0; i < TextureRange.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -1050,7 +1050,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
views,
|
views,
|
||||||
result.ToArray());
|
result.ToArray());
|
||||||
|
|
||||||
foreach (CpuRegionHandle handle in result)
|
foreach (RegionHandle handle in result)
|
||||||
{
|
{
|
||||||
handle.RegisterDirtyEvent(() => DirtyAction(groupHandle));
|
handle.RegisterDirtyEvent(() => DirtyAction(groupHandle));
|
||||||
}
|
}
|
||||||
@@ -1248,7 +1248,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (CpuRegionHandle handle in groupHandle.Handles)
|
foreach (RegionHandle handle in groupHandle.Handles)
|
||||||
{
|
{
|
||||||
bool hasMatch = false;
|
bool hasMatch = false;
|
||||||
|
|
||||||
@@ -1270,7 +1270,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (CpuRegionHandle handle in groupHandle.Handles)
|
foreach (RegionHandle handle in groupHandle.Handles)
|
||||||
{
|
{
|
||||||
handle.Reprotect();
|
handle.Reprotect();
|
||||||
}
|
}
|
||||||
@@ -1303,7 +1303,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
if (!(_hasMipViews || _hasLayerViews))
|
if (!(_hasMipViews || _hasLayerViews))
|
||||||
{
|
{
|
||||||
// Single dirty region.
|
// Single dirty region.
|
||||||
var cpuRegionHandles = new CpuRegionHandle[TextureRange.Count];
|
var cpuRegionHandles = new RegionHandle[TextureRange.Count];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < TextureRange.Count; i++)
|
for (int i = 0; i < TextureRange.Count; i++)
|
||||||
@@ -1322,7 +1322,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
var groupHandle = new TextureGroupHandle(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles);
|
var groupHandle = new TextureGroupHandle(this, 0, Storage.Size, _views, 0, 0, 0, _allOffsets.Length, cpuRegionHandles);
|
||||||
|
|
||||||
foreach (CpuRegionHandle handle in cpuRegionHandles)
|
foreach (RegionHandle handle in cpuRegionHandles)
|
||||||
{
|
{
|
||||||
handle.RegisterDirtyEvent(() => DirtyAction(groupHandle));
|
handle.RegisterDirtyEvent(() => DirtyAction(groupHandle));
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
using Ryujinx.Cpu.Tracking;
|
using Ryujinx.Graphics.Gpu.Synchronization;
|
||||||
using Ryujinx.Graphics.Gpu.Synchronization;
|
using Ryujinx.Memory.Tracking;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The CPU memory tracking handles that cover this handle.
|
/// The CPU memory tracking handles that cover this handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CpuRegionHandle[] Handles { get; }
|
public RegionHandle[] Handles { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if a texture overlapping this handle has been modified. Is set false when the flush action is called.
|
/// True if a texture overlapping this handle has been modified. Is set false when the flush action is called.
|
||||||
@@ -127,7 +127,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
int firstLevel,
|
int firstLevel,
|
||||||
int baseSlice,
|
int baseSlice,
|
||||||
int sliceCount,
|
int sliceCount,
|
||||||
CpuRegionHandle[] handles)
|
RegionHandle[] handles)
|
||||||
{
|
{
|
||||||
_group = group;
|
_group = group;
|
||||||
_firstLayer = firstLayer;
|
_firstLayer = firstLayer;
|
||||||
@@ -642,7 +642,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
foreach (CpuRegionHandle handle in Handles)
|
foreach (RegionHandle handle in Handles)
|
||||||
{
|
{
|
||||||
handle.Dispose();
|
handle.Dispose();
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Gpu.Synchronization;
|
using Ryujinx.Graphics.Gpu.Synchronization;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
@@ -54,8 +53,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
private BufferModifiedRangeList _modifiedRanges = null;
|
private BufferModifiedRangeList _modifiedRanges = null;
|
||||||
|
|
||||||
private readonly CpuMultiRegionHandle _memoryTrackingGranular;
|
private readonly MultiRegionHandle _memoryTrackingGranular;
|
||||||
private readonly CpuRegionHandle _memoryTracking;
|
private readonly RegionHandle _memoryTracking;
|
||||||
|
|
||||||
private readonly RegionSignal _externalFlushDelegate;
|
private readonly RegionSignal _externalFlushDelegate;
|
||||||
private readonly Action<ulong, ulong> _loadDelegate;
|
private readonly Action<ulong, ulong> _loadDelegate;
|
||||||
@@ -68,6 +67,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
private int _referenceCount = 1;
|
private int _referenceCount = 1;
|
||||||
|
|
||||||
|
private ulong _dirtyStart = ulong.MaxValue;
|
||||||
|
private ulong _dirtyEnd = ulong.MaxValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the buffer.
|
/// Creates a new instance of the buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -99,7 +101,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Enumerable.Repeat(buffer._memoryTracking.GetHandle(), 1);
|
return Enumerable.Repeat(buffer._memoryTracking, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -221,6 +223,26 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
_sequenceNumber = _context.SequenceNumber;
|
_sequenceNumber = _context.SequenceNumber;
|
||||||
|
_dirtyStart = ulong.MaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_dirtyStart != ulong.MaxValue)
|
||||||
|
{
|
||||||
|
ulong end = address + size;
|
||||||
|
|
||||||
|
if (end > _dirtyStart && address < _dirtyEnd)
|
||||||
|
{
|
||||||
|
if (_modifiedRanges != null)
|
||||||
|
{
|
||||||
|
_modifiedRanges.ExcludeModifiedRegions(_dirtyStart, _dirtyEnd - _dirtyStart, _loadDelegate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadRegion(_dirtyStart, _dirtyEnd - _dirtyStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
_dirtyStart = ulong.MaxValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +313,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inherit modified ranges from another buffer.
|
/// Inherit modified and dirty ranges from another buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="from">The buffer to inherit from</param>
|
/// <param name="from">The buffer to inherit from</param>
|
||||||
public void InheritModifiedRanges(Buffer from)
|
public void InheritModifiedRanges(Buffer from)
|
||||||
@@ -320,6 +342,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
_modifiedRanges.InheritRanges(from._modifiedRanges, registerRangeAction);
|
_modifiedRanges.InheritRanges(from._modifiedRanges, registerRangeAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (from._dirtyStart != ulong.MaxValue)
|
||||||
|
{
|
||||||
|
ForceDirty(from._dirtyStart, from._dirtyEnd - from._dirtyStart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -338,6 +365,44 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clear the dirty range that overlaps with the given region.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Start address of the modified region</param>
|
||||||
|
/// <param name="size">Size of the modified region</param>
|
||||||
|
private void ClearDirty(ulong address, ulong size)
|
||||||
|
{
|
||||||
|
if (_dirtyStart != ulong.MaxValue)
|
||||||
|
{
|
||||||
|
ulong end = address + size;
|
||||||
|
|
||||||
|
if (end > _dirtyStart && address < _dirtyEnd)
|
||||||
|
{
|
||||||
|
if (address <= _dirtyStart)
|
||||||
|
{
|
||||||
|
// Cut off the start.
|
||||||
|
|
||||||
|
if (end < _dirtyEnd)
|
||||||
|
{
|
||||||
|
_dirtyStart = end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dirtyStart = ulong.MaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (end >= _dirtyEnd)
|
||||||
|
{
|
||||||
|
// Cut off the end.
|
||||||
|
|
||||||
|
_dirtyEnd = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If fully contained, do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicate that a region of the buffer was modified, and must be loaded from memory.
|
/// Indicate that a region of the buffer was modified, and must be loaded from memory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -357,6 +422,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
mSize = maxSize;
|
mSize = maxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClearDirty(mAddress, mSize);
|
||||||
|
|
||||||
if (_modifiedRanges != null)
|
if (_modifiedRanges != null)
|
||||||
{
|
{
|
||||||
_modifiedRanges.ExcludeModifiedRegions(mAddress, mSize, _loadDelegate);
|
_modifiedRanges.ExcludeModifiedRegions(mAddress, mSize, _loadDelegate);
|
||||||
@@ -380,14 +447,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Force a region of the buffer to be dirty. Avoids reprotection and nullifies sequence number check.
|
/// Force a region of the buffer to be dirty within the memory tracking. Avoids reprotection and nullifies sequence number check.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mAddress">Start address of the modified region</param>
|
/// <param name="mAddress">Start address of the modified region</param>
|
||||||
/// <param name="mSize">Size of the region to force dirty</param>
|
/// <param name="mSize">Size of the region to force dirty</param>
|
||||||
public void ForceDirty(ulong mAddress, ulong mSize)
|
private void ForceTrackingDirty(ulong mAddress, ulong mSize)
|
||||||
{
|
{
|
||||||
_modifiedRanges?.Clear(mAddress, mSize);
|
|
||||||
|
|
||||||
if (_useGranular)
|
if (_useGranular)
|
||||||
{
|
{
|
||||||
_memoryTrackingGranular.ForceDirty(mAddress, mSize);
|
_memoryTrackingGranular.ForceDirty(mAddress, mSize);
|
||||||
@@ -399,6 +464,39 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Force a region of the buffer to be dirty. Avoids reprotection and nullifies sequence number check.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mAddress">Start address of the modified region</param>
|
||||||
|
/// <param name="mSize">Size of the region to force dirty</param>
|
||||||
|
public void ForceDirty(ulong mAddress, ulong mSize)
|
||||||
|
{
|
||||||
|
_modifiedRanges?.Clear(mAddress, mSize);
|
||||||
|
|
||||||
|
ulong end = mAddress + mSize;
|
||||||
|
|
||||||
|
if (_dirtyStart == ulong.MaxValue)
|
||||||
|
{
|
||||||
|
_dirtyStart = mAddress;
|
||||||
|
_dirtyEnd = end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Is the new range more than a page away from the existing one?
|
||||||
|
|
||||||
|
if ((long)(mAddress - _dirtyEnd) >= (long)MemoryManager.PageSize ||
|
||||||
|
(long)(_dirtyStart - end) >= (long)MemoryManager.PageSize)
|
||||||
|
{
|
||||||
|
ForceTrackingDirty(mAddress, mSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dirtyStart = Math.Min(_dirtyStart, mAddress);
|
||||||
|
_dirtyEnd = Math.Max(_dirtyEnd, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs copy of all the buffer data from one buffer to another.
|
/// Performs copy of all the buffer data from one buffer to another.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Ryujinx.Cpu.Tracking;
|
using Ryujinx.Memory.Tracking;
|
||||||
using Ryujinx.Memory.Tracking;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Memory
|
namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
@@ -9,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class GpuRegionHandle : IRegionHandle
|
class GpuRegionHandle : IRegionHandle
|
||||||
{
|
{
|
||||||
private readonly CpuRegionHandle[] _cpuRegionHandles;
|
private readonly RegionHandle[] _cpuRegionHandles;
|
||||||
|
|
||||||
public bool Dirty
|
public bool Dirty
|
||||||
{
|
{
|
||||||
@@ -35,7 +34,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// Create a new GpuRegionHandle, made up of mulitple CpuRegionHandles.
|
/// Create a new GpuRegionHandle, made up of mulitple CpuRegionHandles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cpuRegionHandles">The CpuRegionHandles that make up this handle</param>
|
/// <param name="cpuRegionHandles">The CpuRegionHandles that make up this handle</param>
|
||||||
public GpuRegionHandle(CpuRegionHandle[] cpuRegionHandles)
|
public GpuRegionHandle(RegionHandle[] cpuRegionHandles)
|
||||||
{
|
{
|
||||||
_cpuRegionHandles = cpuRegionHandles;
|
_cpuRegionHandles = cpuRegionHandles;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Ryujinx.Cpu;
|
using Ryujinx.Cpu;
|
||||||
using Ryujinx.Cpu.Tracking;
|
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
using Ryujinx.Graphics.Gpu.Shader;
|
using Ryujinx.Graphics.Gpu.Shader;
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
@@ -348,7 +347,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="size">Size of the region</param>
|
/// <param name="size">Size of the region</param>
|
||||||
/// <param name="kind">Kind of the resource being tracked</param>
|
/// <param name="kind">Kind of the resource being tracked</param>
|
||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
public CpuRegionHandle BeginTracking(ulong address, ulong size, ResourceKind kind)
|
public RegionHandle BeginTracking(ulong address, ulong size, ResourceKind kind)
|
||||||
{
|
{
|
||||||
return _cpuMemory.BeginTracking(address, size, (int)kind);
|
return _cpuMemory.BeginTracking(address, size, (int)kind);
|
||||||
}
|
}
|
||||||
@@ -361,7 +360,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
public GpuRegionHandle BeginTracking(MultiRange range, ResourceKind kind)
|
public GpuRegionHandle BeginTracking(MultiRange range, ResourceKind kind)
|
||||||
{
|
{
|
||||||
var cpuRegionHandles = new CpuRegionHandle[range.Count];
|
var cpuRegionHandles = new RegionHandle[range.Count];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < range.Count; i++)
|
for (int i = 0; i < range.Count; i++)
|
||||||
@@ -390,7 +389,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="handles">Handles to inherit state from or reuse</param>
|
/// <param name="handles">Handles to inherit state from or reuse</param>
|
||||||
/// <param name="granularity">Desired granularity of write tracking</param>
|
/// <param name="granularity">Desired granularity of write tracking</param>
|
||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, ResourceKind kind, IEnumerable<IRegionHandle> handles = null, ulong granularity = 4096)
|
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, ResourceKind kind, IEnumerable<IRegionHandle> handles = null, ulong granularity = 4096)
|
||||||
{
|
{
|
||||||
return _cpuMemory.BeginGranularTracking(address, size, handles, granularity, (int)kind);
|
return _cpuMemory.BeginGranularTracking(address, size, handles, granularity, (int)kind);
|
||||||
}
|
}
|
||||||
@@ -403,7 +402,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="kind">Kind of the resource being tracked</param>
|
/// <param name="kind">Kind of the resource being tracked</param>
|
||||||
/// <param name="granularity">Desired granularity of write tracking</param>
|
/// <param name="granularity">Desired granularity of write tracking</param>
|
||||||
/// <returns>The memory tracking handle</returns>
|
/// <returns>The memory tracking handle</returns>
|
||||||
public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ResourceKind kind, ulong granularity = 4096)
|
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ResourceKind kind, ulong granularity = 4096)
|
||||||
{
|
{
|
||||||
return _cpuMemory.BeginSmartGranularTracking(address, size, granularity, (int)kind);
|
return _cpuMemory.BeginSmartGranularTracking(address, size, granularity, (int)kind);
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
private const ushort FileFormatVersionMajor = 1;
|
private const ushort FileFormatVersionMajor = 1;
|
||||||
private const ushort FileFormatVersionMinor = 2;
|
private const ushort FileFormatVersionMinor = 2;
|
||||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||||
private const uint CodeGenVersion = 4735;
|
private const uint CodeGenVersion = 4821;
|
||||||
|
|
||||||
private const string SharedTocFileName = "shared.toc";
|
private const string SharedTocFileName = "shared.toc";
|
||||||
private const string SharedDataFileName = "shared.data";
|
private const string SharedDataFileName = "shared.data";
|
||||||
|
@@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
|
|
||||||
private static GpuVendor GetGpuVendor()
|
private static GpuVendor GetGpuVendor()
|
||||||
{
|
{
|
||||||
string vendor = GL.GetString(StringName.Vendor).ToLower();
|
string vendor = GL.GetString(StringName.Vendor).ToLowerInvariant();
|
||||||
|
|
||||||
if (vendor == "nvidia corporation")
|
if (vendor == "nvidia corporation")
|
||||||
{
|
{
|
||||||
@@ -112,7 +112,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
}
|
}
|
||||||
else if (vendor == "intel")
|
else if (vendor == "intel")
|
||||||
{
|
{
|
||||||
string renderer = GL.GetString(StringName.Renderer).ToLower();
|
string renderer = GL.GetString(StringName.Renderer).ToLowerInvariant();
|
||||||
|
|
||||||
return renderer.Contains("mesa") ? GpuVendor.IntelUnix : GpuVendor.IntelWindows;
|
return renderer.Contains("mesa") ? GpuVendor.IntelUnix : GpuVendor.IntelWindows;
|
||||||
}
|
}
|
||||||
|
@@ -5,13 +5,27 @@ namespace Ryujinx.Graphics.Shader
|
|||||||
// New fields should be added to the end of the struct to keep disk shader cache compatibility.
|
// New fields should be added to the end of the struct to keep disk shader cache compatibility.
|
||||||
|
|
||||||
public readonly int Binding;
|
public readonly int Binding;
|
||||||
public readonly int Slot;
|
public readonly byte Slot;
|
||||||
|
public readonly byte SbCbSlot;
|
||||||
|
public readonly ushort SbCbOffset;
|
||||||
public BufferUsageFlags Flags;
|
public BufferUsageFlags Flags;
|
||||||
|
|
||||||
public BufferDescriptor(int binding, int slot)
|
public BufferDescriptor(int binding, int slot)
|
||||||
{
|
{
|
||||||
Binding = binding;
|
Binding = binding;
|
||||||
Slot = slot;
|
Slot = (byte)slot;
|
||||||
|
SbCbSlot = 0;
|
||||||
|
SbCbOffset = 0;
|
||||||
|
|
||||||
|
Flags = BufferUsageFlags.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferDescriptor(int binding, int slot, int sbCbSlot, int sbCbOffset)
|
||||||
|
{
|
||||||
|
Binding = binding;
|
||||||
|
Slot = (byte)slot;
|
||||||
|
SbCbSlot = (byte)sbCbSlot;
|
||||||
|
SbCbOffset = (ushort)sbCbOffset;
|
||||||
|
|
||||||
Flags = BufferUsageFlags.None;
|
Flags = BufferUsageFlags.None;
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Shader
|
|||||||
/// Flags that indicate how a buffer will be used in a shader.
|
/// Flags that indicate how a buffer will be used in a shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum BufferUsageFlags
|
public enum BufferUsageFlags : byte
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
||||||
|
@@ -16,6 +16,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
public const int UbeDescsSize = StorageDescSize * UbeMaxCount;
|
public const int UbeDescsSize = StorageDescSize * UbeMaxCount;
|
||||||
public const int UbeFirstCbuf = 8;
|
public const int UbeFirstCbuf = 8;
|
||||||
|
|
||||||
|
public const int DriverReservedCb = 0;
|
||||||
|
|
||||||
public static bool UsesGlobalMemory(Instruction inst, StorageKind storageKind)
|
public static bool UsesGlobalMemory(Instruction inst, StorageKind storageKind)
|
||||||
{
|
{
|
||||||
return (inst.IsAtomic() && storageKind == StorageKind.GlobalMemory) ||
|
return (inst.IsAtomic() && storageKind == StorageKind.GlobalMemory) ||
|
||||||
|
@@ -8,6 +8,20 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
{
|
{
|
||||||
static class GlobalToStorage
|
static class GlobalToStorage
|
||||||
{
|
{
|
||||||
|
private struct SearchResult
|
||||||
|
{
|
||||||
|
public static SearchResult NotFound => new SearchResult(-1, 0);
|
||||||
|
public bool Found => SbCbSlot != -1;
|
||||||
|
public int SbCbSlot { get; }
|
||||||
|
public int SbCbOffset { get; }
|
||||||
|
|
||||||
|
public SearchResult(int sbCbSlot, int sbCbOffset)
|
||||||
|
{
|
||||||
|
SbCbSlot = sbCbSlot;
|
||||||
|
SbCbOffset = sbCbOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void RunPass(BasicBlock block, ShaderConfig config, ref int sbUseMask, ref int ubeUseMask)
|
public static void RunPass(BasicBlock block, ShaderConfig config, ref int sbUseMask, ref int ubeUseMask)
|
||||||
{
|
{
|
||||||
int sbStart = GetStorageBaseCbOffset(config.Stage);
|
int sbStart = GetStorageBaseCbOffset(config.Stage);
|
||||||
@@ -49,30 +63,33 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
{
|
{
|
||||||
Operand source = operation.GetSource(0);
|
Operand source = operation.GetSource(0);
|
||||||
|
|
||||||
int storageIndex = SearchForStorageBase(block, source, sbStart, sbEnd);
|
var result = SearchForStorageBase(config, block, source);
|
||||||
|
if (!result.Found)
|
||||||
if (storageIndex >= 0)
|
|
||||||
{
|
{
|
||||||
// Storage buffers are implemented using global memory access.
|
continue;
|
||||||
// If we know from where the base address of the access is loaded,
|
|
||||||
// we can guess which storage buffer it is accessing.
|
|
||||||
// We can then replace the global memory access with a storage
|
|
||||||
// buffer access.
|
|
||||||
node = ReplaceGlobalWithStorage(block, node, config, storageIndex);
|
|
||||||
}
|
}
|
||||||
else if (config.Stage == ShaderStage.Compute && operation.Inst == Instruction.LoadGlobal)
|
|
||||||
|
if (config.Stage == ShaderStage.Compute &&
|
||||||
|
operation.Inst == Instruction.LoadGlobal &&
|
||||||
|
result.SbCbSlot == DriverReservedCb &&
|
||||||
|
result.SbCbOffset >= UbeBaseOffset &&
|
||||||
|
result.SbCbOffset < UbeBaseOffset + UbeDescsSize)
|
||||||
{
|
{
|
||||||
// Here we effectively try to replace a LDG instruction with LDC.
|
// Here we effectively try to replace a LDG instruction with LDC.
|
||||||
// The hardware only supports a limited amount of constant buffers
|
// The hardware only supports a limited amount of constant buffers
|
||||||
// so NVN "emulates" more constant buffers using global memory access.
|
// so NVN "emulates" more constant buffers using global memory access.
|
||||||
// Here we try to replace the global access back to a constant buffer
|
// Here we try to replace the global access back to a constant buffer
|
||||||
// load.
|
// load.
|
||||||
storageIndex = SearchForStorageBase(block, source, ubeStart, ubeStart + ubeEnd);
|
node = ReplaceLdgWithLdc(node, config, (result.SbCbOffset - UbeBaseOffset) / StorageDescSize);
|
||||||
|
|
||||||
if (storageIndex >= 0)
|
|
||||||
{
|
|
||||||
node = ReplaceLdgWithLdc(node, config, storageIndex);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Storage buffers are implemented using global memory access.
|
||||||
|
// If we know from where the base address of the access is loaded,
|
||||||
|
// we can guess which storage buffer it is accessing.
|
||||||
|
// We can then replace the global memory access with a storage
|
||||||
|
// buffer access.
|
||||||
|
node = ReplaceGlobalWithStorage(block, node, config, config.GetSbSlot((byte)result.SbCbSlot, (ushort)result.SbCbOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,12 +161,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
Operand addrLow,
|
Operand addrLow,
|
||||||
bool isStg16Or8)
|
bool isStg16Or8)
|
||||||
{
|
{
|
||||||
int baseAddressCbOffset = GetStorageCbOffset(config.Stage, storageIndex);
|
(int sbCbSlot, int sbCbOffset) = config.GetSbCbInfo(storageIndex);
|
||||||
|
|
||||||
bool storageAligned = !(config.GpuAccessor.QueryHasUnalignedStorageBuffer() || config.GpuAccessor.QueryHostStorageBufferOffsetAlignment() > Constants.StorageAlignment);
|
bool storageAligned = !(config.GpuAccessor.QueryHasUnalignedStorageBuffer() || config.GpuAccessor.QueryHostStorageBufferOffsetAlignment() > Constants.StorageAlignment);
|
||||||
|
|
||||||
(Operand byteOffset, int constantOffset) = storageAligned ?
|
(Operand byteOffset, int constantOffset) = storageAligned ?
|
||||||
GetStorageOffset(block, Utils.FindLastOperation(addrLow, block), baseAddressCbOffset) :
|
GetStorageOffset(block, Utils.FindLastOperation(addrLow, block), sbCbSlot, sbCbOffset) :
|
||||||
(null, 0);
|
(null, 0);
|
||||||
|
|
||||||
if (byteOffset != null)
|
if (byteOffset != null)
|
||||||
@@ -159,7 +176,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
|
|
||||||
if (byteOffset == null)
|
if (byteOffset == null)
|
||||||
{
|
{
|
||||||
Operand baseAddrLow = Cbuf(0, baseAddressCbOffset);
|
Operand baseAddrLow = Cbuf(sbCbSlot, sbCbOffset);
|
||||||
Operand baseAddrTrunc = Local();
|
Operand baseAddrTrunc = Local();
|
||||||
|
|
||||||
Operand alignMask = Const(-config.GpuAccessor.QueryHostStorageBufferOffsetAlignment());
|
Operand alignMask = Const(-config.GpuAccessor.QueryHostStorageBufferOffsetAlignment());
|
||||||
@@ -198,9 +215,9 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
return wordOffset;
|
return wordOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsCb0Offset(Operand operand, int offset)
|
private static bool IsCbOffset(Operand operand, int slot, int offset)
|
||||||
{
|
{
|
||||||
return operand.Type == OperandType.ConstantBuffer && operand.GetCbufSlot() == 0 && operand.GetCbufOffset() == offset;
|
return operand.Type == OperandType.ConstantBuffer && operand.GetCbufSlot() == slot && operand.GetCbufOffset() == offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReplaceAddressAlignment(LinkedList<INode> list, Operand address, Operand byteOffset, int constantOffset)
|
private static void ReplaceAddressAlignment(LinkedList<INode> list, Operand address, Operand byteOffset, int constantOffset)
|
||||||
@@ -244,9 +261,9 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (Operand, int) GetStorageOffset(BasicBlock block, Operand address, int baseAddressCbOffset)
|
private static (Operand, int) GetStorageOffset(BasicBlock block, Operand address, int cbSlot, int baseAddressCbOffset)
|
||||||
{
|
{
|
||||||
if (IsCb0Offset(address, baseAddressCbOffset))
|
if (IsCbOffset(address, cbSlot, baseAddressCbOffset))
|
||||||
{
|
{
|
||||||
// Direct offset: zero.
|
// Direct offset: zero.
|
||||||
return (Const(0), 0);
|
return (Const(0), 0);
|
||||||
@@ -256,7 +273,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
|
|
||||||
address = Utils.FindLastOperation(address, block);
|
address = Utils.FindLastOperation(address, block);
|
||||||
|
|
||||||
if (IsCb0Offset(address, baseAddressCbOffset))
|
if (IsCbOffset(address, cbSlot, baseAddressCbOffset))
|
||||||
{
|
{
|
||||||
// Only constant offset
|
// Only constant offset
|
||||||
return (Const(0), constantOffset);
|
return (Const(0), constantOffset);
|
||||||
@@ -270,11 +287,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
Operand src1 = offsetAdd.GetSource(0);
|
Operand src1 = offsetAdd.GetSource(0);
|
||||||
Operand src2 = Utils.FindLastOperation(offsetAdd.GetSource(1), block);
|
Operand src2 = Utils.FindLastOperation(offsetAdd.GetSource(1), block);
|
||||||
|
|
||||||
if (IsCb0Offset(src2, baseAddressCbOffset))
|
if (IsCbOffset(src2, cbSlot, baseAddressCbOffset))
|
||||||
{
|
{
|
||||||
return (src1, constantOffset);
|
return (src1, constantOffset);
|
||||||
}
|
}
|
||||||
else if (IsCb0Offset(src1, baseAddressCbOffset))
|
else if (IsCbOffset(src1, cbSlot, baseAddressCbOffset))
|
||||||
{
|
{
|
||||||
return (src2, constantOffset);
|
return (src2, constantOffset);
|
||||||
}
|
}
|
||||||
@@ -360,20 +377,20 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int SearchForStorageBase(BasicBlock block, Operand globalAddress, int sbStart, int sbEnd)
|
private static SearchResult SearchForStorageBase(ShaderConfig config, BasicBlock block, Operand globalAddress)
|
||||||
{
|
{
|
||||||
globalAddress = Utils.FindLastOperation(globalAddress, block);
|
globalAddress = Utils.FindLastOperation(globalAddress, block);
|
||||||
|
|
||||||
if (globalAddress.Type == OperandType.ConstantBuffer)
|
if (globalAddress.Type == OperandType.ConstantBuffer)
|
||||||
{
|
{
|
||||||
return GetStorageIndex(globalAddress, sbStart, sbEnd);
|
return GetStorageIndex(config, globalAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation operation = globalAddress.AsgOp as Operation;
|
Operation operation = globalAddress.AsgOp as Operation;
|
||||||
|
|
||||||
if (operation == null || operation.Inst != Instruction.Add)
|
if (operation == null || operation.Inst != Instruction.Add)
|
||||||
{
|
{
|
||||||
return -1;
|
return SearchResult.NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
Operand src1 = operation.GetSource(0);
|
Operand src1 = operation.GetSource(0);
|
||||||
@@ -382,34 +399,65 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
if ((src1.Type == OperandType.LocalVariable && src2.Type == OperandType.Constant) ||
|
if ((src1.Type == OperandType.LocalVariable && src2.Type == OperandType.Constant) ||
|
||||||
(src2.Type == OperandType.LocalVariable && src1.Type == OperandType.Constant))
|
(src2.Type == OperandType.LocalVariable && src1.Type == OperandType.Constant))
|
||||||
{
|
{
|
||||||
|
Operand baseAddr;
|
||||||
|
|
||||||
if (src1.Type == OperandType.LocalVariable)
|
if (src1.Type == OperandType.LocalVariable)
|
||||||
{
|
{
|
||||||
operation = Utils.FindLastOperation(src1, block).AsgOp as Operation;
|
baseAddr = Utils.FindLastOperation(src1, block);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation = Utils.FindLastOperation(src2, block).AsgOp as Operation;
|
baseAddr = Utils.FindLastOperation(src2, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var result = GetStorageIndex(config, baseAddr);
|
||||||
|
if (result.Found)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
operation = baseAddr.AsgOp as Operation;
|
||||||
|
|
||||||
if (operation == null || operation.Inst != Instruction.Add)
|
if (operation == null || operation.Inst != Instruction.Add)
|
||||||
{
|
{
|
||||||
return -1;
|
return SearchResult.NotFound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var selectedResult = SearchResult.NotFound;
|
||||||
|
|
||||||
for (int index = 0; index < operation.SourcesCount; index++)
|
for (int index = 0; index < operation.SourcesCount; index++)
|
||||||
{
|
{
|
||||||
Operand source = operation.GetSource(index);
|
Operand source = operation.GetSource(index);
|
||||||
|
|
||||||
int storageIndex = GetStorageIndex(source, sbStart, sbEnd);
|
var result = GetStorageIndex(config, source);
|
||||||
|
|
||||||
if (storageIndex != -1)
|
// If we already have a result, we give preference to the ones from
|
||||||
|
// the driver reserved constant buffer, as those are the ones that
|
||||||
|
// contains the base address.
|
||||||
|
if (result.Found && (!selectedResult.Found || result.SbCbSlot == GlobalMemory.DriverReservedCb))
|
||||||
{
|
{
|
||||||
return storageIndex;
|
selectedResult = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return selectedResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SearchResult GetStorageIndex(ShaderConfig config, Operand operand)
|
||||||
|
{
|
||||||
|
if (operand.Type == OperandType.ConstantBuffer)
|
||||||
|
{
|
||||||
|
int slot = operand.GetCbufSlot();
|
||||||
|
int offset = operand.GetCbufOffset();
|
||||||
|
|
||||||
|
if ((offset & 3) == 0)
|
||||||
|
{
|
||||||
|
return new SearchResult(slot, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SearchResult.NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetStorageIndex(Operand operand, int sbStart, int sbEnd)
|
private static int GetStorageIndex(Operand operand, int sbStart, int sbEnd)
|
||||||
|
@@ -68,7 +68,6 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConstantFolding.RunPass(operation);
|
ConstantFolding.RunPass(operation);
|
||||||
|
|
||||||
Simplification.RunPass(operation);
|
Simplification.RunPass(operation);
|
||||||
|
|
||||||
if (DestIsLocalVar(operation))
|
if (DestIsLocalVar(operation))
|
||||||
|
@@ -110,9 +110,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
Operand BindingRangeCheck(int cbOffset, out Operand baseAddrLow)
|
Operand BindingRangeCheck(int cbOffset, out Operand baseAddrLow)
|
||||||
{
|
{
|
||||||
baseAddrLow = Cbuf(0, cbOffset);
|
baseAddrLow = Cbuf(DriverReservedCb, cbOffset);
|
||||||
Operand baseAddrHigh = Cbuf(0, cbOffset + 1);
|
Operand baseAddrHigh = Cbuf(DriverReservedCb, cbOffset + 1);
|
||||||
Operand size = Cbuf(0, cbOffset + 2);
|
Operand size = Cbuf(DriverReservedCb, cbOffset + 2);
|
||||||
|
|
||||||
Operand offset = PrependOperation(Instruction.Subtract, addrLow, baseAddrLow);
|
Operand offset = PrependOperation(Instruction.Subtract, addrLow, baseAddrLow);
|
||||||
Operand borrow = PrependOperation(Instruction.CompareLessU32, addrLow, baseAddrLow);
|
Operand borrow = PrependOperation(Instruction.CompareLessU32, addrLow, baseAddrLow);
|
||||||
@@ -134,9 +134,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
sbUseMask &= ~(1 << slot);
|
sbUseMask &= ~(1 << slot);
|
||||||
|
|
||||||
config.SetUsedStorageBuffer(slot, isWrite);
|
|
||||||
|
|
||||||
int cbOffset = GetStorageCbOffset(config.Stage, slot);
|
int cbOffset = GetStorageCbOffset(config.Stage, slot);
|
||||||
|
slot = config.GetSbSlot(DriverReservedCb, (ushort)cbOffset);
|
||||||
|
|
||||||
|
config.SetUsedStorageBuffer(slot, isWrite);
|
||||||
|
|
||||||
Operand inRange = BindingRangeCheck(cbOffset, out Operand baseAddrLow);
|
Operand inRange = BindingRangeCheck(cbOffset, out Operand baseAddrLow);
|
||||||
|
|
||||||
|
@@ -125,6 +125,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
private readonly Dictionary<TextureInfo, TextureMeta> _usedTextures;
|
private readonly Dictionary<TextureInfo, TextureMeta> _usedTextures;
|
||||||
private readonly Dictionary<TextureInfo, TextureMeta> _usedImages;
|
private readonly Dictionary<TextureInfo, TextureMeta> _usedImages;
|
||||||
|
|
||||||
|
private readonly Dictionary<int, int> _sbSlots;
|
||||||
|
private readonly Dictionary<int, int> _sbSlotsReverse;
|
||||||
|
|
||||||
private BufferDescriptor[] _cachedConstantBufferDescriptors;
|
private BufferDescriptor[] _cachedConstantBufferDescriptors;
|
||||||
private BufferDescriptor[] _cachedStorageBufferDescriptors;
|
private BufferDescriptor[] _cachedStorageBufferDescriptors;
|
||||||
private TextureDescriptor[] _cachedTextureDescriptors;
|
private TextureDescriptor[] _cachedTextureDescriptors;
|
||||||
@@ -152,6 +155,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
_usedTextures = new Dictionary<TextureInfo, TextureMeta>();
|
_usedTextures = new Dictionary<TextureInfo, TextureMeta>();
|
||||||
_usedImages = new Dictionary<TextureInfo, TextureMeta>();
|
_usedImages = new Dictionary<TextureInfo, TextureMeta>();
|
||||||
|
|
||||||
|
_sbSlots = new Dictionary<int, int>();
|
||||||
|
_sbSlotsReverse = new Dictionary<int, int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShaderConfig(
|
public ShaderConfig(
|
||||||
@@ -770,9 +776,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
usedMask |= (int)GpuAccessor.QueryConstantBufferUse();
|
usedMask |= (int)GpuAccessor.QueryConstantBufferUse();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cachedConstantBufferDescriptors = GetBufferDescriptors(
|
return _cachedConstantBufferDescriptors = GetUniformBufferDescriptors(
|
||||||
usedMask,
|
usedMask,
|
||||||
0,
|
|
||||||
UsedFeatures.HasFlag(FeatureFlags.CbIndexing),
|
UsedFeatures.HasFlag(FeatureFlags.CbIndexing),
|
||||||
out _firstConstantBufferBinding,
|
out _firstConstantBufferBinding,
|
||||||
GpuAccessor.QueryBindingConstantBuffer);
|
GpuAccessor.QueryBindingConstantBuffer);
|
||||||
@@ -785,7 +790,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
return _cachedStorageBufferDescriptors;
|
return _cachedStorageBufferDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cachedStorageBufferDescriptors = GetBufferDescriptors(
|
return _cachedStorageBufferDescriptors = GetStorageBufferDescriptors(
|
||||||
_usedStorageBuffers,
|
_usedStorageBuffers,
|
||||||
_usedStorageBuffersWrite,
|
_usedStorageBuffersWrite,
|
||||||
true,
|
true,
|
||||||
@@ -793,7 +798,48 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
GpuAccessor.QueryBindingStorageBuffer);
|
GpuAccessor.QueryBindingStorageBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferDescriptor[] GetBufferDescriptors(
|
private static BufferDescriptor[] GetUniformBufferDescriptors(int usedMask, bool isArray, out int firstBinding, Func<int, int> getBindingCallback)
|
||||||
|
{
|
||||||
|
firstBinding = 0;
|
||||||
|
int lastSlot = -1;
|
||||||
|
bool hasFirstBinding = false;
|
||||||
|
var descriptors = new BufferDescriptor[BitOperations.PopCount((uint)usedMask)];
|
||||||
|
|
||||||
|
for (int i = 0; i < descriptors.Length; i++)
|
||||||
|
{
|
||||||
|
int slot = BitOperations.TrailingZeroCount(usedMask);
|
||||||
|
|
||||||
|
if (isArray)
|
||||||
|
{
|
||||||
|
// The next array entries also consumes bindings, even if they are unused.
|
||||||
|
for (int j = lastSlot + 1; j < slot; j++)
|
||||||
|
{
|
||||||
|
int binding = getBindingCallback(j);
|
||||||
|
|
||||||
|
if (!hasFirstBinding)
|
||||||
|
{
|
||||||
|
firstBinding = binding;
|
||||||
|
hasFirstBinding = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastSlot = slot;
|
||||||
|
descriptors[i] = new BufferDescriptor(getBindingCallback(slot), slot);
|
||||||
|
|
||||||
|
if (!hasFirstBinding)
|
||||||
|
{
|
||||||
|
firstBinding = descriptors[i].Binding;
|
||||||
|
hasFirstBinding = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
usedMask &= ~(1 << slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
return descriptors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BufferDescriptor[] GetStorageBufferDescriptors(
|
||||||
int usedMask,
|
int usedMask,
|
||||||
int writtenMask,
|
int writtenMask,
|
||||||
bool isArray,
|
bool isArray,
|
||||||
@@ -827,7 +873,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
lastSlot = slot;
|
lastSlot = slot;
|
||||||
|
|
||||||
descriptors[i] = new BufferDescriptor(getBindingCallback(slot), slot);
|
(int sbCbSlot, int sbCbOffset) = GetSbCbInfo(slot);
|
||||||
|
|
||||||
|
descriptors[i] = new BufferDescriptor(getBindingCallback(slot), slot, sbCbSlot, sbCbOffset);
|
||||||
|
|
||||||
if (!hasFirstBinding)
|
if (!hasFirstBinding)
|
||||||
{
|
{
|
||||||
@@ -924,6 +972,40 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
return FindDescriptorIndex(GetImageDescriptors(), texOp);
|
return FindDescriptorIndex(GetImageDescriptors(), texOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetSbSlot(byte sbCbSlot, ushort sbCbOffset)
|
||||||
|
{
|
||||||
|
int key = PackSbCbInfo(sbCbSlot, sbCbOffset);
|
||||||
|
|
||||||
|
if (!_sbSlots.TryGetValue(key, out int slot))
|
||||||
|
{
|
||||||
|
slot = _sbSlots.Count;
|
||||||
|
_sbSlots.Add(key, slot);
|
||||||
|
_sbSlotsReverse.Add(slot, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public (int, int) GetSbCbInfo(int slot)
|
||||||
|
{
|
||||||
|
if (_sbSlotsReverse.TryGetValue(slot, out int key))
|
||||||
|
{
|
||||||
|
return UnpackSbCbInfo(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException($"Invalid slot {slot}.", nameof(slot));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int PackSbCbInfo(int sbCbSlot, int sbCbOffset)
|
||||||
|
{
|
||||||
|
return sbCbOffset | ((int)sbCbSlot << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (int, int) UnpackSbCbInfo(int key)
|
||||||
|
{
|
||||||
|
return ((byte)(key >> 16), (ushort)key);
|
||||||
|
}
|
||||||
|
|
||||||
public ShaderProgramInfo CreateProgramInfo(ShaderIdentification identification = ShaderIdentification.None)
|
public ShaderProgramInfo CreateProgramInfo(ShaderIdentification identification = ShaderIdentification.None)
|
||||||
{
|
{
|
||||||
return new ShaderProgramInfo(
|
return new ShaderProgramInfo(
|
||||||
|
@@ -327,7 +327,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
private void StartNewServices()
|
private void StartNewServices()
|
||||||
{
|
{
|
||||||
ServiceTable = new ServiceTable();
|
ServiceTable = new ServiceTable();
|
||||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient));
|
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices));
|
||||||
|
|
||||||
foreach (var service in services)
|
foreach (var service in services)
|
||||||
{
|
{
|
||||||
|
@@ -89,7 +89,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Title independent mods
|
// Title independent mods
|
||||||
public class PatchCache
|
private class PatchCache
|
||||||
{
|
{
|
||||||
public List<Mod<DirectoryInfo>> NsoPatches { get; }
|
public List<Mod<DirectoryInfo>> NsoPatches { get; }
|
||||||
public List<Mod<DirectoryInfo>> NroPatches { get; }
|
public List<Mod<DirectoryInfo>> NroPatches { get; }
|
||||||
@@ -107,14 +107,14 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<ulong, ModCache> AppMods; // key is TitleId
|
private readonly Dictionary<ulong, ModCache> _appMods; // key is TitleId
|
||||||
public PatchCache Patches;
|
private PatchCache _patches;
|
||||||
|
|
||||||
private static readonly EnumerationOptions _dirEnumOptions;
|
private static readonly EnumerationOptions DirEnumOptions;
|
||||||
|
|
||||||
static ModLoader()
|
static ModLoader()
|
||||||
{
|
{
|
||||||
_dirEnumOptions = new EnumerationOptions
|
DirEnumOptions = new EnumerationOptions
|
||||||
{
|
{
|
||||||
MatchCasing = MatchCasing.CaseInsensitive,
|
MatchCasing = MatchCasing.CaseInsensitive,
|
||||||
MatchType = MatchType.Simple,
|
MatchType = MatchType.Simple,
|
||||||
@@ -125,37 +125,73 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
public ModLoader()
|
public ModLoader()
|
||||||
{
|
{
|
||||||
AppMods = new Dictionary<ulong, ModCache>();
|
_appMods = new Dictionary<ulong, ModCache>();
|
||||||
Patches = new PatchCache();
|
_patches = new PatchCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
private void Clear()
|
||||||
{
|
{
|
||||||
AppMods.Clear();
|
_appMods.Clear();
|
||||||
Patches = new PatchCache();
|
_patches = new PatchCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool StrEquals(string s1, string s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase);
|
private static bool StrEquals(string s1, string s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public string GetModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetModsPath());
|
public static string GetModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetModsPath());
|
||||||
public string GetSdModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetSdModsPath());
|
public static string GetSdModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetSdModsPath());
|
||||||
|
|
||||||
private string EnsureBaseDirStructure(string modsBasePath)
|
private static string EnsureBaseDirStructure(string modsBasePath)
|
||||||
{
|
{
|
||||||
var modsDir = new DirectoryInfo(modsBasePath);
|
var modsDir = new DirectoryInfo(modsBasePath);
|
||||||
|
|
||||||
modsDir.CreateSubdirectory(AmsContentsDir);
|
modsDir.CreateSubdirectory(AmsContentsDir);
|
||||||
modsDir.CreateSubdirectory(AmsNsoPatchDir);
|
modsDir.CreateSubdirectory(AmsNsoPatchDir);
|
||||||
modsDir.CreateSubdirectory(AmsNroPatchDir);
|
modsDir.CreateSubdirectory(AmsNroPatchDir);
|
||||||
// modsDir.CreateSubdirectory(AmsKipPatchDir); // uncomment when KIPs are supported
|
// TODO: uncomment when KIPs are supported
|
||||||
|
// modsDir.CreateSubdirectory(AmsKipPatchDir);
|
||||||
|
|
||||||
return modsDir.FullName;
|
return modsDir.FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DirectoryInfo FindTitleDir(DirectoryInfo contentsDir, string titleId)
|
private static DirectoryInfo FindTitleDir(DirectoryInfo contentsDir, string titleId)
|
||||||
=> contentsDir.EnumerateDirectories($"{titleId}*", _dirEnumOptions).FirstOrDefault();
|
=> contentsDir.EnumerateDirectories($"{titleId}*", DirEnumOptions).FirstOrDefault();
|
||||||
|
|
||||||
public string GetTitleDir(string modsBasePath, string titleId)
|
private static void AddModsFromDirectory(ModCache mods, DirectoryInfo dir, string titleId)
|
||||||
|
{
|
||||||
|
System.Text.StringBuilder types = new();
|
||||||
|
|
||||||
|
foreach (var modDir in dir.EnumerateDirectories())
|
||||||
|
{
|
||||||
|
types.Clear();
|
||||||
|
Mod<DirectoryInfo> mod = new("", null);
|
||||||
|
|
||||||
|
if (StrEquals(RomfsDir, modDir.Name))
|
||||||
|
{
|
||||||
|
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleId} RomFs>", modDir));
|
||||||
|
types.Append('R');
|
||||||
|
}
|
||||||
|
else if (StrEquals(ExefsDir, modDir.Name))
|
||||||
|
{
|
||||||
|
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleId} ExeFs>", modDir));
|
||||||
|
types.Append('E');
|
||||||
|
}
|
||||||
|
else if (StrEquals(CheatDir, modDir.Name))
|
||||||
|
{
|
||||||
|
types.Append('C', QueryCheatsDir(mods, modDir));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddModsFromDirectory(mods, modDir, titleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types.Length > 0)
|
||||||
|
{
|
||||||
|
Logger.Info?.Print(LogClass.ModLoader, $"Found mod '{mod.Name}' [{types}]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetTitleDir(string modsBasePath, string titleId)
|
||||||
{
|
{
|
||||||
var contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir));
|
var contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir));
|
||||||
var titleModsPath = FindTitleDir(contentsDir, titleId);
|
var titleModsPath = FindTitleDir(contentsDir, titleId);
|
||||||
@@ -170,17 +206,32 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Static Query Methods
|
// Static Query Methods
|
||||||
public static void QueryPatchDirs(PatchCache cache, DirectoryInfo patchDir)
|
private static void QueryPatchDirs(PatchCache cache, DirectoryInfo patchDir)
|
||||||
{
|
{
|
||||||
if (cache.Initialized || !patchDir.Exists) return;
|
if (cache.Initialized || !patchDir.Exists)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var patches = cache.KipPatches;
|
List<Mod<DirectoryInfo>> patches;
|
||||||
string type = null;
|
string type;
|
||||||
|
|
||||||
if (StrEquals(AmsNsoPatchDir, patchDir.Name)) { patches = cache.NsoPatches; type = "NSO"; }
|
if (StrEquals(AmsNsoPatchDir, patchDir.Name))
|
||||||
else if (StrEquals(AmsNroPatchDir, patchDir.Name)) { patches = cache.NroPatches; type = "NRO"; }
|
{
|
||||||
else if (StrEquals(AmsKipPatchDir, patchDir.Name)) { patches = cache.KipPatches; type = "KIP"; }
|
patches = cache.NsoPatches; type = "NSO";
|
||||||
else return;
|
}
|
||||||
|
else if (StrEquals(AmsNroPatchDir, patchDir.Name))
|
||||||
|
{
|
||||||
|
patches = cache.NroPatches; type = "NRO";
|
||||||
|
}
|
||||||
|
else if (StrEquals(AmsKipPatchDir, patchDir.Name))
|
||||||
|
{
|
||||||
|
patches = cache.KipPatches; type = "KIP";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var modDir in patchDir.EnumerateDirectories())
|
foreach (var modDir in patchDir.EnumerateDirectories())
|
||||||
{
|
{
|
||||||
@@ -189,9 +240,12 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void QueryTitleDir(ModCache mods, DirectoryInfo titleDir)
|
private static void QueryTitleDir(ModCache mods, DirectoryInfo titleDir)
|
||||||
{
|
{
|
||||||
if (!titleDir.Exists) return;
|
if (!titleDir.Exists)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var fsFile = new FileInfo(Path.Combine(titleDir.FullName, RomfsContainer));
|
var fsFile = new FileInfo(Path.Combine(titleDir.FullName, RomfsContainer));
|
||||||
if (fsFile.Exists)
|
if (fsFile.Exists)
|
||||||
@@ -205,64 +259,15 @@ namespace Ryujinx.HLE.HOS
|
|||||||
mods.ExefsContainers.Add(new Mod<FileInfo>($"<{titleDir.Name} ExeFs>", fsFile));
|
mods.ExefsContainers.Add(new Mod<FileInfo>($"<{titleDir.Name} ExeFs>", fsFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Text.StringBuilder types = new System.Text.StringBuilder(5);
|
AddModsFromDirectory(mods, titleDir, titleDir.Name);
|
||||||
|
|
||||||
foreach (var modDir in titleDir.EnumerateDirectories())
|
|
||||||
{
|
|
||||||
types.Clear();
|
|
||||||
Mod<DirectoryInfo> mod = new Mod<DirectoryInfo>("", null);
|
|
||||||
|
|
||||||
if (StrEquals(RomfsDir, modDir.Name))
|
|
||||||
{
|
|
||||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleDir.Name} RomFs>", modDir));
|
|
||||||
types.Append('R');
|
|
||||||
}
|
|
||||||
else if (StrEquals(ExefsDir, modDir.Name))
|
|
||||||
{
|
|
||||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleDir.Name} ExeFs>", modDir));
|
|
||||||
types.Append('E');
|
|
||||||
}
|
|
||||||
else if (StrEquals(CheatDir, modDir.Name))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < QueryCheatsDir(mods, modDir); i++)
|
|
||||||
{
|
|
||||||
types.Append('C');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var romfs = new DirectoryInfo(Path.Combine(modDir.FullName, RomfsDir));
|
|
||||||
var exefs = new DirectoryInfo(Path.Combine(modDir.FullName, ExefsDir));
|
|
||||||
var cheat = new DirectoryInfo(Path.Combine(modDir.FullName, CheatDir));
|
|
||||||
|
|
||||||
if (romfs.Exists)
|
|
||||||
{
|
|
||||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(modDir.Name, romfs));
|
|
||||||
types.Append('R');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exefs.Exists)
|
|
||||||
{
|
|
||||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(modDir.Name, exefs));
|
|
||||||
types.Append('E');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cheat.Exists)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < QueryCheatsDir(mods, cheat); i++)
|
|
||||||
{
|
|
||||||
types.Append('C');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (types.Length > 0) Logger.Info?.Print(LogClass.ModLoader, $"Found mod '{mod.Name}' [{types}]");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong titleId)
|
public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong titleId)
|
||||||
{
|
{
|
||||||
if (!contentsDir.Exists) return;
|
if (!contentsDir.Exists)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((titleId & 0x1000) != 0 ? "DLC" : "Title")} {titleId:X16}");
|
Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((titleId & 0x1000) != 0 ? "DLC" : "Title")} {titleId:X16}");
|
||||||
|
|
||||||
@@ -302,9 +307,16 @@ namespace Ryujinx.HLE.HOS
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int oldCheatsCount = mods.Cheats.Count;
|
||||||
|
|
||||||
// A cheat file can contain several cheats for the same executable, so the file must be parsed in
|
// A cheat file can contain several cheats for the same executable, so the file must be parsed in
|
||||||
// order to properly enumerate them.
|
// order to properly enumerate them.
|
||||||
mods.Cheats.AddRange(GetCheatsInFile(file));
|
mods.Cheats.AddRange(GetCheatsInFile(file));
|
||||||
|
|
||||||
|
if (mods.Cheats.Count - oldCheatsCount > 0)
|
||||||
|
{
|
||||||
|
numMods++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return numMods;
|
return numMods;
|
||||||
@@ -313,13 +325,11 @@ namespace Ryujinx.HLE.HOS
|
|||||||
private static IEnumerable<Cheat> GetCheatsInFile(FileInfo cheatFile)
|
private static IEnumerable<Cheat> GetCheatsInFile(FileInfo cheatFile)
|
||||||
{
|
{
|
||||||
string cheatName = DefaultCheatName;
|
string cheatName = DefaultCheatName;
|
||||||
List<string> instructions = new List<string>();
|
List<string> instructions = new();
|
||||||
List<Cheat> cheats = new List<Cheat>();
|
List<Cheat> cheats = new();
|
||||||
|
|
||||||
using (StreamReader cheatData = cheatFile.OpenText())
|
using StreamReader cheatData = cheatFile.OpenText();
|
||||||
{
|
while (cheatData.ReadLine() is { } line)
|
||||||
string line;
|
|
||||||
while ((line = cheatData.ReadLine()) != null)
|
|
||||||
{
|
{
|
||||||
line = line.Trim();
|
line = line.Trim();
|
||||||
|
|
||||||
@@ -332,11 +342,11 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
Logger.Warning?.Print(LogClass.ModLoader, $"Ignoring cheat '{cheatFile.FullName}' because it is malformed");
|
Logger.Warning?.Print(LogClass.ModLoader, $"Ignoring cheat '{cheatFile.FullName}' because it is malformed");
|
||||||
|
|
||||||
return new List<Cheat>();
|
return Array.Empty<Cheat>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the previous section to the list.
|
// Add the previous section to the list.
|
||||||
if (instructions.Count != 0)
|
if (instructions.Count > 0)
|
||||||
{
|
{
|
||||||
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
||||||
}
|
}
|
||||||
@@ -353,17 +363,16 @@ namespace Ryujinx.HLE.HOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the last section being processed.
|
// Add the last section being processed.
|
||||||
if (instructions.Count != 0)
|
if (instructions.Count > 0)
|
||||||
{
|
{
|
||||||
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return cheats;
|
return cheats;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assumes searchDirPaths don't overlap
|
// Assumes searchDirPaths don't overlap
|
||||||
public static void CollectMods(Dictionary<ulong, ModCache> modCaches, PatchCache patches, params string[] searchDirPaths)
|
private static void CollectMods(Dictionary<ulong, ModCache> modCaches, PatchCache patches, params string[] searchDirPaths)
|
||||||
{
|
{
|
||||||
static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) ||
|
static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) ||
|
||||||
StrEquals(AmsNroPatchDir, name) ||
|
StrEquals(AmsNroPatchDir, name) ||
|
||||||
@@ -375,7 +384,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
{
|
{
|
||||||
if (IsContentsDir(searchDir.Name))
|
if (IsContentsDir(searchDir.Name))
|
||||||
{
|
{
|
||||||
foreach (var (titleId, cache) in modCaches)
|
foreach ((ulong titleId, ModCache cache) in modCaches)
|
||||||
{
|
{
|
||||||
QueryContentsDir(cache, searchDir, titleId);
|
QueryContentsDir(cache, searchDir, titleId);
|
||||||
}
|
}
|
||||||
@@ -419,15 +428,15 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
foreach (ulong titleId in titles)
|
foreach (ulong titleId in titles)
|
||||||
{
|
{
|
||||||
AppMods[titleId] = new ModCache();
|
_appMods[titleId] = new ModCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
CollectMods(AppMods, Patches, searchDirPaths);
|
CollectMods(_appMods, _patches, searchDirPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IStorage ApplyRomFsMods(ulong titleId, IStorage baseStorage)
|
internal IStorage ApplyRomFsMods(ulong titleId, IStorage baseStorage)
|
||||||
{
|
{
|
||||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.RomfsDirs.Count + mods.RomfsContainers.Count == 0)
|
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.RomfsDirs.Count + mods.RomfsContainers.Count == 0)
|
||||||
{
|
{
|
||||||
return baseStorage;
|
return baseStorage;
|
||||||
}
|
}
|
||||||
@@ -487,7 +496,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
return newStorage;
|
return newStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddFiles(IFileSystem fs, string modName, HashSet<string> fileSet, RomFsBuilder builder)
|
private static void AddFiles(IFileSystem fs, string modName, ISet<string> fileSet, RomFsBuilder builder)
|
||||||
{
|
{
|
||||||
foreach (var entry in fs.EnumerateEntries()
|
foreach (var entry in fs.EnumerateEntries()
|
||||||
.Where(f => f.Type == DirectoryEntryType.File)
|
.Where(f => f.Type == DirectoryEntryType.File)
|
||||||
@@ -509,7 +518,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
internal bool ReplaceExefsPartition(ulong titleId, ref IFileSystem exefs)
|
internal bool ReplaceExefsPartition(ulong titleId, ref IFileSystem exefs)
|
||||||
{
|
{
|
||||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsContainers.Count == 0)
|
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsContainers.Count == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -537,13 +546,13 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
internal ModLoadResult ApplyExefsMods(ulong titleId, NsoExecutable[] nsos)
|
internal ModLoadResult ApplyExefsMods(ulong titleId, NsoExecutable[] nsos)
|
||||||
{
|
{
|
||||||
ModLoadResult modLoadResult = new ModLoadResult
|
ModLoadResult modLoadResult = new()
|
||||||
{
|
{
|
||||||
Stubs = new BitVector32(),
|
Stubs = new BitVector32(),
|
||||||
Replaces = new BitVector32()
|
Replaces = new BitVector32()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
||||||
{
|
{
|
||||||
return modLoadResult;
|
return modLoadResult;
|
||||||
}
|
}
|
||||||
@@ -561,7 +570,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
{
|
{
|
||||||
var nsoName = ProcessConst.ExeFsPrefixes[i];
|
var nsoName = ProcessConst.ExeFsPrefixes[i];
|
||||||
|
|
||||||
FileInfo nsoFile = new FileInfo(Path.Combine(mod.Path.FullName, nsoName));
|
FileInfo nsoFile = new(Path.Combine(mod.Path.FullName, nsoName));
|
||||||
if (nsoFile.Exists)
|
if (nsoFile.Exists)
|
||||||
{
|
{
|
||||||
if (modLoadResult.Replaces[1 << i])
|
if (modLoadResult.Replaces[1 << i])
|
||||||
@@ -580,7 +589,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
modLoadResult.Stubs[1 << i] |= File.Exists(Path.Combine(mod.Path.FullName, nsoName + StubExtension));
|
modLoadResult.Stubs[1 << i] |= File.Exists(Path.Combine(mod.Path.FullName, nsoName + StubExtension));
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInfo npdmFile = new FileInfo(Path.Combine(mod.Path.FullName, "main.npdm"));
|
FileInfo npdmFile = new(Path.Combine(mod.Path.FullName, "main.npdm"));
|
||||||
if (npdmFile.Exists)
|
if (npdmFile.Exists)
|
||||||
{
|
{
|
||||||
if (modLoadResult.Npdm != null)
|
if (modLoadResult.Npdm != null)
|
||||||
@@ -611,7 +620,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
internal void ApplyNroPatches(NroExecutable nro)
|
internal void ApplyNroPatches(NroExecutable nro)
|
||||||
{
|
{
|
||||||
var nroPatches = Patches.NroPatches;
|
var nroPatches = _patches.NroPatches;
|
||||||
|
|
||||||
if (nroPatches.Count == 0) return;
|
if (nroPatches.Count == 0) return;
|
||||||
|
|
||||||
@@ -622,9 +631,9 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
internal bool ApplyNsoPatches(ulong titleId, params IExecutable[] programs)
|
internal bool ApplyNsoPatches(ulong titleId, params IExecutable[] programs)
|
||||||
{
|
{
|
||||||
IEnumerable<Mod<DirectoryInfo>> nsoMods = Patches.NsoPatches;
|
IEnumerable<Mod<DirectoryInfo>> nsoMods = _patches.NsoPatches;
|
||||||
|
|
||||||
if (AppMods.TryGetValue(titleId, out ModCache mods))
|
if (_appMods.TryGetValue(titleId, out ModCache mods))
|
||||||
{
|
{
|
||||||
nsoMods = nsoMods.Concat(mods.ExefsDirs);
|
nsoMods = nsoMods.Concat(mods.ExefsDirs);
|
||||||
}
|
}
|
||||||
@@ -636,7 +645,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
internal void LoadCheats(ulong titleId, ProcessTamperInfo tamperInfo, TamperMachine tamperMachine)
|
internal void LoadCheats(ulong titleId, ProcessTamperInfo tamperInfo, TamperMachine tamperMachine)
|
||||||
{
|
{
|
||||||
if (tamperInfo == null || tamperInfo.BuildIds == null || tamperInfo.CodeAddresses == null)
|
if (tamperInfo?.BuildIds == null || tamperInfo.CodeAddresses == null)
|
||||||
{
|
{
|
||||||
Logger.Error?.Print(LogClass.ModLoader, "Unable to install cheat because the associated process is invalid");
|
Logger.Error?.Print(LogClass.ModLoader, "Unable to install cheat because the associated process is invalid");
|
||||||
|
|
||||||
@@ -645,14 +654,14 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
Logger.Info?.Print(LogClass.ModLoader, $"Build ids found for title {titleId:X16}:\n {String.Join("\n ", tamperInfo.BuildIds)}");
|
Logger.Info?.Print(LogClass.ModLoader, $"Build ids found for title {titleId:X16}:\n {String.Join("\n ", tamperInfo.BuildIds)}");
|
||||||
|
|
||||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.Cheats.Count == 0)
|
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.Cheats.Count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cheats = mods.Cheats;
|
var cheats = mods.Cheats;
|
||||||
var processExes = tamperInfo.BuildIds.Zip(tamperInfo.CodeAddresses, (k, v) => new { k, v })
|
var processExes = tamperInfo.BuildIds.Zip(tamperInfo.CodeAddresses, (k, v) => new { k, v })
|
||||||
.ToDictionary(x => x.k.Substring(0, Math.Min(Cheat.CheatIdSize, x.k.Length)), x => x.v);
|
.ToDictionary(x => x.k[..Math.Min(Cheat.CheatIdSize, x.k.Length)], x => x.v);
|
||||||
|
|
||||||
foreach (var cheat in cheats)
|
foreach (var cheat in cheats)
|
||||||
{
|
{
|
||||||
|
85
src/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs
Normal file
85
src/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using LibHac;
|
||||||
|
using LibHac.Common;
|
||||||
|
using Ryujinx.Common;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Arp;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat
|
||||||
|
{
|
||||||
|
[Service("bcat:a", "bcat:a")]
|
||||||
|
[Service("bcat:m", "bcat:m")]
|
||||||
|
[Service("bcat:u", "bcat:u")]
|
||||||
|
[Service("bcat:s", "bcat:s")]
|
||||||
|
class IServiceCreator : DisposableIpcService
|
||||||
|
{
|
||||||
|
private SharedRef<LibHac.Bcat.Impl.Ipc.IServiceCreator> _base;
|
||||||
|
|
||||||
|
public IServiceCreator(ServiceCtx context, string serviceName)
|
||||||
|
{
|
||||||
|
var applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient;
|
||||||
|
applicationClient.Sm.GetService(ref _base, serviceName).ThrowIfFailure();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (isDisposing)
|
||||||
|
{
|
||||||
|
_base.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(0)]
|
||||||
|
// CreateBcatService(pid) -> object<nn::bcat::detail::ipc::IBcatService>
|
||||||
|
public ResultCode CreateBcatService(ServiceCtx context)
|
||||||
|
{
|
||||||
|
// TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
|
||||||
|
// Add an instance of nn::bcat::detail::service::core::PassphraseManager.
|
||||||
|
// Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
|
||||||
|
// Add an instance of nn::bcat::detail::service::core::TaskManager who load "bcat-sys:/" system save data and open "dc/task.bin".
|
||||||
|
// If the file don't exist, create a new one (size of 0x800) and write 2 empty struct with a size of 0x400.
|
||||||
|
|
||||||
|
MakeObject(context, new IBcatService(ApplicationLaunchProperty.GetByPid(context)));
|
||||||
|
|
||||||
|
// NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case.
|
||||||
|
// return ResultCode.NullObject;
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1)]
|
||||||
|
// CreateDeliveryCacheStorageService(pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
||||||
|
public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
|
||||||
|
{
|
||||||
|
ulong pid = context.RequestData.ReadUInt64();
|
||||||
|
|
||||||
|
using var serv = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
||||||
|
|
||||||
|
Result rc = _base.Get.CreateDeliveryCacheStorageService(ref serv.Ref, pid);
|
||||||
|
|
||||||
|
if (rc.IsSuccess())
|
||||||
|
{
|
||||||
|
MakeObject(context, new IDeliveryCacheStorageService(context, ref serv.Ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ResultCode)rc.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(2)]
|
||||||
|
// CreateDeliveryCacheStorageServiceWithApplicationId(nn::ApplicationId) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
||||||
|
public ResultCode CreateDeliveryCacheStorageServiceWithApplicationId(ServiceCtx context)
|
||||||
|
{
|
||||||
|
ApplicationId applicationId = context.RequestData.ReadStruct<ApplicationId>();
|
||||||
|
|
||||||
|
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
||||||
|
|
||||||
|
Result rc = _base.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref service.Ref, applicationId);
|
||||||
|
|
||||||
|
if (rc.IsSuccess())
|
||||||
|
{
|
||||||
|
MakeObject(context, new IDeliveryCacheStorageService(context, ref service.Ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ResultCode)rc.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
src/Ryujinx.HLE/HOS/Services/Bcat/ResultCode.cs
Normal file
29
src/Ryujinx.HLE/HOS/Services/Bcat/ResultCode.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat
|
||||||
|
{
|
||||||
|
enum ResultCode
|
||||||
|
{
|
||||||
|
ModuleId = 122,
|
||||||
|
ErrorCodeShift = 9,
|
||||||
|
|
||||||
|
Success = 0,
|
||||||
|
|
||||||
|
InvalidArgument = (1 << ErrorCodeShift) | ModuleId,
|
||||||
|
NotFound = (2 << ErrorCodeShift) | ModuleId,
|
||||||
|
TargetLocked = (3 << ErrorCodeShift) | ModuleId,
|
||||||
|
TargetAlreadyMounted = (4 << ErrorCodeShift) | ModuleId,
|
||||||
|
TargetNotMounted = (5 << ErrorCodeShift) | ModuleId,
|
||||||
|
AlreadyOpen = (6 << ErrorCodeShift) | ModuleId,
|
||||||
|
NotOpen = (7 << ErrorCodeShift) | ModuleId,
|
||||||
|
InternetRequestDenied = (8 << ErrorCodeShift) | ModuleId,
|
||||||
|
ServiceOpenLimitReached = (9 << ErrorCodeShift) | ModuleId,
|
||||||
|
SaveDataNotFound = (10 << ErrorCodeShift) | ModuleId,
|
||||||
|
NetworkServiceAccountNotAvailable = (31 << ErrorCodeShift) | ModuleId,
|
||||||
|
PassphrasePathNotFound = (80 << ErrorCodeShift) | ModuleId,
|
||||||
|
DataVerificationFailed = (81 << ErrorCodeShift) | ModuleId,
|
||||||
|
PermissionDenied = (90 << ErrorCodeShift) | ModuleId,
|
||||||
|
AllocationFailed = (91 << ErrorCodeShift) | ModuleId,
|
||||||
|
InvalidOperation = (98 << ErrorCodeShift) | ModuleId,
|
||||||
|
InvalidDeliveryCacheStorageFile = (204 << ErrorCodeShift) | ModuleId,
|
||||||
|
StorageOpenLimitReached = (205 << ErrorCodeShift) | ModuleId
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
using Ryujinx.HLE.HOS.Services.Arp;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||||
|
{
|
||||||
|
class IBcatService : IpcService
|
||||||
|
{
|
||||||
|
public IBcatService(ApplicationLaunchProperty applicationLaunchProperty) { }
|
||||||
|
|
||||||
|
[CommandCmif(10100)]
|
||||||
|
// RequestSyncDeliveryCache() -> object<nn::bcat::detail::ipc::IDeliveryCacheProgressService>
|
||||||
|
public ResultCode RequestSyncDeliveryCache(ServiceCtx context)
|
||||||
|
{
|
||||||
|
MakeObject(context, new IDeliveryCacheProgressService(context));
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
using LibHac;
|
||||||
|
using LibHac.Bcat;
|
||||||
|
using LibHac.Common;
|
||||||
|
using Ryujinx.Common;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||||
|
{
|
||||||
|
class IDeliveryCacheDirectoryService : DisposableIpcService
|
||||||
|
{
|
||||||
|
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> _base;
|
||||||
|
|
||||||
|
public IDeliveryCacheDirectoryService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> baseService)
|
||||||
|
{
|
||||||
|
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>.CreateMove(ref baseService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (isDisposing)
|
||||||
|
{
|
||||||
|
_base.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(0)]
|
||||||
|
// Open(nn::bcat::DirectoryName)
|
||||||
|
public ResultCode Open(ServiceCtx context)
|
||||||
|
{
|
||||||
|
DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
|
||||||
|
|
||||||
|
Result result = _base.Get.Open(ref directoryName);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1)]
|
||||||
|
// Read() -> (u32, buffer<nn::bcat::DeliveryCacheDirectoryEntry, 6>)
|
||||||
|
public ResultCode Read(ServiceCtx context)
|
||||||
|
{
|
||||||
|
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||||
|
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||||
|
|
||||||
|
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||||
|
{
|
||||||
|
Result result = _base.Get.Read(out int entriesRead, MemoryMarshal.Cast<byte, DeliveryCacheDirectoryEntry>(region.Memory.Span));
|
||||||
|
|
||||||
|
context.ResponseData.Write(entriesRead);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(2)]
|
||||||
|
// GetCount() -> u32
|
||||||
|
public ResultCode GetCount(ServiceCtx context)
|
||||||
|
{
|
||||||
|
Result result = _base.Get.GetCount(out int count);
|
||||||
|
|
||||||
|
context.ResponseData.Write(count);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,78 @@
|
|||||||
|
using LibHac;
|
||||||
|
using LibHac.Bcat;
|
||||||
|
using LibHac.Common;
|
||||||
|
using Ryujinx.Common;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||||
|
{
|
||||||
|
class IDeliveryCacheFileService : DisposableIpcService
|
||||||
|
{
|
||||||
|
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> _base;
|
||||||
|
|
||||||
|
public IDeliveryCacheFileService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> baseService)
|
||||||
|
{
|
||||||
|
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>.CreateMove(ref baseService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (isDisposing)
|
||||||
|
{
|
||||||
|
_base.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(0)]
|
||||||
|
// Open(nn::bcat::DirectoryName, nn::bcat::FileName)
|
||||||
|
public ResultCode Open(ServiceCtx context)
|
||||||
|
{
|
||||||
|
DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
|
||||||
|
FileName fileName = context.RequestData.ReadStruct<FileName>();
|
||||||
|
|
||||||
|
Result result = _base.Get.Open(ref directoryName, ref fileName);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1)]
|
||||||
|
// Read(u64) -> (u64, buffer<bytes, 6>)
|
||||||
|
public ResultCode Read(ServiceCtx context)
|
||||||
|
{
|
||||||
|
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||||
|
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||||
|
|
||||||
|
long offset = context.RequestData.ReadInt64();
|
||||||
|
|
||||||
|
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||||
|
{
|
||||||
|
Result result = _base.Get.Read(out long bytesRead, offset, region.Memory.Span);
|
||||||
|
|
||||||
|
context.ResponseData.Write(bytesRead);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(2)]
|
||||||
|
// GetSize() -> u64
|
||||||
|
public ResultCode GetSize(ServiceCtx context)
|
||||||
|
{
|
||||||
|
Result result = _base.Get.GetSize(out long size);
|
||||||
|
|
||||||
|
context.ResponseData.Write(size);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(3)]
|
||||||
|
// GetDigest() -> nn::bcat::Digest
|
||||||
|
public ResultCode GetDigest(ServiceCtx context)
|
||||||
|
{
|
||||||
|
Result result = _base.Get.GetDigest(out Digest digest);
|
||||||
|
|
||||||
|
context.ResponseData.WriteStruct(digest);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,63 @@
|
|||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Cpu;
|
||||||
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator.Types;
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||||
|
{
|
||||||
|
class IDeliveryCacheProgressService : IpcService
|
||||||
|
{
|
||||||
|
private KEvent _event;
|
||||||
|
private int _eventHandle;
|
||||||
|
|
||||||
|
public IDeliveryCacheProgressService(ServiceCtx context)
|
||||||
|
{
|
||||||
|
_event = new KEvent(context.Device.System.KernelContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(0)]
|
||||||
|
// GetEvent() -> handle<copy>
|
||||||
|
public ResultCode GetEvent(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (_eventHandle == 0)
|
||||||
|
{
|
||||||
|
if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out _eventHandle) != Result.Success)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Out of handles!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_eventHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1)]
|
||||||
|
// GetImpl() -> buffer<nn::bcat::detail::DeliveryCacheProgressImpl, 0x1a>
|
||||||
|
public ResultCode GetImpl(ServiceCtx context)
|
||||||
|
{
|
||||||
|
DeliveryCacheProgressImpl deliveryCacheProgress = new DeliveryCacheProgressImpl
|
||||||
|
{
|
||||||
|
State = DeliveryCacheProgressImpl.Status.Done,
|
||||||
|
Result = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
ulong dcpSize = WriteDeliveryCacheProgressImpl(context, context.Request.RecvListBuff[0], deliveryCacheProgress);
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(dcpSize);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ulong WriteDeliveryCacheProgressImpl(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, DeliveryCacheProgressImpl deliveryCacheProgress)
|
||||||
|
{
|
||||||
|
return MemoryHelper.Write(context.Memory, ipcDesc.Position, deliveryCacheProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,74 @@
|
|||||||
|
using LibHac;
|
||||||
|
using LibHac.Bcat;
|
||||||
|
using LibHac.Common;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||||
|
{
|
||||||
|
class IDeliveryCacheStorageService : DisposableIpcService
|
||||||
|
{
|
||||||
|
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> _base;
|
||||||
|
|
||||||
|
public IDeliveryCacheStorageService(ServiceCtx context, ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> baseService)
|
||||||
|
{
|
||||||
|
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>.CreateMove(ref baseService);
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(0)]
|
||||||
|
// CreateFileService() -> object<nn::bcat::detail::ipc::IDeliveryCacheFileService>
|
||||||
|
public ResultCode CreateFileService(ServiceCtx context)
|
||||||
|
{
|
||||||
|
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>();
|
||||||
|
|
||||||
|
Result result = _base.Get.CreateFileService(ref service.Ref);
|
||||||
|
|
||||||
|
if (result.IsSuccess())
|
||||||
|
{
|
||||||
|
MakeObject(context, new IDeliveryCacheFileService(ref service.Ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(1)]
|
||||||
|
// CreateDirectoryService() -> object<nn::bcat::detail::ipc::IDeliveryCacheDirectoryService>
|
||||||
|
public ResultCode CreateDirectoryService(ServiceCtx context)
|
||||||
|
{
|
||||||
|
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>();
|
||||||
|
|
||||||
|
Result result = _base.Get.CreateDirectoryService(ref service.Ref);
|
||||||
|
|
||||||
|
if (result.IsSuccess())
|
||||||
|
{
|
||||||
|
MakeObject(context, new IDeliveryCacheDirectoryService(ref service.Ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(10)]
|
||||||
|
// EnumerateDeliveryCacheDirectory() -> (u32, buffer<nn::bcat::DirectoryName, 6>)
|
||||||
|
public ResultCode EnumerateDeliveryCacheDirectory(ServiceCtx context)
|
||||||
|
{
|
||||||
|
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||||
|
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||||
|
|
||||||
|
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||||
|
{
|
||||||
|
Result result = _base.Get.EnumerateDeliveryCacheDirectory(out int count, MemoryMarshal.Cast<byte, DirectoryName>(region.Memory.Span));
|
||||||
|
|
||||||
|
context.ResponseData.Write(count);
|
||||||
|
|
||||||
|
return (ResultCode)result.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (isDisposing)
|
||||||
|
{
|
||||||
|
_base.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc.Types
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator.Types
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||||
public struct DeliveryCacheProgressImpl
|
public struct DeliveryCacheProgressImpl
|
@@ -2,6 +2,7 @@
|
|||||||
using LibHac.FsSystem;
|
using LibHac.FsSystem;
|
||||||
using LibHac.Loader;
|
using LibHac.Loader;
|
||||||
using LibHac.Ns;
|
using LibHac.Ns;
|
||||||
|
using Ryujinx.HLE.HOS;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||||
using ApplicationId = LibHac.Ncm.ApplicationId;
|
using ApplicationId = LibHac.Ncm.ApplicationId;
|
||||||
|
|
||||||
@@ -17,8 +18,8 @@ namespace Ryujinx.HLE.Loaders.Processes
|
|||||||
|
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
||||||
new[] { programId },
|
new[] { programId },
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.GetModsBasePath(),
|
ModLoader.GetModsBasePath(),
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.GetSdModsBasePath());
|
ModLoader.GetSdModsBasePath());
|
||||||
|
|
||||||
if (programId != 0)
|
if (programId != 0)
|
||||||
{
|
{
|
||||||
|
@@ -8,6 +8,7 @@ using LibHac.Ns;
|
|||||||
using LibHac.Tools.FsSystem;
|
using LibHac.Tools.FsSystem;
|
||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.HLE.HOS;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ApplicationId = LibHac.Ncm.ApplicationId;
|
using ApplicationId = LibHac.Ncm.ApplicationId;
|
||||||
@@ -35,8 +36,8 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
|||||||
// Collecting mods related to AocTitleIds and ProgramId.
|
// Collecting mods related to AocTitleIds and ProgramId.
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
||||||
device.Configuration.ContentManager.GetAocTitleIds().Prepend(metaLoader.GetProgramId()),
|
device.Configuration.ContentManager.GetAocTitleIds().Prepend(metaLoader.GetProgramId()),
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.GetModsBasePath(),
|
ModLoader.GetModsBasePath(),
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.GetSdModsBasePath());
|
ModLoader.GetSdModsBasePath());
|
||||||
|
|
||||||
// Load Nacp file.
|
// Load Nacp file.
|
||||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||||
|
@@ -1,48 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Bcat.Ipc;
|
|
||||||
using Ryujinx.Horizon.Bcat.Types;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sm;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat
|
|
||||||
{
|
|
||||||
internal class BcatIpcServer
|
|
||||||
{
|
|
||||||
private const int BcatMaxSessionsCount = 8;
|
|
||||||
private const int BcatTotalMaxSessionsCount = BcatMaxSessionsCount * 4;
|
|
||||||
|
|
||||||
private const int PointerBufferSize = 0x400;
|
|
||||||
private const int MaxDomains = 64;
|
|
||||||
private const int MaxDomainObjects = 64;
|
|
||||||
private const int MaxPortsCount = 4;
|
|
||||||
|
|
||||||
private SmApi _sm;
|
|
||||||
private BcatServerManager _serverManager;
|
|
||||||
|
|
||||||
private static readonly ManagerOptions _bcatManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
|
||||||
|
|
||||||
internal void Initialize()
|
|
||||||
{
|
|
||||||
HeapAllocator allocator = new();
|
|
||||||
|
|
||||||
_sm = new SmApi();
|
|
||||||
_sm.Initialize().AbortOnFailure();
|
|
||||||
|
|
||||||
_serverManager = new BcatServerManager(allocator, _sm, MaxPortsCount, _bcatManagerOptions, BcatTotalMaxSessionsCount);
|
|
||||||
|
|
||||||
_serverManager.RegisterServer((int)BcatPortIndex.Admin, ServiceName.Encode("bcat:a"), BcatMaxSessionsCount);
|
|
||||||
_serverManager.RegisterServer((int)BcatPortIndex.Manager, ServiceName.Encode("bcat:m"), BcatMaxSessionsCount);
|
|
||||||
_serverManager.RegisterServer((int)BcatPortIndex.User, ServiceName.Encode("bcat:u"), BcatMaxSessionsCount);
|
|
||||||
_serverManager.RegisterServer((int)BcatPortIndex.System, ServiceName.Encode("bcat:s"), BcatMaxSessionsCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ServiceRequests()
|
|
||||||
{
|
|
||||||
_serverManager.ServiceRequests();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Shutdown()
|
|
||||||
{
|
|
||||||
_serverManager.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
using Ryujinx.Horizon.LogManager;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat
|
|
||||||
{
|
|
||||||
internal class BcatMain : IService
|
|
||||||
{
|
|
||||||
public static void Main(ServiceTable serviceTable)
|
|
||||||
{
|
|
||||||
BcatIpcServer ipcServer = new();
|
|
||||||
|
|
||||||
ipcServer.Initialize();
|
|
||||||
|
|
||||||
serviceTable.SignalServiceReady();
|
|
||||||
|
|
||||||
ipcServer.ServiceRequests();
|
|
||||||
ipcServer.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,29 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Common;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat
|
|
||||||
{
|
|
||||||
class BcatResult
|
|
||||||
{
|
|
||||||
private const int ModuleId = 122;
|
|
||||||
|
|
||||||
public static Result Success => new(ModuleId, 0);
|
|
||||||
public static Result InvalidArgument => new(ModuleId, 1);
|
|
||||||
public static Result NotFound => new(ModuleId, 2);
|
|
||||||
public static Result TargetLocked => new(ModuleId, 3);
|
|
||||||
public static Result TargetAlreadyMounted => new(ModuleId, 4);
|
|
||||||
public static Result TargetNotMounted => new(ModuleId, 5);
|
|
||||||
public static Result AlreadyOpen => new(ModuleId, 6);
|
|
||||||
public static Result NotOpen => new(ModuleId, 7);
|
|
||||||
public static Result InternetRequestDenied => new(ModuleId, 8);
|
|
||||||
public static Result ServiceOpenLimitReached => new(ModuleId, 9);
|
|
||||||
public static Result SaveDataNotFound => new(ModuleId, 10);
|
|
||||||
public static Result NetworkServiceAccountNotAvailable => new(ModuleId, 31);
|
|
||||||
public static Result PassphrasePathNotFound => new(ModuleId, 80);
|
|
||||||
public static Result DataVerificationFailed => new(ModuleId, 81);
|
|
||||||
public static Result PermissionDenied => new(ModuleId, 90);
|
|
||||||
public static Result AllocationFailed => new(ModuleId, 91);
|
|
||||||
public static Result InvalidOperation => new(ModuleId, 98);
|
|
||||||
public static Result InvalidDeliveryCacheStorageFile => new(ModuleId, 204);
|
|
||||||
public static Result StorageOpenLimitReached => new(ModuleId, 205);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Bcat.Ipc;
|
|
||||||
using Ryujinx.Horizon.Bcat.Types;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sm;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat
|
|
||||||
{
|
|
||||||
class BcatServerManager : ServerManager
|
|
||||||
{
|
|
||||||
public BcatServerManager(HeapAllocator allocator, SmApi sm, int maxPorts, ManagerOptions options, int maxSessions) : base(allocator, sm, maxPorts, options, maxSessions)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Result OnNeedsToAccept(int portIndex, Server server)
|
|
||||||
{
|
|
||||||
return (BcatPortIndex)portIndex switch
|
|
||||||
{
|
|
||||||
BcatPortIndex.Admin => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.Admin)),
|
|
||||||
BcatPortIndex.Manager => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.Manager)),
|
|
||||||
BcatPortIndex.User => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.User)),
|
|
||||||
BcatPortIndex.System => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.System)),
|
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(portIndex)),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,82 +0,0 @@
|
|||||||
using LibHac.Common;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Bcat;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
|
||||||
{
|
|
||||||
partial class ServiceCreator : IServiceCreator, IDisposable
|
|
||||||
{
|
|
||||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IServiceCreator> _libHacService;
|
|
||||||
|
|
||||||
private int _disposalState;
|
|
||||||
|
|
||||||
public ServiceCreator(string serviceName)
|
|
||||||
{
|
|
||||||
HorizonStatic.Options.BcatClient.Sm.GetService(ref _libHacService, serviceName).ThrowIfFailure();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(0)]
|
|
||||||
public Result CreateBcatService(out IBcatService bcatService, [ClientProcessId] ulong pid)
|
|
||||||
{
|
|
||||||
// TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
|
|
||||||
// Add an instance of nn::bcat::detail::service::core::PassphraseManager.
|
|
||||||
// Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
|
|
||||||
// Add an instance of nn::bcat::detail::service::core::TaskManager who loads "bcat-sys:/" system save data and opens "dc/task.bin".
|
|
||||||
// If the file don't exist, create a new one (with a size of 0x800 bytes) and write 2 empty structs with a size of 0x400 bytes.
|
|
||||||
|
|
||||||
bcatService = new BcatService(Bcat.Types.BcatServicePermissionLevel.User);
|
|
||||||
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(1)]
|
|
||||||
public Result CreateDeliveryCacheStorageService(out IDeliveryCacheStorageService service, [ClientProcessId] ulong pid)
|
|
||||||
{
|
|
||||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
|
||||||
|
|
||||||
var resultCode = _libHacService.Get.CreateDeliveryCacheStorageService(ref libHacService.Ref, pid);
|
|
||||||
|
|
||||||
if (resultCode.IsSuccess())
|
|
||||||
{
|
|
||||||
service = new DeliveryCacheStorageService(ref libHacService.Ref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
service = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultCode.ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(2)]
|
|
||||||
public Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, ApplicationId applicationId)
|
|
||||||
{
|
|
||||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
|
||||||
|
|
||||||
var resultCode = _libHacService.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref libHacService.Ref, new LibHac.ApplicationId(applicationId.Id));
|
|
||||||
|
|
||||||
if (resultCode.IsSuccess())
|
|
||||||
{
|
|
||||||
service = new DeliveryCacheStorageService(ref libHacService.Ref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
service = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultCode.ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
|
||||||
{
|
|
||||||
_libHacService.Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Bcat.Types;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Bcat;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
|
||||||
{
|
|
||||||
partial class BcatService : IBcatService
|
|
||||||
{
|
|
||||||
private readonly BcatServicePermissionLevel _permissionLevel;
|
|
||||||
|
|
||||||
public BcatService(BcatServicePermissionLevel permissionLevel)
|
|
||||||
{
|
|
||||||
_permissionLevel = permissionLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(10100)]
|
|
||||||
public Result RequestSyncDeliveryCache(out IDeliveryCacheProgressService deliveryCacheProgressService)
|
|
||||||
{
|
|
||||||
deliveryCacheProgressService = new DeliveryCacheProgressService();
|
|
||||||
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,48 +0,0 @@
|
|||||||
using LibHac.Bcat;
|
|
||||||
using LibHac.Common;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Bcat;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
|
||||||
{
|
|
||||||
partial class DeliveryCacheDirectoryService : IDeliveryCacheDirectoryService, IDisposable
|
|
||||||
{
|
|
||||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> _libHacService;
|
|
||||||
private int _disposalState;
|
|
||||||
|
|
||||||
public DeliveryCacheDirectoryService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> libHacService)
|
|
||||||
{
|
|
||||||
_libHacService = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>.CreateMove(ref libHacService);
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(0)]
|
|
||||||
public Result Open(DirectoryName directoryName)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.Open(ref directoryName).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(1)]
|
|
||||||
public Result Read(out int entriesRead, [Buffer(Sdk.Sf.Hipc.HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DeliveryCacheDirectoryEntry> entriesBuffer)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.Read(out entriesRead, entriesBuffer).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(2)]
|
|
||||||
public Result GetCount(out int count)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.GetCount(out count).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
|
||||||
{
|
|
||||||
_libHacService.Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,54 +0,0 @@
|
|||||||
using LibHac.Bcat;
|
|
||||||
using LibHac.Common;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Bcat;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
|
||||||
{
|
|
||||||
partial class DeliveryCacheFileService : IDeliveryCacheFileService, IDisposable
|
|
||||||
{
|
|
||||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> _libHacService;
|
|
||||||
private int _disposalState;
|
|
||||||
|
|
||||||
public DeliveryCacheFileService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> libHacService)
|
|
||||||
{
|
|
||||||
_libHacService = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>.CreateMove(ref libHacService);
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(0)]
|
|
||||||
public Result Open(DirectoryName directoryName, FileName fileName)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.Open(ref directoryName, ref fileName).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(1)]
|
|
||||||
public Result Read(long offset, out long bytesRead, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> data)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.Read(out bytesRead, offset, data).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(2)]
|
|
||||||
public Result GetSize(out long size)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.GetSize(out size).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(3)]
|
|
||||||
public Result GetDigest(out Digest digest)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.GetDigest(out digest).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
|
||||||
{
|
|
||||||
_libHacService.Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,58 +0,0 @@
|
|||||||
using Ryujinx.Common.Logging;
|
|
||||||
using Ryujinx.Horizon.Bcat.Ipc.Types;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Bcat;
|
|
||||||
using Ryujinx.Horizon.Sdk.OsTypes;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
|
||||||
{
|
|
||||||
partial class DeliveryCacheProgressService : IDeliveryCacheProgressService, IDisposable
|
|
||||||
{
|
|
||||||
private int _handle;
|
|
||||||
private SystemEventType _systemEvent;
|
|
||||||
private int _disposalState;
|
|
||||||
|
|
||||||
[CmifCommand(0)]
|
|
||||||
public Result GetEvent([CopyHandle] out int handle)
|
|
||||||
{
|
|
||||||
if (_handle == 0)
|
|
||||||
{
|
|
||||||
Os.CreateSystemEvent(out _systemEvent, EventClearMode.ManualClear, true).AbortOnFailure();
|
|
||||||
|
|
||||||
_handle = Os.GetReadableHandleOfSystemEvent(ref _systemEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = _handle;
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
|
||||||
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(1)]
|
|
||||||
public Result GetImpl([Buffer(HipcBufferFlags.Out | HipcBufferFlags.Pointer, 0x200)] out DeliveryCacheProgressImpl deliveryCacheProgressImpl)
|
|
||||||
{
|
|
||||||
deliveryCacheProgressImpl = new DeliveryCacheProgressImpl
|
|
||||||
{
|
|
||||||
State = DeliveryCacheProgressImpl.Status.Done,
|
|
||||||
Result = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
|
||||||
|
|
||||||
return Result.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_handle != 0 && Interlocked.Exchange(ref _disposalState, 1) == 0)
|
|
||||||
{
|
|
||||||
Os.DestroySystemEvent(ref _systemEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,74 +0,0 @@
|
|||||||
using LibHac.Bcat;
|
|
||||||
using LibHac.Common;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Bcat;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
|
||||||
{
|
|
||||||
partial class DeliveryCacheStorageService : IDeliveryCacheStorageService, IDisposable
|
|
||||||
{
|
|
||||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> _libHacService;
|
|
||||||
private int _disposalState;
|
|
||||||
|
|
||||||
public DeliveryCacheStorageService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> libHacService)
|
|
||||||
{
|
|
||||||
_libHacService = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>.CreateMove(ref libHacService);
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(0)]
|
|
||||||
public Result CreateFileService(out IDeliveryCacheFileService service)
|
|
||||||
{
|
|
||||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>();
|
|
||||||
|
|
||||||
var resultCode = _libHacService.Get.CreateFileService(ref libHacService.Ref);
|
|
||||||
|
|
||||||
if (resultCode.IsSuccess())
|
|
||||||
{
|
|
||||||
service = new DeliveryCacheFileService(ref libHacService.Ref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
service = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultCode.ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(1)]
|
|
||||||
public Result CreateDirectoryService(out IDeliveryCacheDirectoryService service)
|
|
||||||
{
|
|
||||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>();
|
|
||||||
|
|
||||||
var resultCode = _libHacService.Get.CreateDirectoryService(ref libHacService.Ref);
|
|
||||||
|
|
||||||
if (resultCode.IsSuccess())
|
|
||||||
{
|
|
||||||
service = new DeliveryCacheDirectoryService(ref libHacService.Ref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
service = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultCode.ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[CmifCommand(10)]
|
|
||||||
public Result EnumerateDeliveryCacheDirectory(out int count, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DirectoryName> directoryNames)
|
|
||||||
{
|
|
||||||
return _libHacService.Get.EnumerateDeliveryCacheDirectory(out count, directoryNames).ToHorizonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
|
||||||
{
|
|
||||||
_libHacService.Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,10 +0,0 @@
|
|||||||
namespace Ryujinx.Horizon.Bcat.Types
|
|
||||||
{
|
|
||||||
enum BcatPortIndex
|
|
||||||
{
|
|
||||||
Admin,
|
|
||||||
Manager,
|
|
||||||
User,
|
|
||||||
System
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,10 +0,0 @@
|
|||||||
namespace Ryujinx.Horizon.Bcat.Types
|
|
||||||
{
|
|
||||||
enum BcatServicePermissionLevel
|
|
||||||
{
|
|
||||||
Admin = -1,
|
|
||||||
User = 1,
|
|
||||||
System = 2,
|
|
||||||
Manager = 6
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,5 +1,3 @@
|
|||||||
using LibHac;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon
|
namespace Ryujinx.Horizon
|
||||||
{
|
{
|
||||||
public struct HorizonOptions
|
public struct HorizonOptions
|
||||||
@@ -7,13 +5,10 @@ namespace Ryujinx.Horizon
|
|||||||
public bool IgnoreMissingServices { get; }
|
public bool IgnoreMissingServices { get; }
|
||||||
public bool ThrowOnInvalidCommandIds { get; }
|
public bool ThrowOnInvalidCommandIds { get; }
|
||||||
|
|
||||||
public HorizonClient BcatClient { get; }
|
public HorizonOptions(bool ignoreMissingServices)
|
||||||
|
|
||||||
public HorizonOptions(bool ignoreMissingServices, HorizonClient bcatClient)
|
|
||||||
{
|
{
|
||||||
IgnoreMissingServices = ignoreMissingServices;
|
IgnoreMissingServices = ignoreMissingServices;
|
||||||
ThrowOnInvalidCommandIds = true;
|
ThrowOnInvalidCommandIds = true;
|
||||||
BcatClient = bcatClient;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Common;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon
|
|
||||||
{
|
|
||||||
internal static class LibHacResultExtensions
|
|
||||||
{
|
|
||||||
public static Result ToHorizonResult(this LibHac.Result result)
|
|
||||||
{
|
|
||||||
return new Result((int)result.Module, (int)result.Description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,12 +9,12 @@ namespace Ryujinx.Horizon.Prepo
|
|||||||
private const int PrepoMaxSessionsCount = 12;
|
private const int PrepoMaxSessionsCount = 12;
|
||||||
private const int PrepoTotalMaxSessionsCount = PrepoMaxSessionsCount * 6;
|
private const int PrepoTotalMaxSessionsCount = PrepoMaxSessionsCount * 6;
|
||||||
|
|
||||||
private const int PointerBufferSize = 0x80;
|
private const int PointerBufferSize = 0x3800;
|
||||||
private const int MaxDomains = 64;
|
private const int MaxDomains = 64;
|
||||||
private const int MaxDomainObjects = 16;
|
private const int MaxDomainObjects = 16;
|
||||||
private const int MaxPortsCount = 6;
|
private const int MaxPortsCount = 6;
|
||||||
|
|
||||||
private static readonly ManagerOptions _prepoManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
private static readonly ManagerOptions _logManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||||
|
|
||||||
private SmApi _sm;
|
private SmApi _sm;
|
||||||
private PrepoServerManager _serverManager;
|
private PrepoServerManager _serverManager;
|
||||||
@@ -26,7 +26,7 @@ namespace Ryujinx.Horizon.Prepo
|
|||||||
_sm = new SmApi();
|
_sm = new SmApi();
|
||||||
_sm.Initialize().AbortOnFailure();
|
_sm.Initialize().AbortOnFailure();
|
||||||
|
|
||||||
_serverManager = new PrepoServerManager(allocator, _sm, MaxPortsCount, _prepoManagerOptions, PrepoTotalMaxSessionsCount);
|
_serverManager = new PrepoServerManager(allocator, _sm, MaxPortsCount, _logManagerOptions, PrepoTotalMaxSessionsCount);
|
||||||
|
|
||||||
_serverManager.RegisterServer((int)PrepoPortIndex.Admin, ServiceName.Encode("prepo:a"), PrepoMaxSessionsCount); // 1.0.0-5.1.0
|
_serverManager.RegisterServer((int)PrepoPortIndex.Admin, ServiceName.Encode("prepo:a"), PrepoMaxSessionsCount); // 1.0.0-5.1.0
|
||||||
_serverManager.RegisterServer((int)PrepoPortIndex.Admin2, ServiceName.Encode("prepo:a2"), PrepoMaxSessionsCount); // 6.0.0+
|
_serverManager.RegisterServer((int)PrepoPortIndex.Admin2, ServiceName.Encode("prepo:a2"), PrepoMaxSessionsCount); // 6.0.0+
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
|
||||||
{
|
|
||||||
internal interface IBcatService : IServiceObject
|
|
||||||
{
|
|
||||||
Result RequestSyncDeliveryCache(out IDeliveryCacheProgressService deliveryCacheProgressService);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
using LibHac.Bcat;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
|
||||||
{
|
|
||||||
internal interface IDeliveryCacheDirectoryService : IServiceObject
|
|
||||||
{
|
|
||||||
Result GetCount(out int count);
|
|
||||||
Result Open(DirectoryName directoryName);
|
|
||||||
Result Read(out int entriesRead, Span<DeliveryCacheDirectoryEntry> entriesBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
using LibHac.Bcat;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
|
||||||
{
|
|
||||||
internal interface IDeliveryCacheFileService : IServiceObject
|
|
||||||
{
|
|
||||||
Result GetDigest(out Digest digest);
|
|
||||||
Result GetSize(out long size);
|
|
||||||
Result Open(DirectoryName directoryName, FileName fileName);
|
|
||||||
Result Read(long offset, out long bytesRead, Span<byte> data);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Bcat.Ipc.Types;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
|
||||||
{
|
|
||||||
internal interface IDeliveryCacheProgressService : IServiceObject
|
|
||||||
{
|
|
||||||
Result GetEvent(out int handle);
|
|
||||||
Result GetImpl(out DeliveryCacheProgressImpl deliveryCacheProgressImpl);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
using LibHac.Bcat;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
|
||||||
{
|
|
||||||
internal interface IDeliveryCacheStorageService : IServiceObject
|
|
||||||
{
|
|
||||||
Result CreateDirectoryService(out IDeliveryCacheDirectoryService service);
|
|
||||||
Result CreateFileService(out IDeliveryCacheFileService service);
|
|
||||||
Result EnumerateDeliveryCacheDirectory(out int count, Span<DirectoryName> directoryNames);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
|
||||||
{
|
|
||||||
internal interface IServiceCreator : IServiceObject
|
|
||||||
{
|
|
||||||
Result CreateBcatService(out IBcatService service, ulong pid);
|
|
||||||
Result CreateDeliveryCacheStorageService(out IDeliveryCacheStorageService service, ulong pid);
|
|
||||||
Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, Ncm.ApplicationId applicationId);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,4 +1,3 @@
|
|||||||
using Ryujinx.Horizon.Bcat;
|
|
||||||
using Ryujinx.Horizon.LogManager;
|
using Ryujinx.Horizon.LogManager;
|
||||||
using Ryujinx.Horizon.Prepo;
|
using Ryujinx.Horizon.Prepo;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -24,7 +23,6 @@ namespace Ryujinx.Horizon
|
|||||||
|
|
||||||
RegisterService<LmMain>();
|
RegisterService<LmMain>();
|
||||||
RegisterService<PrepoMain>();
|
RegisterService<PrepoMain>();
|
||||||
RegisterService<BcatMain>();
|
|
||||||
|
|
||||||
_totalServices = entries.Count;
|
_totalServices = entries.Count;
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.Memory.Tracking
|
namespace Ryujinx.Memory.Tracking
|
||||||
@@ -443,6 +444,16 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
return Address < address + size && address < EndAddress;
|
return Address < address + size && address < EndAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if this handle's memory range matches another exactly.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other">The other handle</param>
|
||||||
|
/// <returns>True on a match, false otherwise</returns>
|
||||||
|
public bool RangeEquals(RegionHandle other)
|
||||||
|
{
|
||||||
|
return RealAddress == other.RealAddress && RealSize == other.RealSize;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose the handle. Within the tracking lock, this removes references from virtual regions.
|
/// Dispose the handle. Within the tracking lock, this removes references from virtual regions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -270,7 +270,13 @@ namespace Ryujinx.Ui.Widgets
|
|||||||
|
|
||||||
int index = Nca.GetSectionIndexFromType(ncaSectionType, mainNca.Header.ContentType);
|
int index = Nca.GetSectionIndexFromType(ncaSectionType, mainNca.Header.ContentType);
|
||||||
|
|
||||||
IFileSystem ncaFileSystem = patchNca != null ? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
bool sectionExistsInPatch = false;
|
||||||
|
if (patchNca != null)
|
||||||
|
{
|
||||||
|
sectionExistsInPatch = patchNca.CanOpenSection(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
IFileSystem ncaFileSystem = sectionExistsInPatch ? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
||||||
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
|
||||||
FileSystemClient fsClient = _horizonClient.Fs;
|
FileSystemClient fsClient = _horizonClient.Fs;
|
||||||
@@ -460,16 +466,16 @@ namespace Ryujinx.Ui.Widgets
|
|||||||
|
|
||||||
private void OpenTitleModDir_Clicked(object sender, EventArgs args)
|
private void OpenTitleModDir_Clicked(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
string modsBasePath = _virtualFileSystem.ModLoader.GetModsBasePath();
|
string modsBasePath = ModLoader.GetModsBasePath();
|
||||||
string titleModsPath = _virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, _titleIdText);
|
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, _titleIdText);
|
||||||
|
|
||||||
OpenHelper.OpenFolder(titleModsPath);
|
OpenHelper.OpenFolder(titleModsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenTitleSdModDir_Clicked(object sender, EventArgs args)
|
private void OpenTitleSdModDir_Clicked(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
string sdModsBasePath = _virtualFileSystem.ModLoader.GetSdModsBasePath();
|
string sdModsBasePath = ModLoader.GetSdModsBasePath();
|
||||||
string titleModsPath = _virtualFileSystem.ModLoader.GetTitleDir(sdModsBasePath, _titleIdText);
|
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, _titleIdText);
|
||||||
|
|
||||||
OpenHelper.OpenFolder(titleModsPath);
|
OpenHelper.OpenFolder(titleModsPath);
|
||||||
}
|
}
|
||||||
|
@@ -28,8 +28,8 @@ namespace Ryujinx.Ui.Windows
|
|||||||
builder.Autoconnect(this);
|
builder.Autoconnect(this);
|
||||||
_baseTitleInfoLabel.Text = $"Cheats Available for {titleName} [{titleId:X16}]";
|
_baseTitleInfoLabel.Text = $"Cheats Available for {titleName} [{titleId:X16}]";
|
||||||
|
|
||||||
string modsBasePath = virtualFileSystem.ModLoader.GetModsBasePath();
|
string modsBasePath = ModLoader.GetModsBasePath();
|
||||||
string titleModsPath = virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, titleId.ToString("X16"));
|
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId.ToString("X16"));
|
||||||
|
|
||||||
_enabledCheatsPath = System.IO.Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
_enabledCheatsPath = System.IO.Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Adds an update to this list</property>
|
<property name="tooltip_text" translatable="yes">Adds a DLC to this list</property>
|
||||||
<property name="margin_left">10</property>
|
<property name="margin_left">10</property>
|
||||||
<signal name="clicked" handler="AddButton_Clicked" swapped="no"/>
|
<signal name="clicked" handler="AddButton_Clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Removes the selected update</property>
|
<property name="tooltip_text" translatable="yes">Removes the selected DLC</property>
|
||||||
<property name="margin_left">10</property>
|
<property name="margin_left">10</property>
|
||||||
<signal name="clicked" handler="RemoveButton_Clicked" swapped="no"/>
|
<signal name="clicked" handler="RemoveButton_Clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Removes the selected update</property>
|
<property name="tooltip_text" translatable="yes">Removes all DLCs</property>
|
||||||
<property name="margin_left">10</property>
|
<property name="margin_left">10</property>
|
||||||
<signal name="clicked" handler="RemoveAllButton_Clicked" swapped="no"/>
|
<signal name="clicked" handler="RemoveAllButton_Clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
|
@@ -133,7 +133,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Removes the selected update</property>
|
<property name="tooltip_text" translatable="yes">Removes all the updates</property>
|
||||||
<property name="margin_left">10</property>
|
<property name="margin_left">10</property>
|
||||||
<signal name="clicked" handler="RemoveAllButton_Clicked" swapped="no"/>
|
<signal name="clicked" handler="RemoveAllButton_Clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
|
Reference in New Issue
Block a user