From f3cc62c075943b690722b785b4d08175b51f8aa5 Mon Sep 17 00:00:00 2001 From: RaphaelK12 <38438130+RaphaelK12@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:11:52 -0300 Subject: [PATCH] FXAA and SMAA Fixes Fixes the phone's menu and camera when using anti-aliasing methods --- source/antialiasing.ixx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/source/antialiasing.ixx b/source/antialiasing.ixx index 95868006..a28379cf 100644 --- a/source/antialiasing.ixx +++ b/source/antialiasing.ixx @@ -207,8 +207,9 @@ public: IDirect3DSurface9* blendSurf = nullptr; DWORD OldSRGB = 0; DWORD OldSampler = 0; - DWORD Samplers[5] = { D3DTEXF_LINEAR }; - pDevice->GetPixelShader(&pShader); + #define PostfxTextureCount 6 + IDirect3DBaseTexture9* prePostFx[PostfxTextureCount] = { 0 }; + DWORD Samplers[PostfxTextureCount] = { D3DTEXF_LINEAR }; if (doPostFxAA) { @@ -220,6 +221,12 @@ public: pDevice->GetRenderTarget(0, &backBuffer); if (backBuffer && ShadersAA::pHDRTex2) { + // save sampler state + for(int i = 0; i < PostfxTextureCount; i++) { + pDevice->GetTexture(i, &prePostFx[i]); + pDevice->GetSamplerState(i, D3DSAMP_MAGFILTER, &Samplers[i]); + } + ShadersAA::pHDRTex2->GetSurfaceLevel(0, &pHDRSurface2); static auto prefAA = FusionFixSettings.GetRef("PREF_ANTIALIASING"); @@ -257,10 +264,6 @@ public: ShadersAA::edgesTex->GetSurfaceLevel(0, &edgesSurf); ShadersAA::blendTex->GetSurfaceLevel(0, &blendSurf); - // save sampler state - for(int i = 0; i < 5; i++) - pDevice->GetSamplerState(i, D3DSAMP_MAGFILTER, &Samplers[i]); - // game postfx pDevice->SetRenderTarget(0, pHDRSurface2); pDevice->Clear(0, 0, D3DCLEAR_TARGET, 0, 0, 0); @@ -332,15 +335,18 @@ public: pDevice->SetPixelShader(pShader); pDevice->SetFVF(OldFVF); - // restore sampler state - for (auto i = 0; i < 5; i++) - pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, Samplers[i]); - SAFE_RELEASE(edgesSurf); SAFE_RELEASE(blendSurf); } } + // restore sampler state + for(int i = 0; i < PostfxTextureCount; i++) { + pDevice->SetTexture(i, prePostFx[i]); + pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, Samplers[i]); + SAFE_RELEASE(prePostFx[i]); + } + SAFE_RELEASE(backBuffer); SAFE_RELEASE(pHDRSurface2); if (bUseSSAA) {