From aa51fae5a636dce911fe245d597d69a2ef14dfe9 Mon Sep 17 00:00:00 2001 From: myT <> Date: Sun, 17 Sep 2023 01:53:15 +0200 Subject: [PATCH] fixed SMAA crash on device change --- code/renderer/grp_smaa.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/code/renderer/grp_smaa.cpp b/code/renderer/grp_smaa.cpp index 3d114bd..01d3336 100644 --- a/code/renderer/grp_smaa.cpp +++ b/code/renderer/grp_smaa.cpp @@ -87,14 +87,30 @@ void SMAA::Update() const bool resChanged = newWidth != width || newHeight != height; const bool presetChanged = newMode != mode; - const bool createFixed = justEnabled && !fixedLoaded; - const bool destroyFixed = justDisabled && fixedLoaded; + bool createFixed = justEnabled && !fixedLoaded; + bool destroyFixed = justDisabled && fixedLoaded; - const bool createResDep = justEnabled || (alwaysEnabled && resChanged); - const bool destroyResDep = justDisabled || (alwaysEnabled && resChanged); + bool createResDep = justEnabled || (alwaysEnabled && resChanged); + bool destroyResDep = justDisabled || (alwaysEnabled && resChanged); - const bool createPresetDep = justEnabled || (alwaysEnabled && presetChanged); - const bool destroyPresetDep = justDisabled || (alwaysEnabled && presetChanged); + bool createPresetDep = justEnabled || (alwaysEnabled && presetChanged); + bool destroyPresetDep = justDisabled || (alwaysEnabled && presetChanged); + + if(grp.firstInit) + { + // first init or device change: we have nothing to destroy + const bool enableSMAA = newMode != Mode::Disabled; + createFixed = enableSMAA; + createResDep = enableSMAA; + createPresetDep = enableSMAA; + destroyFixed = false; + destroyResDep = false; + destroyPresetDep = false; + mode = Mode::Disabled; + width = -1; + height = -1; + fixedLoaded = false; + } if(destroyFixed || destroyResDep || destroyPresetDep) {