From 250fe865c76c6f56f050ea794607f5fac57cb5e2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 10 Apr 2024 17:38:41 +0200 Subject: [PATCH] Disable anisotropic filtering for Intel hardware when not using linear min/mag filter since its broken Change gl_texture_filter_anisotropic to use a default value that depends on whether the GPU is integrated or not --- src/common/rendering/hwrenderer/data/hw_cvars.cpp | 2 +- .../rendering/vulkan/samplers/vk_samplers.cpp | 15 ++++++++++++++- wadsrc/static/menudef.txt | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_cvars.cpp b/src/common/rendering/hwrenderer/data/hw_cvars.cpp index 97135c223..7d8c4aa3b 100644 --- a/src/common/rendering/hwrenderer/data/hw_cvars.cpp +++ b/src/common/rendering/hwrenderer/data/hw_cvars.cpp @@ -115,7 +115,7 @@ CVAR(Int, gl_satformula, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); // Texture CVARs // //========================================================================== -CUSTOM_CVARD(Float, gl_texture_filter_anisotropic, 8.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL, "changes the OpenGL texture anisotropy setting") +CUSTOM_CVARD(Float, gl_texture_filter_anisotropic, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL, "changes the texture anisotropy setting") { screen->SetTextureFilterMode(); } diff --git a/src/common/rendering/vulkan/samplers/vk_samplers.cpp b/src/common/rendering/vulkan/samplers/vk_samplers.cpp index 5ed7f23bf..33db31926 100644 --- a/src/common/rendering/vulkan/samplers/vk_samplers.cpp +++ b/src/common/rendering/vulkan/samplers/vk_samplers.cpp @@ -96,7 +96,20 @@ void VkSamplerManager::CreateHWSamplers() builder.MipmapMode(TexFilter[filter].mipfilter); if (TexFilter[filter].mipmapping) { - builder.Anisotropy(gl_texture_filter_anisotropic); + // Anisotropy puts extra load on the memory architecture. + // Unless the user explicitly chose their own filter value, default to lower filtering for integrated GPUs as they are generally slow. + float maxAnisotropy = gl_texture_filter_anisotropic; + if (maxAnisotropy < 1.0f) + { + if (fb->GetDevice()->PhysicalDevice.Properties.Properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) + maxAnisotropy = 4.0f; + else + maxAnisotropy = 8.0f; + } + + // Intel has consistently been fucking up anisotropic filtering for a decade now. Time to punish them. If they now finally implement it in their hardware/drivers it will stay disabled! + if (maxAnisotropy > 1.0f && (fb->GetDevice()->PhysicalDevice.Properties.Properties.vendorID != 8086 || (TexFilter[filter].magFilter == VK_FILTER_LINEAR && TexFilter[filter].minFilter == VK_FILTER_LINEAR))) + builder.Anisotropy(maxAnisotropy); builder.MaxLod(100.0f); // According to the spec this value is clamped so something high makes it usable for all textures. } else diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 48358d941..e20a53ff3 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2557,6 +2557,7 @@ OptionValue "FXAAQuality" OptionValue "Anisotropy" { + 0, "$OPTVAL_DEFAULT" 1, "$OPTVAL_OFF" 2, "$OPTVAL_2X" 4, "$OPTVAL_4X"