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
This commit is contained in:
Magnus Norddahl 2024-04-10 17:38:41 +02:00
commit 250fe865c7
3 changed files with 16 additions and 2 deletions

View file

@ -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();
}

View file

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

View file

@ -2557,6 +2557,7 @@ OptionValue "FXAAQuality"
OptionValue "Anisotropy"
{
0, "$OPTVAL_DEFAULT"
1, "$OPTVAL_OFF"
2, "$OPTVAL_2X"
4, "$OPTVAL_4X"