Skip to content

Commit 11d0e00

Browse files
authored
FXAA and SMAA Fixes (#378)
Fixes the phone's menu and camera when using anti-aliasing methods
1 parent d0ae336 commit 11d0e00

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

source/antialiasing.ixx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ public:
207207
IDirect3DSurface9* blendSurf = nullptr;
208208
DWORD OldSRGB = 0;
209209
DWORD OldSampler = 0;
210-
DWORD Samplers[5] = { D3DTEXF_LINEAR };
211-
pDevice->GetPixelShader(&pShader);
210+
#define PostfxTextureCount 6
211+
IDirect3DBaseTexture9* prePostFx[PostfxTextureCount] = { 0 };
212+
DWORD Samplers[PostfxTextureCount] = { D3DTEXF_LINEAR };
212213

213214
if (doPostFxAA)
214215
{
@@ -220,6 +221,12 @@ public:
220221
pDevice->GetRenderTarget(0, &backBuffer);
221222
if (backBuffer && ShadersAA::pHDRTex2)
222223
{
224+
// save sampler state
225+
for(int i = 0; i < PostfxTextureCount; i++) {
226+
pDevice->GetTexture(i, &prePostFx[i]);
227+
pDevice->GetSamplerState(i, D3DSAMP_MAGFILTER, &Samplers[i]);
228+
}
229+
223230
ShadersAA::pHDRTex2->GetSurfaceLevel(0, &pHDRSurface2);
224231

225232
static auto prefAA = FusionFixSettings.GetRef("PREF_ANTIALIASING");
@@ -257,10 +264,6 @@ public:
257264
ShadersAA::edgesTex->GetSurfaceLevel(0, &edgesSurf);
258265
ShadersAA::blendTex->GetSurfaceLevel(0, &blendSurf);
259266

260-
// save sampler state
261-
for(int i = 0; i < 5; i++)
262-
pDevice->GetSamplerState(i, D3DSAMP_MAGFILTER, &Samplers[i]);
263-
264267
// game postfx
265268
pDevice->SetRenderTarget(0, pHDRSurface2);
266269
pDevice->Clear(0, 0, D3DCLEAR_TARGET, 0, 0, 0);
@@ -332,15 +335,18 @@ public:
332335
pDevice->SetPixelShader(pShader);
333336
pDevice->SetFVF(OldFVF);
334337

335-
// restore sampler state
336-
for (auto i = 0; i < 5; i++)
337-
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, Samplers[i]);
338-
339338
SAFE_RELEASE(edgesSurf);
340339
SAFE_RELEASE(blendSurf);
341340
}
342341
}
343342

343+
// restore sampler state
344+
for(int i = 0; i < PostfxTextureCount; i++) {
345+
pDevice->SetTexture(i, prePostFx[i]);
346+
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, Samplers[i]);
347+
SAFE_RELEASE(prePostFx[i]);
348+
}
349+
344350
SAFE_RELEASE(backBuffer);
345351
SAFE_RELEASE(pHDRSurface2);
346352
if (bUseSSAA) {

0 commit comments

Comments
 (0)