From cb872dfc9021993565caa454b61125cab83d45eb Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 5 May 2026 01:14:26 +0000 Subject: [PATCH] [common] make unswizzle settings be able to be configured for all powers of 2 from 2^1 to 2^16 Signed-off-by: lizzie --- src/common/settings.h | 18 +++++++---- src/common/settings_enums.h | 3 -- src/qt_common/config/shared_translation.cpp | 31 ++---------------- src/video_core/texture_cache/texture_cache.h | 33 +++----------------- 4 files changed, 19 insertions(+), 66 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index 9749a8df40..a9c625d584 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -560,20 +560,26 @@ struct Values { SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererHacks}; - SwitchableSetting gpu_unswizzle_texture_size{linkage, - GpuUnswizzleSize::Large, + SwitchableSetting gpu_unswizzle_texture_size{linkage, + 6, + 1, + 16, "gpu_unswizzle_texture_size", Category::RendererHacks, Specialization::Default}; - SwitchableSetting gpu_unswizzle_stream_size{linkage, - GpuUnswizzle::Medium, + SwitchableSetting gpu_unswizzle_stream_size{linkage, + 4, + 1, + 16, "gpu_unswizzle_stream_size", Category::RendererHacks, Specialization::Default}; - SwitchableSetting gpu_unswizzle_chunk_size{linkage, - GpuUnswizzleChunk::Medium, + SwitchableSetting gpu_unswizzle_chunk_size{linkage, + 7, + 1, + 16, "gpu_unswizzle_chunk_size", Category::RendererHacks, Specialization::Default}; diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 638be4127f..d369a93d8e 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -150,9 +150,6 @@ ENUM(ConsoleMode, Handheld, Docked); ENUM(AppletMode, HLE, LLE); ENUM(SpirvOptimizeMode, Never, OnLoad, Always); ENUM(GpuOverclock, Normal, Medium, High) -ENUM(GpuUnswizzleSize, VerySmall, Small, Normal, Large, VeryLarge) -ENUM(GpuUnswizzle, VeryLow, Low, Normal, Medium, High) -ENUM(GpuUnswizzleChunk, VeryLow, Low, Normal, Medium, High) ENUM(TemperatureUnits, Celsius, Fahrenheit) ENUM(ExtendedDynamicState, Disabled, EDS1, EDS2, EDS3); ENUM(GpuLogLevel, Off, Errors, Standard, Verbose, All) diff --git a/src/qt_common/config/shared_translation.cpp b/src/qt_common/config/shared_translation.cpp index 506d74084f..6144b048ed 100644 --- a/src/qt_common/config/shared_translation.cpp +++ b/src/qt_common/config/shared_translation.cpp @@ -234,16 +234,16 @@ std::unique_ptr InitializeTranslations(QObject* parent) { tr("Accelerates BCn 3D texture decoding using GPU compute.\n" "Disable if experiencing crashes or graphical glitches.")); INSERT(Settings, gpu_unswizzle_texture_size, tr("GPU Unswizzle Max Texture Size"), - tr("Sets the maximum size (MiB) for GPU-based texture unswizzling.\n" + tr("Sets the maximum size (power of 2 * 1MiB) for GPU-based texture unswizzling.\n" "While the GPU is faster for medium and large textures, the CPU may be more " "efficient for very small ones.\n" "Adjust this to find the balance between GPU acceleration and CPU overhead.")); INSERT(Settings, gpu_unswizzle_stream_size, tr("GPU Unswizzle Stream Size"), - tr("Sets the maximum amount of texture data (in MiB) processed per frame.\n" + tr("Sets the maximum amount of texture data (power of 2 * 1MiB) processed per frame.\n" "Higher values can reduce stutter during texture loading but may impact frame " "consistency.")); INSERT(Settings, gpu_unswizzle_chunk_size, tr("GPU Unswizzle Chunk Size"), - tr("Determines the number of depth slices processed in a single dispatch.\n" + tr("Determines the number of depth slices (power of 2) processed in a single dispatch.\n" "Increasing this can improve throughput on high-end GPUs but may cause TDR or driver " "timeouts on weaker hardware.")); @@ -642,31 +642,6 @@ std::unique_ptr ComboboxEnumeration(QObject* parent) { PAIR(GpuOverclock, Medium, tr("Medium (256)")), PAIR(GpuOverclock, High, tr("High (512)")), }}); - translations->insert({Settings::EnumMetadata::Index(), - { - PAIR(GpuUnswizzleSize, VerySmall, tr("Very Small (16 MB)")), - PAIR(GpuUnswizzleSize, Small, tr("Small (32 MB)")), - PAIR(GpuUnswizzleSize, Normal, tr("Normal (128 MB)")), - PAIR(GpuUnswizzleSize, Large, tr("Large (256 MB)")), - PAIR(GpuUnswizzleSize, VeryLarge, tr("Very Large (512 MB)")), - }}); - translations->insert({Settings::EnumMetadata::Index(), - { - PAIR(GpuUnswizzle, VeryLow, tr("Very Low (4 MB)")), - PAIR(GpuUnswizzle, Low, tr("Low (8 MB)")), - PAIR(GpuUnswizzle, Normal, tr("Normal (16 MB)")), - PAIR(GpuUnswizzle, Medium, tr("Medium (32 MB)")), - PAIR(GpuUnswizzle, High, tr("High (64 MB)")), - }}); - translations->insert({Settings::EnumMetadata::Index(), - { - PAIR(GpuUnswizzleChunk, VeryLow, tr("Very Low (32)")), - PAIR(GpuUnswizzleChunk, Low, tr("Low (64)")), - PAIR(GpuUnswizzleChunk, Normal, tr("Normal (128)")), - PAIR(GpuUnswizzleChunk, Medium, tr("Medium (256)")), - PAIR(GpuUnswizzleChunk, High, tr("High (512)")), - }}); - translations->insert({Settings::EnumMetadata::Index(), { PAIR(ExtendedDynamicState, Disabled, tr("Disabled")), diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 5a1c680830..daa18359ea 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -76,35 +76,10 @@ TextureCache

::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag minimum_memory = 0; } - const bool gpu_unswizzle_enabled = Settings::values.gpu_unswizzle_enabled.GetValue(); - - if (gpu_unswizzle_enabled) { - switch (Settings::values.gpu_unswizzle_texture_size.GetValue()) { - case Settings::GpuUnswizzleSize::VerySmall: gpu_unswizzle_maxsize = 16_MiB; break; - case Settings::GpuUnswizzleSize::Small: gpu_unswizzle_maxsize = 32_MiB; break; - case Settings::GpuUnswizzleSize::Normal: gpu_unswizzle_maxsize = 128_MiB; break; - case Settings::GpuUnswizzleSize::Large: gpu_unswizzle_maxsize = 256_MiB; break; - case Settings::GpuUnswizzleSize::VeryLarge: gpu_unswizzle_maxsize = 512_MiB; break; - default: gpu_unswizzle_maxsize = 128_MiB; break; - } - - switch (Settings::values.gpu_unswizzle_stream_size.GetValue()) { - case Settings::GpuUnswizzle::VeryLow: swizzle_chunk_size = 4_MiB; break; - case Settings::GpuUnswizzle::Low: swizzle_chunk_size = 8_MiB; break; - case Settings::GpuUnswizzle::Normal: swizzle_chunk_size = 16_MiB; break; - case Settings::GpuUnswizzle::Medium: swizzle_chunk_size = 32_MiB; break; - case Settings::GpuUnswizzle::High: swizzle_chunk_size = 64_MiB; break; - default: swizzle_chunk_size = 16_MiB; - } - - switch (Settings::values.gpu_unswizzle_chunk_size.GetValue()) { - case Settings::GpuUnswizzleChunk::VeryLow: swizzle_slices_per_batch = 32; break; - case Settings::GpuUnswizzleChunk::Low: swizzle_slices_per_batch = 64; break; - case Settings::GpuUnswizzleChunk::Normal: swizzle_slices_per_batch = 128; break; - case Settings::GpuUnswizzleChunk::Medium: swizzle_slices_per_batch = 256; break; - case Settings::GpuUnswizzleChunk::High: swizzle_slices_per_batch = 512; break; - default: swizzle_slices_per_batch = 128; - } + if (Settings::values.gpu_unswizzle_enabled.GetValue()) { + gpu_unswizzle_maxsize = (1 << u32(Settings::values.gpu_unswizzle_texture_size.GetValue())) * 1_MiB; + swizzle_chunk_size = (1 << u32(Settings::values.gpu_unswizzle_stream_size.GetValue())) * 1_MiB; + swizzle_slices_per_batch = 1 << u32(Settings::values.gpu_unswizzle_chunk_size.GetValue()); } else { gpu_unswizzle_maxsize = 0; swizzle_chunk_size = 0;