Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
470a8031a4 | ||
|
5440d4ad5c | ||
|
dde208b480 | ||
|
4c3d2d5d75 | ||
|
fab11ba3f1 | ||
|
332891b5ff | ||
|
7df4fcada7 | ||
|
d6698680be | ||
|
e5c9838b0b | ||
|
f8ec878796 | ||
|
9ff21f9ab6 | ||
|
aa021085cf | ||
|
1f5d881860 |
@@ -590,6 +590,7 @@
|
|||||||
"DlcWindowTitle": "Manage Downloadable Content for {0} ({1})",
|
"DlcWindowTitle": "Manage Downloadable Content for {0} ({1})",
|
||||||
"UpdateWindowTitle": "Title Update Manager",
|
"UpdateWindowTitle": "Title Update Manager",
|
||||||
"CheatWindowHeading": "Cheats Available for {0} [{1}]",
|
"CheatWindowHeading": "Cheats Available for {0} [{1}]",
|
||||||
|
"BuildId": "BuildId:",
|
||||||
"DlcWindowHeading": "{0} Downloadable Content(s)",
|
"DlcWindowHeading": "{0} Downloadable Content(s)",
|
||||||
"UserProfilesEditProfile": "Edit Selected",
|
"UserProfilesEditProfile": "Edit Selected",
|
||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
@@ -644,5 +645,6 @@
|
|||||||
"UserEditorTitleCreate" : "Create User",
|
"UserEditorTitleCreate" : "Create User",
|
||||||
"SettingsTabNetworkInterface": "Network Interface:",
|
"SettingsTabNetworkInterface": "Network Interface:",
|
||||||
"NetworkInterfaceTooltip": "The network interface used for LAN features",
|
"NetworkInterfaceTooltip": "The network interface used for LAN features",
|
||||||
"NetworkInterfaceDefault": "Default"
|
"NetworkInterfaceDefault": "Default",
|
||||||
|
"PackagingShaders": "Packaging Shaders"
|
||||||
}
|
}
|
||||||
|
@@ -233,9 +233,14 @@ namespace Ryujinx.Ava.Common
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IFileSystem ncaFileSystem = patchNca != null
|
bool sectionExistsInPatch = false;
|
||||||
? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
if (patchNca != null)
|
||||||
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
{
|
||||||
|
sectionExistsInPatch = patchNca.CanOpenSection(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
IFileSystem ncaFileSystem = sectionExistsInPatch ? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
||||||
|
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
|
||||||
FileSystemClient fsClient = _horizonClient.Fs;
|
FileSystemClient fsClient = _horizonClient.Fs;
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem Header="{locale:Locale GameListContextMenuExtractData}">
|
<MenuItem Header="{locale:Locale GameListContextMenuExtractData}">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Click="ExtractApplicationLogo_Click"
|
Click="ExtractApplicationExeFs_Click"
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataExeFS}"
|
Header="{locale:Locale GameListContextMenuExtractDataExeFS}"
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataExeFSToolTip}" />
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataExeFSToolTip}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
Header="{locale:Locale GameListContextMenuExtractDataRomFS}"
|
Header="{locale:Locale GameListContextMenuExtractDataRomFS}"
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" />
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Click="ExtractApplicationExeFs_Click"
|
Click="ExtractApplicationLogo_Click"
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@@ -10,6 +10,7 @@ using Ryujinx.Ava.UI.Helpers;
|
|||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Ava.UI.Windows;
|
using Ryujinx.Ava.UI.Windows;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Ryujinx.Ui.App.Common;
|
||||||
using Ryujinx.HLE.HOS;
|
using Ryujinx.HLE.HOS;
|
||||||
using Ryujinx.Ui.Common.Helper;
|
using Ryujinx.Ui.Common.Helper;
|
||||||
using System;
|
using System;
|
||||||
@@ -118,7 +119,11 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
|
|
||||||
if (viewModel?.SelectedApplication != null)
|
if (viewModel?.SelectedApplication != null)
|
||||||
{
|
{
|
||||||
await new CheatWindow(viewModel.VirtualFileSystem, viewModel.SelectedApplication.TitleId, viewModel.SelectedApplication.TitleName).ShowDialog(viewModel.TopLevel as Window);
|
await new CheatWindow(
|
||||||
|
viewModel.VirtualFileSystem,
|
||||||
|
viewModel.SelectedApplication.TitleId,
|
||||||
|
viewModel.SelectedApplication.TitleName,
|
||||||
|
viewModel.SelectedApplication.Path).ShowDialog(viewModel.TopLevel as Window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,13 +294,13 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ExtractApplicationLogo_Click(object sender, RoutedEventArgs args)
|
public async void ExtractApplicationExeFs_Click(object sender, RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
if (viewModel?.SelectedApplication != null)
|
if (viewModel?.SelectedApplication != null)
|
||||||
{
|
{
|
||||||
await ApplicationHelper.ExtractSection(NcaSectionType.Logo, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
await ApplicationHelper.ExtractSection(NcaSectionType.Code, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,13 +314,13 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ExtractApplicationExeFs_Click(object sender, RoutedEventArgs args)
|
public async void ExtractApplicationLogo_Click(object sender, RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||||
|
|
||||||
if (viewModel?.SelectedApplication != null)
|
if (viewModel?.SelectedApplication != null)
|
||||||
{
|
{
|
||||||
await ApplicationHelper.ExtractSection(NcaSectionType.Code, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
await ApplicationHelper.ExtractSection(NcaSectionType.Logo, viewModel.SelectedApplication.Path, viewModel.SelectedApplication.TitleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1099,6 +1099,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingShaders];
|
LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingShaders];
|
||||||
IsLoadingIndeterminate = false;
|
IsLoadingIndeterminate = false;
|
||||||
break;
|
break;
|
||||||
|
case ShaderCacheLoadingState.Packaging:
|
||||||
|
LoadHeading = LocaleManager.Instance[LocaleKeys.PackagingShaders];
|
||||||
|
IsLoadingIndeterminate = false;
|
||||||
|
break;
|
||||||
case ShaderCacheLoadingState.Loaded:
|
case ShaderCacheLoadingState.Loaded:
|
||||||
LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, TitleName);
|
LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, TitleName);
|
||||||
IsLoadingIndeterminate = true;
|
IsLoadingIndeterminate = true;
|
||||||
|
@@ -11,6 +11,7 @@ using Ryujinx.Common;
|
|||||||
using Ryujinx.Common.Utilities;
|
using Ryujinx.Common.Utilities;
|
||||||
using Ryujinx.HLE.HOS;
|
using Ryujinx.HLE.HOS;
|
||||||
using Ryujinx.Modules;
|
using Ryujinx.Modules;
|
||||||
|
using Ryujinx.Ui.App.Common;
|
||||||
using Ryujinx.Ui.Common;
|
using Ryujinx.Ui.Common;
|
||||||
using Ryujinx.Ui.Common.Configuration;
|
using Ryujinx.Ui.Common.Configuration;
|
||||||
using Ryujinx.Ui.Common.Helper;
|
using Ryujinx.Ui.Common.Helper;
|
||||||
@@ -176,7 +177,11 @@ namespace Ryujinx.Ava.UI.Views.Main
|
|||||||
|
|
||||||
string name = ViewModel.AppHost.Device.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)ViewModel.AppHost.Device.System.State.DesiredTitleLanguage].NameString.ToString();
|
string name = ViewModel.AppHost.Device.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)ViewModel.AppHost.Device.System.State.DesiredTitleLanguage].NameString.ToString();
|
||||||
|
|
||||||
await new CheatWindow(Window.VirtualFileSystem, ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText, name).ShowDialog(Window);
|
await new CheatWindow(
|
||||||
|
Window.VirtualFileSystem,
|
||||||
|
ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText,
|
||||||
|
name,
|
||||||
|
Window.ViewModel.SelectedApplication.Path).ShowDialog(Window);
|
||||||
|
|
||||||
ViewModel.AppHost.Device.EnableCheats();
|
ViewModel.AppHost.Device.EnableCheats();
|
||||||
}
|
}
|
||||||
|
@@ -21,23 +21,52 @@
|
|||||||
</Window.Styles>
|
</Window.Styles>
|
||||||
<Grid Name="CheatGrid" Margin="15">
|
<Grid Name="CheatGrid" Margin="15">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
MaxWidth="500"
|
MaxWidth="500"
|
||||||
Margin="20,15,20,20"
|
Margin="20,15,20,5"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
LineHeight="18"
|
LineHeight="18"
|
||||||
Text="{Binding Heading}"
|
Text="{Binding Heading}"
|
||||||
TextAlignment="Center"
|
TextAlignment="Center"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
<Border
|
<TextBlock
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
|
Grid.Column="0"
|
||||||
|
MaxWidth="500"
|
||||||
|
Margin="140,15,20,5"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
LineHeight="30"
|
||||||
|
Text="{locale:Locale BuildId}"
|
||||||
|
TextAlignment="Center"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="0,5,110,5"
|
||||||
|
MinWidth="160"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding BuildId}"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<Border
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
@@ -81,7 +110,9 @@
|
|||||||
</TreeView>
|
</TreeView>
|
||||||
</Border>
|
</Border>
|
||||||
<DockPanel
|
<DockPanel
|
||||||
Grid.Row="3"
|
Grid.Row="4"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
HorizontalAlignment="Stretch">
|
HorizontalAlignment="Stretch">
|
||||||
<DockPanel Margin="0" HorizontalAlignment="Right">
|
<DockPanel Margin="0" HorizontalAlignment="Right">
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
using Avalonia.Collections;
|
using Avalonia;
|
||||||
|
using Avalonia.Collections;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Models;
|
using Ryujinx.Ava.UI.Models;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.HOS;
|
using Ryujinx.HLE.HOS;
|
||||||
|
using Ryujinx.Ui.App.Common;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -17,6 +19,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
private AvaloniaList<CheatsList> LoadedCheats { get; }
|
private AvaloniaList<CheatsList> LoadedCheats { get; }
|
||||||
|
|
||||||
public string Heading { get; }
|
public string Heading { get; }
|
||||||
|
public string BuildId { get; }
|
||||||
|
|
||||||
public CheatWindow()
|
public CheatWindow()
|
||||||
{
|
{
|
||||||
@@ -27,12 +30,13 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle];
|
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle];
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName)
|
public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath)
|
||||||
{
|
{
|
||||||
LoadedCheats = new AvaloniaList<CheatsList>();
|
LoadedCheats = new AvaloniaList<CheatsList>();
|
||||||
|
|
||||||
Heading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.CheatWindowHeading, titleName, titleId.ToUpper());
|
Heading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.CheatWindowHeading, titleName, titleId.ToUpper());
|
||||||
|
BuildId = ApplicationData.GetApplicationBuildId(virtualFileSystem, titlePath);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
string modsBasePath = ModLoader.GetModsBasePath();
|
string modsBasePath = ModLoader.GetModsBasePath();
|
||||||
|
@@ -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;
|
||||||
@@ -879,4 +879,4 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
Array.Clear(_imageState);
|
Array.Clear(_imageState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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";
|
||||||
|
@@ -299,10 +299,13 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
|
|
||||||
if (_programList.Count != 0)
|
if (_programList.Count != 0)
|
||||||
{
|
{
|
||||||
|
_stateChangeCallback(ShaderCacheState.Packaging, 0, _programList.Count);
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Gpu, $"Rebuilding {_programList.Count} shaders...");
|
Logger.Info?.Print(LogClass.Gpu, $"Rebuilding {_programList.Count} shaders...");
|
||||||
|
|
||||||
using var streams = _hostStorage.GetOutputStreams(_context);
|
using var streams = _hostStorage.GetOutputStreams(_context);
|
||||||
|
|
||||||
|
int packagedShaders = 0;
|
||||||
foreach (var kv in _programList)
|
foreach (var kv in _programList)
|
||||||
{
|
{
|
||||||
if (!Active)
|
if (!Active)
|
||||||
@@ -311,7 +314,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
(CachedShaderProgram program, byte[] binaryCode) = kv.Value;
|
(CachedShaderProgram program, byte[] binaryCode) = kv.Value;
|
||||||
|
|
||||||
_hostStorage.AddShader(_context, program, binaryCode, streams);
|
_hostStorage.AddShader(_context, program, binaryCode, streams);
|
||||||
|
|
||||||
|
_stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {_programList.Count} shaders successfully.");
|
Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {_programList.Count} shaders successfully.");
|
||||||
|
@@ -7,6 +7,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
Start,
|
Start,
|
||||||
/// <summary>Shader cache is loading</summary>
|
/// <summary>Shader cache is loading</summary>
|
||||||
Loading,
|
Loading,
|
||||||
|
/// <summary>Shader cache is written to disk</summary>
|
||||||
|
Packaging,
|
||||||
/// <summary>Shader cache finished loading</summary>
|
/// <summary>Shader cache finished loading</summary>
|
||||||
Loaded
|
Loaded
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
else
|
||||||
{
|
{
|
||||||
node = ReplaceLdgWithLdc(node, config, storageIndex);
|
// 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(
|
||||||
|
@@ -200,9 +200,10 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
LibHacHorizonManager = device.Configuration.LibHacHorizonManager;
|
LibHacHorizonManager = device.Configuration.LibHacHorizonManager;
|
||||||
|
|
||||||
|
// We hardcode a clock source id to avoid it changing between each start.
|
||||||
// TODO: use set:sys (and get external clock source id from settings)
|
// TODO: use set:sys (and get external clock source id from settings)
|
||||||
// TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate.
|
// TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate.
|
||||||
UInt128 clockSourceId = UInt128Utils.CreateRandom();
|
UInt128 clockSourceId = new UInt128(0x36a0328702ce8bc1, 0x1608eaba02333284);
|
||||||
IRtcManager.GetExternalRtcValue(out ulong rtcValue);
|
IRtcManager.GetExternalRtcValue(out ulong rtcValue);
|
||||||
|
|
||||||
// We assume the rtc is system time.
|
// We assume the rtc is system time.
|
||||||
@@ -222,22 +223,22 @@ namespace Ryujinx.HLE.HOS
|
|||||||
internalOffset = internalOffset.AddSeconds(-3600L);
|
internalOffset = internalOffset.AddSeconds(-3600L);
|
||||||
}
|
}
|
||||||
|
|
||||||
internalOffset = new TimeSpanType(-internalOffset.NanoSeconds);
|
systemTime = new TimeSpanType(systemTime.NanoSeconds + internalOffset.NanoSeconds);
|
||||||
|
|
||||||
// First init the standard steady clock
|
// First init the standard steady clock
|
||||||
TimeServiceManager.Instance.SetupStandardSteadyClock(TickSource, clockSourceId, systemTime, internalOffset, TimeSpanType.Zero, false);
|
TimeServiceManager.Instance.SetupStandardSteadyClock(TickSource, clockSourceId, TimeSpanType.Zero, TimeSpanType.Zero, TimeSpanType.Zero, false);
|
||||||
TimeServiceManager.Instance.SetupStandardLocalSystemClock(TickSource, new SystemClockContext(), systemTime.ToSeconds());
|
TimeServiceManager.Instance.SetupStandardLocalSystemClock(TickSource, new SystemClockContext(), systemTime.ToSeconds());
|
||||||
|
TimeServiceManager.Instance.StandardLocalSystemClock.GetClockContext(TickSource, out SystemClockContext localSytemClockContext);
|
||||||
|
|
||||||
if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes))
|
if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes))
|
||||||
{
|
{
|
||||||
TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000);
|
TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000);
|
||||||
|
|
||||||
// The network system clock needs a valid system clock, as such we setup this system clock using the local system clock.
|
// The network system clock needs a valid system clock, as such we setup this system clock using the local system clock.
|
||||||
TimeServiceManager.Instance.StandardLocalSystemClock.GetClockContext(TickSource, out SystemClockContext localSytemClockContext);
|
|
||||||
TimeServiceManager.Instance.SetupStandardNetworkSystemClock(localSytemClockContext, standardNetworkClockSufficientAccuracy);
|
TimeServiceManager.Instance.SetupStandardNetworkSystemClock(localSytemClockContext, standardNetworkClockSufficientAccuracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeServiceManager.Instance.SetupStandardUserSystemClock(TickSource, false, SteadyClockTimePoint.GetRandom());
|
TimeServiceManager.Instance.SetupStandardUserSystemClock(TickSource, true, localSytemClockContext.SteadyTimePoint);
|
||||||
|
|
||||||
// FIXME: TimeZone should be init here but it's actually done in ContentManager
|
// FIXME: TimeZone should be init here but it's actually done in ContentManager
|
||||||
|
|
||||||
|
@@ -92,6 +92,15 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandCmif(23)]
|
||||||
|
// GetAppletCommonFunctions() -> object<nn::am::service::IAppletCommonFunctions>
|
||||||
|
public ResultCode GetAppletCommonFunctions(ServiceCtx context)
|
||||||
|
{
|
||||||
|
MakeObject(context, new IAppletCommonFunctions());
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandCmif(1000)]
|
[CommandCmif(1000)]
|
||||||
// GetDebugFunctions() -> object<nn::am::service::IDebugFunctions>
|
// GetDebugFunctions() -> object<nn::am::service::IDebugFunctions>
|
||||||
public ResultCode GetDebugFunctions(ServiceCtx context)
|
public ResultCode GetDebugFunctions(ServiceCtx context)
|
||||||
|
@@ -9,8 +9,10 @@ using System;
|
|||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
|
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
|
||||||
{
|
{
|
||||||
class ICommonStateGetter : IpcService
|
class ICommonStateGetter : DisposableIpcService
|
||||||
{
|
{
|
||||||
|
private readonly ServiceCtx _context;
|
||||||
|
|
||||||
private Apm.ManagerServer _apmManagerServer;
|
private Apm.ManagerServer _apmManagerServer;
|
||||||
private Apm.SystemManagerServer _apmSystemManagerServer;
|
private Apm.SystemManagerServer _apmSystemManagerServer;
|
||||||
private Lbl.LblControllerServer _lblControllerServer;
|
private Lbl.LblControllerServer _lblControllerServer;
|
||||||
@@ -23,11 +25,18 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
private int _messageEventHandle;
|
private int _messageEventHandle;
|
||||||
private int _displayResolutionChangedEventHandle;
|
private int _displayResolutionChangedEventHandle;
|
||||||
|
|
||||||
|
private KEvent _acquiredSleepLockEvent;
|
||||||
|
private int _acquiredSleepLockEventHandle;
|
||||||
|
|
||||||
public ICommonStateGetter(ServiceCtx context)
|
public ICommonStateGetter(ServiceCtx context)
|
||||||
{
|
{
|
||||||
|
_context = context;
|
||||||
|
|
||||||
_apmManagerServer = new Apm.ManagerServer(context);
|
_apmManagerServer = new Apm.ManagerServer(context);
|
||||||
_apmSystemManagerServer = new Apm.SystemManagerServer(context);
|
_apmSystemManagerServer = new Apm.SystemManagerServer(context);
|
||||||
_lblControllerServer = new Lbl.LblControllerServer(context);
|
_lblControllerServer = new Lbl.LblControllerServer(context);
|
||||||
|
|
||||||
|
_acquiredSleepLockEvent = new KEvent(context.Device.System.KernelContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(0)]
|
[CommandCmif(0)]
|
||||||
@@ -117,6 +126,34 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandCmif(10)]
|
||||||
|
// RequestToAcquireSleepLock()
|
||||||
|
public ResultCode RequestToAcquireSleepLock(ServiceCtx context)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandCmif(13)]
|
||||||
|
// GetAcquiredSleepLockEvent() -> handle<copy>
|
||||||
|
public ResultCode GetAcquiredSleepLockEvent(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (_acquiredSleepLockEventHandle == 0)
|
||||||
|
{
|
||||||
|
if (context.Process.HandleTable.GenerateHandle(_acquiredSleepLockEvent.ReadableEvent, out _acquiredSleepLockEventHandle) != Result.Success)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Out of handles!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_acquiredSleepLockEventHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandCmif(50)] // 3.0.0+
|
[CommandCmif(50)] // 3.0.0+
|
||||||
// IsVrModeEnabled() -> b8
|
// IsVrModeEnabled() -> b8
|
||||||
public ResultCode IsVrModeEnabled(ServiceCtx context)
|
public ResultCode IsVrModeEnabled(ServiceCtx context)
|
||||||
@@ -281,5 +318,17 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (isDisposing)
|
||||||
|
{
|
||||||
|
if (_acquiredSleepLockEventHandle != 0)
|
||||||
|
{
|
||||||
|
_context.Process.HandleTable.CloseHandle(_acquiredSleepLockEventHandle);
|
||||||
|
_acquiredSleepLockEventHandle = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Time.Clock.Types
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
struct ContinuousAdjustmentTimePoint
|
||||||
|
{
|
||||||
|
public ulong ClockOffset;
|
||||||
|
public long Multiplier;
|
||||||
|
public long DivisorLog2;
|
||||||
|
public SystemClockContext Context;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +1,8 @@
|
|||||||
using Ryujinx.Cpu;
|
using Ryujinx.Cpu;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||||
using Ryujinx.HLE.HOS.Services.Time.Clock;
|
using Ryujinx.HLE.HOS.Services.Time.Clock;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Time.Clock.Types;
|
||||||
using Ryujinx.HLE.HOS.Services.Time.Types;
|
using Ryujinx.HLE.HOS.Services.Time.Types;
|
||||||
using Ryujinx.HLE.Utilities;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -16,10 +16,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||||||
private SharedMemoryStorage _timeSharedMemoryStorage;
|
private SharedMemoryStorage _timeSharedMemoryStorage;
|
||||||
private int _timeSharedMemorySize;
|
private int _timeSharedMemorySize;
|
||||||
|
|
||||||
private const uint SteadyClockContextOffset = 0x00;
|
private const uint SteadyClockContextOffset = 0x00;
|
||||||
private const uint LocalSystemClockContextOffset = 0x38;
|
private const uint LocalSystemClockContextOffset = 0x38;
|
||||||
private const uint NetworkSystemClockContextOffset = 0x80;
|
private const uint NetworkSystemClockContextOffset = 0x80;
|
||||||
private const uint AutomaticCorrectionEnabledOffset = 0xC8;
|
private const uint AutomaticCorrectionEnabledOffset = 0xC8;
|
||||||
|
private const uint ContinuousAdjustmentTimePointOffset = 0xD0;
|
||||||
|
|
||||||
public void Initialize(Switch device, KSharedMemory sharedMemory, SharedMemoryStorage timeSharedMemoryStorage, int timeSharedMemorySize)
|
public void Initialize(Switch device, KSharedMemory sharedMemory, SharedMemoryStorage timeSharedMemoryStorage, int timeSharedMemorySize)
|
||||||
{
|
{
|
||||||
@@ -39,15 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||||||
|
|
||||||
public void SetupStandardSteadyClock(ITickSource tickSource, UInt128 clockSourceId, TimeSpanType currentTimePoint)
|
public void SetupStandardSteadyClock(ITickSource tickSource, UInt128 clockSourceId, TimeSpanType currentTimePoint)
|
||||||
{
|
{
|
||||||
TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency);
|
UpdateSteadyClock(tickSource, clockSourceId, currentTimePoint);
|
||||||
|
|
||||||
SteadyClockContext context = new SteadyClockContext
|
|
||||||
{
|
|
||||||
InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds),
|
|
||||||
ClockSourceId = clockSourceId
|
|
||||||
};
|
|
||||||
|
|
||||||
WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAutomaticCorrectionEnabled(bool isAutomaticCorrectionEnabled)
|
public void SetAutomaticCorrectionEnabled(bool isAutomaticCorrectionEnabled)
|
||||||
@@ -58,10 +51,38 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||||||
|
|
||||||
public void SetSteadyClockRawTimePoint(ITickSource tickSource, TimeSpanType currentTimePoint)
|
public void SetSteadyClockRawTimePoint(ITickSource tickSource, TimeSpanType currentTimePoint)
|
||||||
{
|
{
|
||||||
SteadyClockContext context = ReadObjectFromSharedMemory<SteadyClockContext>(SteadyClockContextOffset, 4);
|
SteadyClockContext context = ReadObjectFromSharedMemory<SteadyClockContext>(SteadyClockContextOffset, 4);
|
||||||
TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency);
|
|
||||||
|
|
||||||
context.InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds);
|
UpdateSteadyClock(tickSource, context.ClockSourceId, currentTimePoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSteadyClock(ITickSource tickSource, UInt128 clockSourceId, TimeSpanType currentTimePoint)
|
||||||
|
{
|
||||||
|
TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency);
|
||||||
|
|
||||||
|
ContinuousAdjustmentTimePoint adjustmentTimePoint = new ContinuousAdjustmentTimePoint
|
||||||
|
{
|
||||||
|
ClockOffset = (ulong)ticksTimeSpan.NanoSeconds,
|
||||||
|
Multiplier = 1,
|
||||||
|
DivisorLog2 = 0,
|
||||||
|
Context = new SystemClockContext
|
||||||
|
{
|
||||||
|
Offset = 0,
|
||||||
|
SteadyTimePoint = new SteadyClockTimePoint
|
||||||
|
{
|
||||||
|
ClockSourceId = clockSourceId,
|
||||||
|
TimePoint = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
WriteObjectToSharedMemory(ContinuousAdjustmentTimePointOffset, 4, adjustmentTimePoint);
|
||||||
|
|
||||||
|
SteadyClockContext context = new SteadyClockContext
|
||||||
|
{
|
||||||
|
InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds),
|
||||||
|
ClockSourceId = clockSourceId
|
||||||
|
};
|
||||||
|
|
||||||
WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context);
|
WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context);
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Ryujinx.HLE.Loaders.Processes
|
namespace Ryujinx.HLE.Loaders.Processes
|
||||||
{
|
{
|
||||||
public struct ProcessResult
|
public class ProcessResult
|
||||||
{
|
{
|
||||||
public static ProcessResult Failed => new(null, new ApplicationControlProperty(), false, false, null, 0, 0, 0, TitleLanguage.AmericanEnglish);
|
public static ProcessResult Failed => new(null, new ApplicationControlProperty(), false, false, null, 0, 0, 0, TitleLanguage.AmericanEnglish);
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
@@ -1,5 +1,16 @@
|
|||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Ns;
|
using LibHac.Ns;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Fs.Fsa;
|
||||||
|
using LibHac.FsSystem;
|
||||||
|
using LibHac.Loader;
|
||||||
|
using LibHac.Tools.Fs;
|
||||||
|
using LibHac.Tools.FsSystem;
|
||||||
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Ryujinx.Ui.App.Common
|
namespace Ryujinx.Ui.App.Common
|
||||||
{
|
{
|
||||||
@@ -19,5 +30,122 @@ namespace Ryujinx.Ui.App.Common
|
|||||||
public double FileSizeBytes { get; set; }
|
public double FileSizeBytes { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public BlitStruct<ApplicationControlProperty> ControlHolder { get; set; }
|
public BlitStruct<ApplicationControlProperty> ControlHolder { get; set; }
|
||||||
|
|
||||||
|
public static string GetApplicationBuildId(VirtualFileSystem virtualFileSystem, string titleFilePath)
|
||||||
|
{
|
||||||
|
using FileStream file = new(titleFilePath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
Nca mainNca = null;
|
||||||
|
Nca patchNca = null;
|
||||||
|
|
||||||
|
if (!System.IO.Path.Exists(titleFilePath))
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Application, $"File does not exists. {titleFilePath}");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
string extension = System.IO.Path.GetExtension(titleFilePath).ToLower();
|
||||||
|
|
||||||
|
if (extension is ".nsp" or ".xci")
|
||||||
|
{
|
||||||
|
PartitionFileSystem pfs;
|
||||||
|
|
||||||
|
if (extension == ".xci")
|
||||||
|
{
|
||||||
|
Xci xci = new(virtualFileSystem.KeySet, file.AsStorage());
|
||||||
|
|
||||||
|
pfs = xci.OpenPartition(XciPartitionType.Secure);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pfs = new PartitionFileSystem(file.AsStorage());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
|
||||||
|
{
|
||||||
|
using var ncaFile = new UniqueRef<IFile>();
|
||||||
|
|
||||||
|
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||||
|
|
||||||
|
Nca nca = new(virtualFileSystem.KeySet, ncaFile.Get.AsStorage());
|
||||||
|
|
||||||
|
if (nca.Header.ContentType != NcaContentType.Program)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
|
||||||
|
|
||||||
|
if (nca.Header.GetFsHeader(dataIndex).IsPatchSection())
|
||||||
|
{
|
||||||
|
patchNca = nca;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mainNca = nca;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (extension == ".nca")
|
||||||
|
{
|
||||||
|
mainNca = new Nca(virtualFileSystem.KeySet, file.AsStorage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainNca == null)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Application, "Extraction failure. The main NCA was not present in the selected file");
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
(Nca updatePatchNca, _) = ApplicationLibrary.GetGameUpdateData(virtualFileSystem, mainNca.Header.TitleId.ToString("x16"), 0, out _);
|
||||||
|
|
||||||
|
if (updatePatchNca != null)
|
||||||
|
{
|
||||||
|
patchNca = updatePatchNca;
|
||||||
|
}
|
||||||
|
|
||||||
|
IFileSystem codeFs = null;
|
||||||
|
|
||||||
|
if (patchNca == null)
|
||||||
|
{
|
||||||
|
if (mainNca.CanOpenSection(NcaSectionType.Code))
|
||||||
|
{
|
||||||
|
codeFs = mainNca.OpenFileSystem(NcaSectionType.Code, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (patchNca.CanOpenSection(NcaSectionType.Code))
|
||||||
|
{
|
||||||
|
codeFs = mainNca.OpenFileSystemWithPatch(patchNca, NcaSectionType.Code, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codeFs == null)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Loader, "No ExeFS found in NCA");
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string mainExeFs = "main";
|
||||||
|
|
||||||
|
if (!codeFs.FileExists($"/{mainExeFs}"))
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Loader, "No main binary ExeFS found in ExeFS");
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var nsoFile = new UniqueRef<IFile>();
|
||||||
|
|
||||||
|
codeFs.OpenFile(ref nsoFile.Ref, $"/{mainExeFs}".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||||
|
|
||||||
|
NsoReader reader = new NsoReader();
|
||||||
|
reader.Initialize(nsoFile.Release().AsStorage().AsFile(OpenMode.Read)).ThrowIfFailure();
|
||||||
|
|
||||||
|
return BitConverter.ToString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", "").ToUpper()[..16];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1626,9 +1626,12 @@ namespace Ryujinx.Ui
|
|||||||
|
|
||||||
private void ManageCheats_Pressed(object sender, EventArgs args)
|
private void ManageCheats_Pressed(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
var window = new CheatWindow(_virtualFileSystem,
|
var window = new CheatWindow(
|
||||||
_emulationContext.Processes.ActiveApplication.ProgramId,
|
_virtualFileSystem,
|
||||||
_emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString());
|
_emulationContext.Processes.ActiveApplication.ProgramId,
|
||||||
|
_emulationContext.Processes.ActiveApplication.ApplicationControlProperties
|
||||||
|
.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString(),
|
||||||
|
_currentEmulatedGamePath);
|
||||||
|
|
||||||
window.Destroyed += CheatWindow_Destroyed;
|
window.Destroyed += CheatWindow_Destroyed;
|
||||||
window.Show();
|
window.Show();
|
||||||
|
@@ -270,8 +270,14 @@ 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;
|
||||||
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
if (patchNca != null)
|
||||||
|
{
|
||||||
|
sectionExistsInPatch = patchNca.CanOpenSection(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
IFileSystem ncaFileSystem = sectionExistsInPatch ? mainNca.OpenFileSystemWithPatch(patchNca, index, IntegrityCheckLevel.ErrorOnInvalid)
|
||||||
|
: mainNca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
|
||||||
FileSystemClient fsClient = _horizonClient.Fs;
|
FileSystemClient fsClient = _horizonClient.Fs;
|
||||||
|
|
||||||
@@ -455,7 +461,7 @@ namespace Ryujinx.Ui.Widgets
|
|||||||
|
|
||||||
private void ManageCheats_Clicked(object sender, EventArgs args)
|
private void ManageCheats_Clicked(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
new CheatWindow(_virtualFileSystem, _titleId, _titleName).Show();
|
new CheatWindow(_virtualFileSystem, _titleId, _titleName, _titleFilePath).Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenTitleModDir_Clicked(object sender, EventArgs args)
|
private void OpenTitleModDir_Clicked(object sender, EventArgs args)
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using Gtk;
|
using Gtk;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.HOS;
|
using Ryujinx.HLE.HOS;
|
||||||
|
using Ryujinx.Ui.App.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -17,16 +18,18 @@ namespace Ryujinx.Ui.Windows
|
|||||||
|
|
||||||
#pragma warning disable CS0649, IDE0044
|
#pragma warning disable CS0649, IDE0044
|
||||||
[GUI] Label _baseTitleInfoLabel;
|
[GUI] Label _baseTitleInfoLabel;
|
||||||
|
[GUI] TextView _buildIdTextView;
|
||||||
[GUI] TreeView _cheatTreeView;
|
[GUI] TreeView _cheatTreeView;
|
||||||
[GUI] Button _saveButton;
|
[GUI] Button _saveButton;
|
||||||
#pragma warning restore CS0649, IDE0044
|
#pragma warning restore CS0649, IDE0044
|
||||||
|
|
||||||
public CheatWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName) : this(new Builder("Ryujinx.Ui.Windows.CheatWindow.glade"), virtualFileSystem, titleId, titleName) { }
|
public CheatWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName, string titlePath) : this(new Builder("Ryujinx.Ui.Windows.CheatWindow.glade"), virtualFileSystem, titleId, titleName, titlePath) { }
|
||||||
|
|
||||||
private CheatWindow(Builder builder, VirtualFileSystem virtualFileSystem, ulong titleId, string titleName) : base(builder.GetRawOwnedObject("_cheatWindow"))
|
private CheatWindow(Builder builder, VirtualFileSystem virtualFileSystem, ulong titleId, string titleName, string titlePath) : base(builder.GetRawOwnedObject("_cheatWindow"))
|
||||||
{
|
{
|
||||||
builder.Autoconnect(this);
|
builder.Autoconnect(this);
|
||||||
_baseTitleInfoLabel.Text = $"Cheats Available for {titleName} [{titleId:X16}]";
|
_baseTitleInfoLabel.Text = $"Cheats Available for {titleName} [{titleId:X16}]";
|
||||||
|
_buildIdTextView.Buffer.Text = $"BuildId: {ApplicationData.GetApplicationBuildId(virtualFileSystem, titlePath)}";
|
||||||
|
|
||||||
string modsBasePath = ModLoader.GetModsBasePath();
|
string modsBasePath = ModLoader.GetModsBasePath();
|
||||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId.ToString("X16"));
|
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId.ToString("X16"));
|
||||||
|
@@ -31,6 +31,21 @@
|
|||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTextView" id="_buildIdTextView">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="margin_top">10</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="margin_bottom">10</property>
|
||||||
|
<property name="editable">False</property>
|
||||||
|
<property name="cursor_visible">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -57,7 +72,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@@ -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