From cac4345db9aa78f1752b22c32cec6ca940ac9e67 Mon Sep 17 00:00:00 2001 From: Gamer64 Date: Sun, 29 Jun 2025 17:07:14 +0000 Subject: [PATCH] [vk] Sample Shading Option . This seems to improve some games graphics and it may be helpful for MSAA, at the cost of reducing a bit the performance. Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Co-authored-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/235 Co-authored-by: Gamer64 Co-committed-by: Gamer64 --- .../yuzu_emu/features/settings/model/BooleanSetting.kt | 1 + .../yuzu_emu/features/settings/model/view/SettingsItem.kt | 7 +++++++ .../features/settings/ui/SettingsFragmentPresenter.kt | 1 + src/android/app/src/main/res/values/strings.xml | 2 ++ src/common/settings.h | 1 + src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 5 ++++- src/yuzu/configuration/shared_translation.cpp | 7 +++++++ 7 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt index 4c527163c8..cdfbe88152 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt @@ -27,6 +27,7 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting { RENDERER_DEBUG("debug"), RENDERER_PROVOKING_VERTEX("provoking_vertex"), RENDERER_DESCRIPTOR_INDEXING("descriptor_indexing"), + RENDERER_SAMPLE_SHADING("sample_shading"), PICTURE_IN_PICTURE("picture_in_picture"), USE_CUSTOM_RTC("custom_rtc_enabled"), BLACK_BACKGROUNDS("black_backgrounds"), 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 b52355e255..9782aa4d2b 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 @@ -152,6 +152,13 @@ abstract class SettingsItem( descriptionId = R.string.descriptor_indexing_description ) ) + put( + SwitchSetting( + BooleanSetting.RENDERER_SAMPLE_SHADING, + titleId = R.string.sample_shading, + descriptionId = R.string.sample_shading_description + ) + ) put( SliderSetting( ShortSetting.RENDERER_SPEED_LIMIT, 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 2337bc5821..f8f381db41 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 @@ -435,6 +435,7 @@ class SettingsFragmentPresenter( add(ByteSetting.RENDERER_DYNA_STATE.key) add(BooleanSetting.RENDERER_PROVOKING_VERTEX.key) add(BooleanSetting.RENDERER_DESCRIPTOR_INDEXING.key) + add(BooleanSetting.RENDERER_SAMPLE_SHADING.key) add(HeaderSetting(R.string.veil_renderer)) add(BooleanSetting.FRAME_INTERPOLATION.key) diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index d09da35546..7f05e4f985 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -74,6 +74,8 @@ Improves lighting and vertex handling in certain games. Only supported on Vulkan 1.0+ GPUs. Descriptor Indexing Improves texture and buffer handling, as well as the Maxwell translation layer. Supported by some Vulkan 1.1 GPUs and all Vulkan 1.2+ GPUs. + Sample Shading + Allows the fragment shader to execute per sample in a multi-sampled fragment instead once per fragment. Improves graphics quality at the cost of some performance. Only Vulkan 1.1+ devices support this extension. Renderer Enhanced Frame Pacing diff --git a/src/common/settings.h b/src/common/settings.h index b6e091ab50..e4239a3032 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -509,6 +509,7 @@ struct Values { SwitchableSetting provoking_vertex{linkage, false, "provoking_vertex", Category::RendererExtensions}; SwitchableSetting descriptor_indexing{linkage, false, "descriptor_indexing", Category::RendererExtensions}; + SwitchableSetting sample_shading{linkage, false, "sample_shading", Category::RendererExtensions}; Setting renderer_debug{linkage, false, "debug", Category::RendererDebug}; Setting renderer_shader_feedback{linkage, false, "shader_feedback", diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 4b4331d2f4..ee431bb731 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -735,7 +738,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { .pNext = nullptr, .flags = 0, .rasterizationSamples = MaxwellToVK::MsaaMode(key.state.msaa_mode), - .sampleShadingEnable = VK_FALSE, + .sampleShadingEnable = Settings::values.sample_shading.GetValue() ? VK_TRUE : VK_FALSE, .minSampleShading = 0.0f, .pSampleMask = nullptr, .alphaToCoverageEnable = key.state.alpha_to_coverage_enabled != 0 ? VK_TRUE : VK_FALSE, diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index 28eb2108f8..f4484ce35b 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -349,6 +349,13 @@ std::unique_ptr InitializeTranslations(QWidget* parent) tr("Improves texture & buffer handling and the Maxwell translation layer.\n" "Some Vulkan 1.1+ and all 1.2+ devices support this extension.")); + INSERT(Settings, + sample_shading, + tr("Sample Shading"), + tr("Allows the fragment shader to execute per sample in a multi-sampled fragment " + "instead once per fragment. Improves graphics quality at the cost of some performance.\n" + "Only Vulkan 1.1+ devices support this extension.")); + // Renderer (Debug) // System