From 11ac758d7883d6887f2682add025c378b0ec0f52 Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Tue, 28 Dec 2021 13:29:02 +0100 Subject: [PATCH] GS-d3d11: Mirror anisotropic filtering behavior on Direct3D11. Don't run aniso filter on m_convert.pt and m_convert.ln samplers. Running m_convert.pt broke shadows on color clipping. Also use the aniso bit from hw renderer. Aniso will now behave the same as on OpenGL. --- pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 14 +++----------- pcsx2/GS/Renderers/DX11/GSDevice11.h | 1 - pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp | 13 +++++++++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 8835949164..96fcca9778 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -35,13 +35,6 @@ GSDevice11::GSDevice11() m_mipmap = theApp.GetConfigI("mipmap"); m_upscale_multiplier = std::max(0, theApp.GetConfigI("upscale_multiplier")); - const BiFiltering nearest_filter = static_cast(theApp.GetConfigI("filter")); - const int aniso_level = theApp.GetConfigI("MaxAnisotropy"); - if ((nearest_filter != BiFiltering::Nearest && !theApp.GetConfigB("paltex") && aniso_level)) - m_aniso_filter = aniso_level; - else - m_aniso_filter = 0; - m_features.broken_point_sampler = true; // Not technically the case but the most common reason to use DX11 is because you're on AMD m_features.geometry_shader = true; m_features.image_load_store = false; @@ -375,18 +368,18 @@ bool GSDevice11::Create(const WindowInfo& wi) memset(&sd, 0, sizeof(sd)); - sd.Filter = m_aniso_filter ? D3D11_FILTER_ANISOTROPIC : D3D11_FILTER_MIN_MAG_MIP_LINEAR; + sd.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sd.MinLOD = -FLT_MAX; sd.MaxLOD = FLT_MAX; - sd.MaxAnisotropy = m_aniso_filter; + sd.MaxAnisotropy = D3D11_MIN_MAXANISOTROPY; sd.ComparisonFunc = D3D11_COMPARISON_NEVER; m_dev->CreateSamplerState(&sd, m_convert.ln.put()); - sd.Filter = m_aniso_filter ? D3D11_FILTER_ANISOTROPIC : D3D11_FILTER_MIN_MAG_MIP_POINT; + sd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; m_dev->CreateSamplerState(&sd, m_convert.pt.put()); @@ -1485,7 +1478,6 @@ static void preprocessSel(GSDevice11::PSSelector& sel) static void preprocessSel(GSDevice11::PSSamplerSelector& sel) { - sel.aniso = 0; // Not currently supported sel.triln = 0; // Not currently supported } diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.h b/pcsx2/GS/Renderers/DX11/GSDevice11.h index 78c2f79fd8..61b4fb8ed2 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.h +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.h @@ -109,7 +109,6 @@ public: private: float m_hack_topleft_offset; int m_upscale_multiplier; - int m_aniso_filter; int m_mipmap; int m_d3d_texsize; diff --git a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp index dd1c8dcf60..bc8e1afb5a 100644 --- a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp @@ -220,19 +220,24 @@ void GSDevice11::SetupPS(PSSelector sel, const GSHWDrawConfig::PSConstantBuffer* } else { - D3D11_SAMPLER_DESC sd, af; + D3D11_SAMPLER_DESC sd; memset(&sd, 0, sizeof(sd)); - af.Filter = m_aniso_filter ? D3D11_FILTER_ANISOTROPIC : D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT; - sd.Filter = ssel.biln ? af.Filter : D3D11_FILTER_MIN_MAG_MIP_POINT; + const int anisotropy = theApp.GetConfigI("MaxAnisotropy"); + if (anisotropy && ssel.aniso) + sd.Filter = D3D11_FILTER_ANISOTROPIC; + else if (ssel.biln) + sd.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT; + else + sd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; sd.AddressU = ssel.tau ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressV = ssel.tav ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sd.MinLOD = -FLT_MAX; sd.MaxLOD = FLT_MAX; - sd.MaxAnisotropy = m_aniso_filter; + sd.MaxAnisotropy = anisotropy; sd.ComparisonFunc = D3D11_COMPARISON_NEVER; m_dev->CreateSamplerState(&sd, &ss0);