Try to improve FG Feature lifetime & context management

This commit is contained in:
cdozdil
2025-08-30 11:47:40 +03:00
parent c1a93cceb8
commit bd331db5bb
4 changed files with 14 additions and 11 deletions
+4 -6
View File
@@ -378,6 +378,8 @@ ffxReturnCode_t FSRFG_Dx12::DispatchCallback(ffxDispatchDescFrameGeneration* par
return dispatchResult;
}
FSRFG_Dx12::~FSRFG_Dx12() { Shutdown(); }
void* FSRFG_Dx12::FrameGenerationContext()
{
LOG_DEBUG("");
@@ -418,9 +420,6 @@ bool FSRFG_Dx12::Shutdown()
{
Deactivate();
if (_fgContext != nullptr)
DestroyFGContext();
if (_swapChainContext != nullptr)
ReleaseSwapchain(_hwnd);
@@ -529,8 +528,6 @@ bool FSRFG_Dx12::ReleaseSwapchain(HWND hwnd)
_swapChainContext = nullptr;
}
ReleaseObjects();
if (Config::Instance()->FGUseMutexForSwapchain.value_or_default())
{
LOG_TRACE("Releasing Mutex: {}", Mutex.getOwner());
@@ -544,6 +541,8 @@ void FSRFG_Dx12::CreateContext(ID3D12Device* device, FG_Constants& fgConstants)
{
LOG_DEBUG("");
CreateObjects(device);
_constants = fgConstants;
// Changing the format of the hudless resource requires a new context
@@ -738,7 +737,6 @@ void FSRFG_Dx12::EvaluateState(ID3D12Device* device, FG_Constants& fgConstants)
if (_fgContext == nullptr)
{
// Create it again
CreateObjects(device);
CreateContext(device, fgConstants);
// Pause for 10 frames
+2
View File
@@ -97,4 +97,6 @@ class FSRFG_Dx12 : public virtual IFGFeature_Dx12
{
//
}
~FSRFG_Dx12();
};
+6 -5
View File
@@ -383,11 +383,11 @@ void XeFG_Dx12::CreateContext(ID3D12Device* device, FG_Constants& fgConstants)
LOG_DEBUG("");
_device = device;
CreateObjects(device);
if (_fgContext == nullptr && _swapChainContext != nullptr)
{
_fgContext = _swapChainContext;
CreateObjects(device);
}
}
@@ -602,6 +602,8 @@ void* XeFG_Dx12::FrameGenerationContext() { return _fgContext; }
void* XeFG_Dx12::SwapchainContext() { return _swapChainContext; }
XeFG_Dx12::~XeFG_Dx12() { Shutdown(); }
void XeFG_Dx12::EvaluateState(ID3D12Device* device, FG_Constants& fgConstants)
{
LOG_FUNC();
@@ -626,7 +628,6 @@ void XeFG_Dx12::EvaluateState(ID3D12Device* device, FG_Constants& fgConstants)
if (_fgContext == nullptr)
{
// Create it again
CreateObjects(device);
CreateContext(device, fgConstants);
// Pause for 10 frames
@@ -912,10 +913,10 @@ bool XeFG_Dx12::ReleaseSwapchain(HWND hwnd)
if (_fgContext != nullptr)
DestroyFGContext();
if (_swapChainContext != nullptr)
DestroySwapchainContext();
// if (_swapChainContext != nullptr)
// DestroySwapchainContext();
ReleaseObjects();
// ReleaseObjects();
if (Config::Instance()->FGUseMutexForSwapchain.value_or_default())
{
+2
View File
@@ -72,4 +72,6 @@ class XeFG_Dx12 : public virtual IFGFeature_Dx12
if (XeFGProxy::Module() == nullptr)
XeFGProxy::InitXeFG();
}
~XeFG_Dx12();
};