diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index ab9493504f..d5c0244883 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -211,6 +211,7 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache key.magFilt = magFilt & 1; key.sClamp = sClamp; key.tClamp = tClamp; + key.aniso = false; if (!key.mipEnable) { key.maxLevel = 0; @@ -222,7 +223,10 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache key.maxLevel = entry.maxLevel * 256; key.minLevel = 0; key.lodBias = (int)(lodBias * 256.0f); - break; + if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + key.aniso = true; + break; + } case GE_TEXLEVEL_MODE_CONST: key.maxLevel = (int)(lodBias * 256.0f); key.minLevel = (int)(lodBias * 256.0f); @@ -232,7 +236,7 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache // It's incorrect to use the slope as a bias. Instead it should be passed // into the shader directly as an explicit lod level, with the bias on top. For now, we just kill the // lodBias in this mode, working around #9772. - key.maxLevel = entry.maxLevel; + key.maxLevel = entry.maxLevel * 256; key.minLevel = 0; key.lodBias = 0; break; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 858f624653..5289123f81 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -72,6 +72,7 @@ struct SamplerCacheKey { bool magFilt : 1; bool sClamp : 1; bool tClamp : 1; + bool aniso : 1; }; }; bool operator < (const SamplerCacheKey &other) const { diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index a587e924c4..a687a5ea4f 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -64,7 +64,7 @@ ID3D11SamplerState *SamplerCacheD3D11::GetOrCreateSampler(ID3D11Device *device, samp.AddressU = key.sClamp ? D3D11_TEXTURE_ADDRESS_CLAMP : D3D11_TEXTURE_ADDRESS_WRAP; samp.AddressV = key.tClamp ? D3D11_TEXTURE_ADDRESS_CLAMP : D3D11_TEXTURE_ADDRESS_WRAP; samp.AddressW = samp.AddressU; // Mali benefits from all clamps being the same, and this one is irrelevant. - if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + if (key.aniso) { samp.MaxAnisotropy = (float)(1 << g_Config.iAnisotropyLevel); } else { samp.MaxAnisotropy = 1.0f; @@ -81,7 +81,7 @@ ID3D11SamplerState *SamplerCacheD3D11::GetOrCreateSampler(ID3D11Device *device, D3D11_FILTER_MIN_MAG_MIP_LINEAR, }; // Only switch to aniso if linear min and mag are set. - if (samp.MaxAnisotropy > 1.0f && key.magFilt != 0 && key.minFilt != 0) + if (key.aniso && key.magFilt != 0 && key.minFilt != 0) samp.Filter = D3D11_FILTER_ANISOTROPIC; else samp.Filter = filters[filterKey]; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 8d26cb56d3..ba0da41a0e 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -86,13 +86,12 @@ VkSampler SamplerCache::GetOrCreateSampler(const SamplerCacheKey &key) { samp.addressModeU = key.sClamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT; samp.addressModeV = key.tClamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT; samp.addressModeW = samp.addressModeU; // irrelevant, but Mali recommends that all clamp modes are the same if possible. - samp.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; samp.compareOp = VK_COMPARE_OP_ALWAYS; samp.flags = 0; samp.magFilter = key.magFilt ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; samp.minFilter = key.minFilt ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; samp.mipmapMode = key.mipFilt ? VK_SAMPLER_MIPMAP_MODE_LINEAR : VK_SAMPLER_MIPMAP_MODE_NEAREST; - if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + if (key.aniso) { // Docs say the min of this value and the supported max are used. samp.maxAnisotropy = 1 << g_Config.iAnisotropyLevel; samp.anisotropyEnable = true;