From 4c3d2d5d75c46a522d55c0a3ae6820255294517c Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 6 May 2023 15:35:46 +0200 Subject: [PATCH] UI: Add progress bar for re-packaging shaders (#4805) * feat: introduce new shader loading state for progress tracking when writing shaders to disk * fix: move translation to bottom of locale file * fix: change back to foreach and add requested spacing between lines * style: fix formatting Co-authored-by: gdkchan --------- Co-authored-by: gdkchan --- src/Ryujinx.Ava/Assets/Locales/en_US.json | 3 ++- src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs | 4 ++++ .../Shader/DiskCache/ParallelDiskCacheLoader.cs | 6 ++++++ src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx.Ava/Assets/Locales/en_US.json b/src/Ryujinx.Ava/Assets/Locales/en_US.json index 617cad34f7..965dfa3a52 100644 --- a/src/Ryujinx.Ava/Assets/Locales/en_US.json +++ b/src/Ryujinx.Ava/Assets/Locales/en_US.json @@ -644,5 +644,6 @@ "UserEditorTitleCreate" : "Create User", "SettingsTabNetworkInterface": "Network Interface:", "NetworkInterfaceTooltip": "The network interface used for LAN features", - "NetworkInterfaceDefault": "Default" + "NetworkInterfaceDefault": "Default", + "PackagingShaders": "Packaging Shaders" } diff --git a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs index b5c82d6558..4db78afeb0 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs @@ -1099,6 +1099,10 @@ namespace Ryujinx.Ava.UI.ViewModels LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingShaders]; IsLoadingIndeterminate = false; break; + case ShaderCacheLoadingState.Packaging: + LoadHeading = LocaleManager.Instance[LocaleKeys.PackagingShaders]; + IsLoadingIndeterminate = false; + break; case ShaderCacheLoadingState.Loaded: LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, TitleName); IsLoadingIndeterminate = true; diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs index 77fb3ca4bc..58e5c7b10e 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs @@ -299,10 +299,13 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache if (_programList.Count != 0) { + _stateChangeCallback(ShaderCacheState.Packaging, 0, _programList.Count); + Logger.Info?.Print(LogClass.Gpu, $"Rebuilding {_programList.Count} shaders..."); using var streams = _hostStorage.GetOutputStreams(_context); + int packagedShaders = 0; foreach (var kv in _programList) { if (!Active) @@ -311,7 +314,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache } (CachedShaderProgram program, byte[] binaryCode) = kv.Value; + _hostStorage.AddShader(_context, program, binaryCode, streams); + + _stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count); } Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {_programList.Count} shaders successfully."); diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs index 623b73d79b..b94a6c054d 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs @@ -7,6 +7,8 @@ namespace Ryujinx.Graphics.Gpu.Shader Start, /// Shader cache is loading Loading, + /// Shader cache is written to disk + Packaging, /// Shader cache finished loading Loaded }