From e3ea6f2059a3c85acf0e0f4096c89cddc75a0933 Mon Sep 17 00:00:00 2001 From: spectranator Date: Sat, 6 Jul 2024 22:39:54 +0200 Subject: [PATCH 1/5] Revert "Added abgr8 srgb to d24s8 conversion shader" This reverts commit e8f43b7078d8f16bb9dc4a8682bf416c37621129. --- src/video_core/host_shaders/CMakeLists.txt | 1 - .../convert_abgr8_srgb_to_d24s8.frag | 45 ------------------- src/video_core/renderer_vulkan/blit_image.cpp | 9 ---- src/video_core/renderer_vulkan/blit_image.h | 5 --- .../renderer_vulkan/vk_texture_cache.cpp | 3 -- 5 files changed, 63 deletions(-) delete mode 100644 src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 18c04390e6..969f21d509 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -18,7 +18,6 @@ set(SHADER_FILES blit_color_float.frag block_linear_unswizzle_2d.comp block_linear_unswizzle_3d.comp - convert_abgr8_srgb_to_d24s8.frag convert_abgr8_to_d24s8.frag convert_abgr8_to_d32f.frag convert_d32f_to_abgr8.frag diff --git a/src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag b/src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag deleted file mode 100644 index 3e037af74d..0000000000 --- a/src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -#version 450 -#extension GL_ARB_shader_stencil_export : require - -precision highp int; -precision highp float; - -layout(binding = 0) uniform sampler2D color_texture; - -// Utility function to convert sRGB to linear space -highp float srgbToLinear(highp float srgb) { - if (srgb <= 0.04045) - return srgb / 12.92; - else - return pow((srgb + 0.055) / 1.055, 2.4); -} - -void main() { - ivec2 coord = ivec2(gl_FragCoord.xy); - - // Fetch sRGB color and convert to linear space - vec4 srgbColor = texelFetch(color_texture, coord, 0); - highp float r_linear = srgbToLinear(srgbColor.r); - highp float g_linear = srgbToLinear(srgbColor.g); - highp float b_linear = srgbToLinear(srgbColor.b); - - // Compute luminance for depth - highp float luminance = 0.2126 * r_linear + 0.7152 * g_linear + 0.0722 * b_linear; - highp uint depth_val = uint(luminance * (exp2(24.0) - 1.0)); - - // Extract the stencil value from the alpha component - highp uint stencil_val = uint(srgbColor.a * (exp2(8) - 1.0)); - - // Pack stencil and depth values into a single uint - highp uint byte0 = stencil_val << 24; - highp uint byte1 = (depth_val & 0x00FF0000u) >> 16; - highp uint byte2 = (depth_val & 0x0000FF00u) >> 8; - highp uint byte3 = depth_val & 0x000000FFu; - highp uint depth_stencil_unorm = byte0 | (byte1 << 16) | (byte2 << 8) | byte3; - - // Set depth and stencil values for the fragment - gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0); - gl_FragStencilRefARB = int(depth_stencil_unorm >> 24); -} diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index 23bf2b73bb..c3db09424e 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp @@ -7,7 +7,6 @@ #include "common/settings.h" #include "video_core/host_shaders/blit_color_float_frag_spv.h" -#include "video_core/host_shaders/convert_abgr8_srgb_to_d24s8_frag_spv.h" #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" #include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h" #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" @@ -435,7 +434,6 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_, clear_stencil_frag(BuildShader(device, VULKAN_DEPTHSTENCIL_CLEAR_FRAG_SPV)), convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)), convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), - convert_abgr8_srgb_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_SRGB_TO_D24S8_FRAG_SPV)), convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), convert_abgr8_to_d32f_frag(BuildShader(device, CONVERT_ABGR8_TO_D32F_FRAG_SPV)), convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)), @@ -556,13 +554,6 @@ void BlitImageHelper::ConvertR16ToD16(const Framebuffer* dst_framebuffer, Convert(*convert_r16_to_d16_pipeline, dst_framebuffer, src_image_view); } -void BlitImageHelper::ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipelineDepthTargetEx(convert_abgr8_srgb_to_d24s8_pipeline, - dst_framebuffer->RenderPass(), convert_abgr8_srgb_to_d24s8_frag); - Convert(*convert_abgr8_srgb_to_d24s8_pipeline, dst_framebuffer, src_image_view); -} - void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view) { ConvertPipelineDepthTargetEx(convert_abgr8_to_d24s8_pipeline, dst_framebuffer->RenderPass(), diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index 76d384dd6f..b2104a59ee 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h @@ -67,9 +67,6 @@ public: void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); - void ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view); - void ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); @@ -134,7 +131,6 @@ private: vk::ShaderModule clear_stencil_frag; vk::ShaderModule convert_depth_to_float_frag; vk::ShaderModule convert_float_to_depth_frag; - vk::ShaderModule convert_abgr8_srgb_to_d24s8_frag; vk::ShaderModule convert_abgr8_to_d24s8_frag; vk::ShaderModule convert_abgr8_to_d32f_frag; vk::ShaderModule convert_d32f_to_abgr8_frag; @@ -155,7 +151,6 @@ private: vk::Pipeline convert_r32_to_d32_pipeline; vk::Pipeline convert_d16_to_r16_pipeline; vk::Pipeline convert_r16_to_d16_pipeline; - vk::Pipeline convert_abgr8_srgb_to_d24s8_pipeline; vk::Pipeline convert_abgr8_to_d24s8_pipeline; vk::Pipeline convert_abgr8_to_d32f_pipeline; vk::Pipeline convert_d32f_to_abgr8_pipeline; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 2280f9174f..1426a08702 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1235,9 +1235,6 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im src_view.format == PixelFormat::B8G8R8A8_UNORM) { return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view); } - if (src_view.format == PixelFormat::A8B8G8R8_SRGB) { - return blit_image_helper.ConvertABGR8SRGBToD24S8(dst, src_view); - } break; case PixelFormat::D32_FLOAT: if (src_view.format == PixelFormat::A8B8G8R8_UNORM || From 238c5e33dd4e0ed7ac0fc07ef62db4e8a67b8d8a Mon Sep 17 00:00:00 2001 From: spectranator Date: Thu, 11 Jul 2024 23:44:48 +0200 Subject: [PATCH 2/5] Updated README for new mirror repository --- README.md | 45 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index edd27bcb15..0284b1e2d4 100644 --- a/README.md +++ b/README.md @@ -16,41 +16,6 @@ SPDX-License-Identifier: GPL-2.0-or-later It is written in C++ with portability in mind and runs on Linux and Windows -## !!! PENDING GITHUB MIRROR TAKEDOWN !!! - -I have received a takedown notice from GitHub! - -``` -Hi litucks, - -GitHub Trust & Safety is contacting you because we've received a DMCA takedown notice regarding the following content: - -https://github.com/litucks/torzu - -You can see the DMCA takedown notice that we received here, which includes the complainant's requested changes to your repository: - -https://enterprise.githubsupport.com/attachments/token/IRkbmN2s4Pu7U7fwBNZ2hXYoP/?name=2024-07-05-nintendo.rtf - -We want to make clear that it is never our desire or goal to take down open source projects, but instead to help developers address DMCA concerns with their projects. To that end, you have some options: - -1. If you choose to make changes in response to this takedown notice, you'll have 1 business day to make the requested changes. Once you've made the changes, please reply to this message and let us know. If you don't tell us that you've made changes within the next 1 business day, we'll need to disable the entire repository according to our GitHub DMCA Takedown Policy - https://docs.github.com/en/github/site-policy/dmca-takedown-policy - -If you need to remove specific content from your repository, simply making the repository private or deleting it via a commit won't resolve the alleged infringement. Instead, you must follow these instructions to remove the content from your repository's history, even if you don't think it's sensitive - https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/removing-sensitive-data-from-a-repository - -2. If you believe your content on GitHub was mistakenly identified by a DMCA takedown request, you have the right to contest the takedown by submitting a counter notice, as described in our DMCA Takedown Policy - https://docs.github.com/en/github/site-policy/dmca-takedown-policy - -We want to help ensure you can make informed decisions when responding to this takedown request. To help, we have partnered with leading legal providers who can help you evaluate the takedown request and determine how to respond at no cost to you. If you are interested in receiving legal support through this program (https://github.blog/2021-07-27-github-developer-rights-fellowship-stanford-law-school/), reply to this message to let us know that. - -It is important that you reply to this message within 1 business day regardless of which option you choose. If you do not, the repository will be disabled. - -Please let us know if you have any questions or need any help removing the content. - -Regards, -GitHub Trust & Safety -``` - -The next mirror repository is going to be at: https://codeberg.org/litucks/torzu (repo privatized until then) unless anything comes in the way. Otherwise you can use the button in the "About" menu of the emulator to get to the current mirror repository or simply check out the [main repository](http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu). - ## Limited public development I feel like working publicly on this has taken away the fun. You may not understand, but it's quite stressful to have the public eye on a project. @@ -100,14 +65,18 @@ To clone this git repository, you can use these commands given tor is installed cd torzu git submodule update --init --depth 1 --recursive -Alternatively, you can clone from the [GitHub mirror repository](https://github.com/litucks/torzu): +Alternatively, you can clone from the [Codeberg mirror repository](https://codeberg.org/litucks/torzu): - git clone https://github.com/litucks/torzu.git --depth 1 --recursive + git clone https://codeberg.org/litucks/torzu.git --depth 1 --recursive -Note that above repository may be taken down any time. Do not rely on its existence in production. In case the GitHub mirror goes down, another mirror will be most likely be set up on Bitbucket. +Note that above repository may be taken down any time. Do not rely on its existence in production. In case the Codeberg mirror goes down, another mirror will be most likely be set up on Bitbucket. This project incorporates several commits from the [Suyu](https://suyu.dev) and [Sudachi](https://github.com/sudachi-emu/sudachi) forks (but cleaned up due to the typically mediocre code/commit quality from both projects) as well as changes listed in **Changes**. +## GitHub mirror repository + +The GitHub mirror repository has been taken down. The new mirror repository is located on [Codeberg](https://codeberg.org/litucks/torzu). + ## Building * __Linux__: [Linux Build](http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/wiki/Building-for-Linux) From 32b2991a530dbe528cfaf6de8c3c9b2f2b38ccac Mon Sep 17 00:00:00 2001 From: anon Date: Thu, 11 Jul 2024 22:15:04 +0000 Subject: [PATCH 3/5] Update README.md for logo location (#8) Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/8 Co-authored-by: anon Co-committed-by: anon --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0284b1e2d4..7f21f82c25 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-2.0-or-later


- torzu + torzu
torzu
From 224ec030703d10ecfccc8713598243a62ab3190c Mon Sep 17 00:00:00 2001 From: spectranator Date: Thu, 11 Jul 2024 22:26:03 +0000 Subject: [PATCH 4/5] Added note about fake websites to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7f21f82c25..cefaa77d72 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ SPDX-License-Identifier: GPL-2.0-or-later It is written in C++ with portability in mind and runs on Linux and Windows

+## Fake websites + +A lot of fake Torzu websites have popped up. These are not mine. **This project will not have a clearnet website for the foreseeable future!** +I highly advice against downloading anything from these websites, specially if their intention is clearly to make money through advertisements. + ## Limited public development I feel like working publicly on this has taken away the fun. You may not understand, but it's quite stressful to have the public eye on a project. From 7e27e6476d69a83c77ea322da8981bafde16d715 Mon Sep 17 00:00:00 2001 From: echosys Date: Fri, 19 Jul 2024 19:14:19 +0000 Subject: [PATCH 5/5] Add option to only optimize SPIRV during load (#13) Adds a new option "On Load" to the "Optimize SPIRV output" option that turns on optimizations during the loading of the shader cache from disk, but turns it off after that. The previous checkbox states have been named "Never" for unchecked and "Always" for checked. The idea is that once the shader cache has most of the shaders in a game cached they can be optimized during initial game startup (where a performance hit matters less) and the few shaders that get compiled during runtime are not optimized to reduce performance hits. Most of the commit is adding the setting to the Android app, the main logic is in the `gl_shader_cache.cpp` and `vk_pipeline_cache.cpp` files. Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/13 Co-authored-by: echosys Co-committed-by: echosys --- .../yuzu_emu/features/settings/model/IntSetting.kt | 1 + .../yuzu/yuzu_emu/features/settings/model/Settings.kt | 11 +++++++++++ .../features/settings/model/view/SettingsItem.kt | 9 +++++++++ .../features/settings/ui/SettingsFragmentPresenter.kt | 1 + src/android/app/src/main/res/values/arrays.xml | 11 +++++++++++ src/android/app/src/main/res/values/strings.xml | 6 ++++++ src/common/settings.cpp | 1 + src/common/settings.h | 9 +++++++-- src/common/settings_enums.h | 2 ++ src/video_core/renderer_opengl/gl_shader_cache.cpp | 10 +++++++--- src/video_core/renderer_opengl/gl_shader_cache.h | 1 + src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 11 +++++++---- src/video_core/renderer_vulkan/vk_pipeline_cache.h | 1 + src/yuzu/configuration/shared_translation.cpp | 6 ++++++ src/yuzu/uisettings.h | 1 + 15 files changed, 72 insertions(+), 9 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt index 0165cb2d1d..c6d83c346f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt @@ -18,6 +18,7 @@ enum class IntSetting(override val key: String) : AbstractIntSetting { RENDERER_ANTI_ALIASING("anti_aliasing"), RENDERER_SCREEN_LAYOUT("screen_layout"), RENDERER_ASPECT_RATIO("aspect_ratio"), + RENDERER_OPTIMIZE_SPIRV_OUTPUT("optimize_spirv_output"), AUDIO_OUTPUT_ENGINE("output_engine"), MAX_ANISOTROPY("max_anisotropy"), THEME("theme"), diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index 4f6b93bd2e..8a4cfd9827 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt @@ -117,4 +117,15 @@ object Settings { entries.firstOrNull { it.int == int } ?: Center } } + + enum class OptimizeSpirvOutput(val int: Int) { + Never(0), + OnLoad(1), + Always(2); + + companion object { + fun from(int: Int): OptimizeSpirvOutput = + entries.firstOrNull { it.int == int } ?: OnLoad + } + } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index 5fdf983185..3690e28a81 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt @@ -291,6 +291,15 @@ abstract class SettingsItem( descriptionId = R.string.renderer_force_max_clock_description ) ) + put( + SingleChoiceSetting( + IntSetting.RENDERER_OPTIMIZE_SPIRV_OUTPUT, + titleId = R.string.renderer_optimize_spirv_output, + descriptionId = 0, + choicesId = R.array.optimizeSpirvOutputEntries, + valuesId = R.array.optimizeSpirvOutputValues + ) + ) put( SwitchSetting( BooleanSetting.RENDERER_ASYNCHRONOUS_SHADERS, diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 3ea5f50081..e627e7f84f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -177,6 +177,7 @@ class SettingsFragmentPresenter( add(IntSetting.RENDERER_SCREEN_LAYOUT.key) add(IntSetting.RENDERER_ASPECT_RATIO.key) add(IntSetting.VERTICAL_ALIGNMENT.key) + add(IntSetting.RENDERER_OPTIMIZE_SPIRV_OUTPUT.key) add(BooleanSetting.PICTURE_IN_PICTURE.key) add(BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE.key) add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key) diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 1bd6455b4c..3da4a48c8b 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml @@ -303,4 +303,15 @@ 2 + + @string/never + @string/on_load + @string/always + + + 0 + 1 + 2 + + diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 4fbfa6d1d8..2ce5198eca 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -234,6 +234,7 @@ Anti-aliasing method Force maximum clocks (Adreno only) Forces the GPU to run at the maximum possible clocks (thermal constraints will still be applied). + Optimize SPIRV output Use asynchronous shaders Compiles shaders asynchronously, reducing stutter but may introduce glitches. Use reactive flushing @@ -662,6 +663,11 @@ Center Bottom + + Never + On Load + Always + Licenses FidelityFX-FSR diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 80d388fe88..245c432939 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -52,6 +52,7 @@ SWITCHABLE(NvdecEmulation, false); SWITCHABLE(Region, true); SWITCHABLE(RendererBackend, true); SWITCHABLE(ScalingFilter, false); +SWITCHABLE(SpirvOptimizeMode, true); SWITCHABLE(ShaderBackend, true); SWITCHABLE(TimeZone, true); SETTING(VSyncMode, true); diff --git a/src/common/settings.h b/src/common/settings.h index 21775c465a..1190a1bbfd 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -73,6 +73,7 @@ SWITCHABLE(NvdecEmulation, false); SWITCHABLE(Region, true); SWITCHABLE(RendererBackend, true); SWITCHABLE(ScalingFilter, false); +SWITCHABLE(SpirvOptimizeMode, true); SWITCHABLE(ShaderBackend, true); SWITCHABLE(TimeZone, true); SETTING(VSyncMode, true); @@ -278,8 +279,12 @@ struct Values { SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; - SwitchableSetting optimize_spirv_output{linkage, false, "optimize_spirv_output", - Category::Renderer}; + SwitchableSetting optimize_spirv_output{linkage, + SpirvOptimizeMode::OnLoad, + SpirvOptimizeMode::Never, + SpirvOptimizeMode::Always, + "optimize_spirv_output", + Category::Renderer}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; SwitchableSetting accelerate_astc{linkage, diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 6e247e9306..a636154413 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -155,6 +155,8 @@ ENUM(ConsoleMode, Handheld, Docked); ENUM(AppletMode, HLE, LLE); +ENUM(SpirvOptimizeMode, Never, OnLoad, Always) + template inline std::string CanonicalizeEnum(Type id) { const auto group = EnumMetadata::Canonicalizations(); diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 4801c803eb..81af54f216 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp @@ -178,6 +178,7 @@ ShaderCache::ShaderCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, state_tracker{state_tracker_}, shader_notify{shader_notify_}, use_asynchronous_shaders{device.UseAsynchronousShaders()}, strict_context_required{device.StrictContextRequired()}, + optimize_spirv_output{Settings::values.optimize_spirv_output.GetValue() != Settings::SpirvOptimizeMode::Never}, profile{ .supported_spirv = 0x00010000, @@ -344,6 +345,10 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading, if (!use_asynchronous_shaders) { workers.reset(); } + + if (Settings::values.optimize_spirv_output.GetValue() != Settings::SpirvOptimizeMode::Always) { + this->optimize_spirv_output = false; + } } GraphicsPipeline* ShaderCache::CurrentGraphicsPipeline() { @@ -538,8 +543,7 @@ std::unique_ptr ShaderCache::CreateGraphicsPipeline( case Settings::ShaderBackend::SpirV: ConvertLegacyToGeneric(program, runtime_info); sources_spirv[stage_index] = - EmitSPIRV(profile, runtime_info, program, binding, - Settings::values.optimize_spirv_output.GetValue()); + EmitSPIRV(profile, runtime_info, program, binding, this->optimize_spirv_output); break; } previous_program = &program; @@ -598,7 +602,7 @@ std::unique_ptr ShaderCache::CreateComputePipeline( code = EmitGLASM(profile, info, program); break; case Settings::ShaderBackend::SpirV: - code_spirv = EmitSPIRV(profile, program, Settings::values.optimize_spirv_output.GetValue()); + code_spirv = EmitSPIRV(profile, program, this->optimize_spirv_output); break; } diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 5ac4135295..2b46c22c70 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h @@ -73,6 +73,7 @@ private: VideoCore::ShaderNotify& shader_notify; const bool use_asynchronous_shaders; const bool strict_context_required; + bool optimize_spirv_output{}; GraphicsPipelineKey graphics_key{}; GraphicsPipeline* current_pipeline{}; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 4fbd321c4b..4c95461c8a 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -310,6 +310,7 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, texture_cache{texture_cache_}, shader_notify{shader_notify_}, use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()}, use_vulkan_pipeline_cache{Settings::values.use_vulkan_driver_pipeline_cache.GetValue()}, + optimize_spirv_output{Settings::values.optimize_spirv_output.GetValue() != Settings::SpirvOptimizeMode::Never}, workers(device.HasBrokenParallelShaderCompiling() ? 1ULL : GetTotalPipelineWorkers(), "VkPipelineBuilder"), serialization_thread(1, "VkPipelineSerialization") { @@ -564,6 +565,10 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading if (state.statistics) { state.statistics->Report(); } + + if (Settings::values.optimize_spirv_output.GetValue() != Settings::SpirvOptimizeMode::Always) { + this->optimize_spirv_output = false; + } } GraphicsPipeline* PipelineCache::CurrentGraphicsPipelineSlowPath() { @@ -673,8 +678,7 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( const auto runtime_info{MakeRuntimeInfo(programs, key, program, previous_stage)}; ConvertLegacyToGeneric(program, runtime_info); - const std::vector code{EmitSPIRV(profile, runtime_info, program, binding, - Settings::values.optimize_spirv_output.GetValue())}; + const std::vector code{EmitSPIRV(profile, runtime_info, program, binding, this->optimize_spirv_output)}; device.SaveShader(code); modules[stage_index] = BuildShader(device, code); if (device.HasDebuggingToolAttached()) { @@ -768,8 +772,7 @@ std::unique_ptr PipelineCache::CreateComputePipeline( } auto program{TranslateProgram(pools.inst, pools.block, env, cfg, host_info)}; - const std::vector code{ - EmitSPIRV(profile, program, Settings::values.optimize_spirv_output.GetValue())}; + const std::vector code{EmitSPIRV(profile, program, this->optimize_spirv_output)}; device.SaveShader(code); vk::ShaderModule spv_module{BuildShader(device, code)}; if (device.HasDebuggingToolAttached()) { diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 7977001280..7909bd8cf0 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -150,6 +150,7 @@ private: VideoCore::ShaderNotify& shader_notify; bool use_asynchronous_shaders{}; bool use_vulkan_pipeline_cache{}; + bool optimize_spirv_output{}; GraphicsPipelineCacheKey graphics_key{}; GraphicsPipeline* current_pipeline{}; diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index 56ee9f0002..6c08c5a57d 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -319,6 +319,12 @@ std::unique_ptr ComboboxEnumeration(QWidget* parent) { PAIR(AppletMode, LLE, tr("Real applet")), }}); + translations->insert({Settings::EnumMetadata::Index(), + { + PAIR(SpirvOptimizeMode, Never, tr("Never")), + PAIR(SpirvOptimizeMode, OnLoad, tr("On Load")), + PAIR(SpirvOptimizeMode, Always, tr("Always")), + }}); translations->insert({Settings::EnumMetadata::Index(), { PAIR(AstcDecodeMode, Cpu, tr("CPU")), diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index e9059d50d1..fb5988b673 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -277,3 +277,4 @@ Q_DECLARE_METATYPE(Settings::RendererBackend); Q_DECLARE_METATYPE(Settings::ShaderBackend); Q_DECLARE_METATYPE(Settings::AstcRecompression); Q_DECLARE_METATYPE(Settings::AstcDecodeMode); +Q_DECLARE_METATYPE(Settings::SpirvOptimizeMode);