From d53225835aa5a4f2e050897f6f2be838566e6c96 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Thu, 20 Nov 2025 01:41:22 -0400 Subject: [PATCH] [vk] Toggle for LDR degradation with sRGB --- src/android/app/src/main/res/values/strings.xml | 6 +++++- src/common/settings.h | 4 ++++ src/qt_common/config/shared_translation.cpp | 7 ++++++- src/video_core/renderer_vulkan/maxwell_to_vk.cpp | 12 ++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index c37987691f..049b0f286a 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -954,7 +954,11 @@ Force Identity Swizzle - Forces identity component swizzle for storage and input attachment images. Required by Vulkan spec. Disable only for debugging driver issues. + Forces identity component swizzle for storage and input attachment images. Required by Vulkan spec. Disable if graphical issues. + + + Force LDR to sRGB + Converts LDR texture formats to sRGB for proper gamma correction. Fixes washed out colors on Adreno GPUs. Enable if textures look too bright or desaturated. VRAM Usage Mode diff --git a/src/common/settings.h b/src/common/settings.h index 4f6dda8f21..f5b3081be7 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -461,6 +461,10 @@ struct Values { false, "force_identity_swizzle", Category::RendererAdvanced}; + SwitchableSetting force_ldr_to_srgb{linkage, + false, + "force_ldr_to_srgb", + Category::RendererAdvanced}; SwitchableSetting vram_usage_mode{linkage, VramUsageMode::Conservative, "vram_usage_mode", diff --git a/src/qt_common/config/shared_translation.cpp b/src/qt_common/config/shared_translation.cpp index 2699c05daa..30f84812d4 100644 --- a/src/qt_common/config/shared_translation.cpp +++ b/src/qt_common/config/shared_translation.cpp @@ -204,8 +204,13 @@ std::unique_ptr InitializeTranslations(QObject* parent) INSERT(Settings, force_identity_swizzle, tr("Force Identity Swizzle"), - tr("Forces identity component swizzle for storage and input attachment images.\n" + tr("Forces identity component swizzle for storage and input attachment images. " "Required by Vulkan spec. Disable only for debugging driver issues.")); + INSERT(Settings, + force_ldr_to_srgb, + tr("Force LDR Formats to sRGB"), + tr("Converts LDR texture formats (RGBA8_UNORM, A2B10G10R10_UNORM) to sRGB variants. " + "Fixes gamma correction issues on some games. Enable for correct colors on Adreno GPUs.")); INSERT(Settings, use_disk_shader_cache, tr("Use persistent pipeline cache"), diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index 213c9ab765..7c7f37051c 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp @@ -241,6 +241,18 @@ FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with PixelFormat pixel_format) { ASSERT(static_cast(pixel_format) < std::size(tex_format_tuples)); FormatTuple tuple = tex_format_tuples[static_cast(pixel_format)]; + + // Force LDR formats to sRGB when toggle is enabled (fixes gamma on Adreno GPUs) + if (Settings::values.force_ldr_to_srgb.GetValue() && !with_srgb) { + if (pixel_format == PixelFormat::A8B8G8R8_UNORM) { + tuple.format = VK_FORMAT_A8B8G8R8_SRGB_PACK32; + with_srgb = true; // Ensure we use sRGB variant + } else if (pixel_format == PixelFormat::A2B10G10R10_UNORM) { + // A2B10G10R10 doesn't have sRGB variant in Vulkan, keep as UNORM + // The gamma correction will be handled by shaders if needed + } + } + // Transcode on hardware that doesn't support ASTC natively if (!device.IsOptimalAstcSupported() && VideoCore::Surface::IsPixelFormatASTC(pixel_format)) { const bool is_srgb = with_srgb && VideoCore::Surface::IsPixelFormatSRGB(pixel_format);