[common] make unswizzle settings be able to be configured for all powers of 2 from 2^1 to 2^16

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2026-05-05 01:14:26 +00:00
parent fee603f0b9
commit cb872dfc90
4 changed files with 19 additions and 66 deletions

View file

@ -560,20 +560,26 @@ struct Values {
SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
Category::RendererHacks};
SwitchableSetting<GpuUnswizzleSize> gpu_unswizzle_texture_size{linkage,
GpuUnswizzleSize::Large,
SwitchableSetting<u32, true> gpu_unswizzle_texture_size{linkage,
6,
1,
16,
"gpu_unswizzle_texture_size",
Category::RendererHacks,
Specialization::Default};
SwitchableSetting<GpuUnswizzle> gpu_unswizzle_stream_size{linkage,
GpuUnswizzle::Medium,
SwitchableSetting<u32, true> gpu_unswizzle_stream_size{linkage,
4,
1,
16,
"gpu_unswizzle_stream_size",
Category::RendererHacks,
Specialization::Default};
SwitchableSetting<GpuUnswizzleChunk> gpu_unswizzle_chunk_size{linkage,
GpuUnswizzleChunk::Medium,
SwitchableSetting<u32, true> gpu_unswizzle_chunk_size{linkage,
7,
1,
16,
"gpu_unswizzle_chunk_size",
Category::RendererHacks,
Specialization::Default};

View file

@ -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)

View file

@ -234,16 +234,16 @@ std::unique_ptr<TranslationMap> 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<ComboboxTranslationMap> ComboboxEnumeration(QObject* parent) {
PAIR(GpuOverclock, Medium, tr("Medium (256)")),
PAIR(GpuOverclock, High, tr("High (512)")),
}});
translations->insert({Settings::EnumMetadata<Settings::GpuUnswizzleSize>::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<Settings::GpuUnswizzle>::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<Settings::GpuUnswizzleChunk>::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<Settings::ExtendedDynamicState>::Index(),
{
PAIR(ExtendedDynamicState, Disabled, tr("Disabled")),

View file

@ -76,35 +76,10 @@ TextureCache<P>::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;