Tried to fix VMem leak when using FSR inputs

This commit is contained in:
cdozdil
2025-03-19 23:28:53 +03:00
parent c93247a88b
commit 6eb2a67b5a
4 changed files with 24 additions and 40 deletions
+9 -15
View File
@@ -802,15 +802,6 @@ static Fsr212::FfxErrorCode ffxFsr2ContextDestroy_Dx12(Fsr212::FfxFsr2Context* c
if (context == nullptr)
return Fsr212::FFX_ERROR_INVALID_ARGUMENT;
_skipDestroy = true;
auto cdResult = o_ffxFsr2ContextDestroy_Dx12(context);
_skipDestroy = false;
LOG_INFO("result: {:X}", (UINT)cdResult);
if (!_initParams.contains(context) || _d3d12Device == nullptr)
return cdResult;
if (_contexts.contains(context))
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[context]);
@@ -818,6 +809,12 @@ static Fsr212::FfxErrorCode ffxFsr2ContextDestroy_Dx12(Fsr212::FfxFsr2Context* c
_nvParams.erase(context);
_initParams.erase(context);
_skipDestroy = true;
auto cdResult = o_ffxFsr2ContextDestroy_Dx12(context);
_skipDestroy = false;
LOG_INFO("result: {:X}", (UINT)cdResult);
return Fsr212::FFX_OK;
}
@@ -826,12 +823,6 @@ static Fsr212::FfxErrorCode ffxFsr2ContextDestroy_Pattern_Dx12(Fsr212::FfxFsr2Co
if (context == nullptr)
return Fsr212::FFX_ERROR_INVALID_ARGUMENT;
auto cdResult = o_ffxFsr2ContextDestroy_Pattern_Dx12(context);
LOG_INFO("result: {:X}", (UINT)cdResult);
if (!_initParams.contains(context) || _d3d12Device == nullptr || _skipDestroy)
return cdResult;
if (_contexts.contains(context))
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[context]);
@@ -839,6 +830,9 @@ static Fsr212::FfxErrorCode ffxFsr2ContextDestroy_Pattern_Dx12(Fsr212::FfxFsr2Co
_nvParams.erase(context);
_initParams.erase(context);
auto cdResult = o_ffxFsr2ContextDestroy_Pattern_Dx12(context);
LOG_INFO("result: {:X}", (UINT)cdResult);
return Fsr212::FFX_OK;
}
+9 -19
View File
@@ -321,15 +321,6 @@ static Fsr3::FfxErrorCode ffxFsr3ContextDestroy_Dx12(Fsr3::FfxFsr3UpscalerContex
LOG_DEBUG("context: {:X}", (size_t)pContext);
_skipDestroy = true;
auto cdResult = o_ffxFsr3UpscalerContextDestroy_Dx12(pContext);
_skipDestroy = false;
LOG_INFO("result: {:X}", (UINT)cdResult);
if (!_initParams.contains(pContext))
return cdResult;
if (_contexts.contains(pContext))
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[pContext]);
@@ -337,6 +328,12 @@ static Fsr3::FfxErrorCode ffxFsr3ContextDestroy_Dx12(Fsr3::FfxFsr3UpscalerContex
_nvParams.erase(pContext);
_initParams.erase(pContext);
_skipDestroy = true;
auto cdResult = o_ffxFsr3UpscalerContextDestroy_Dx12(pContext);
_skipDestroy = false;
LOG_INFO("result: {:X}", (UINT)cdResult);
return Fsr3::FFX_OK;
}
@@ -485,16 +482,6 @@ static Fsr3::FfxErrorCode ffxFsr3ContextDestroy_Pattern_Dx12(Fsr3::FfxFsr3Upscal
LOG_DEBUG("context: {:X}", (size_t)pContext);
auto cdResult = o_ffxFsr3UpscalerContextDestroy_Dx12(pContext);
if (_skipDestroy)
return cdResult;
LOG_INFO("result: {:X}", (UINT)cdResult);
if (!_initParams.contains(pContext))
return cdResult;
if (_contexts.contains(pContext))
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[pContext]);
@@ -502,6 +489,9 @@ static Fsr3::FfxErrorCode ffxFsr3ContextDestroy_Pattern_Dx12(Fsr3::FfxFsr3Upscal
_nvParams.erase(pContext);
_initParams.erase(pContext);
auto cdResult = o_ffxFsr3UpscalerContextDestroy_Dx12(pContext);
LOG_INFO("result: {:X}", (UINT)cdResult);
return Fsr3::FFX_OK;
}
+3 -3
View File
@@ -232,9 +232,6 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC
LOG_DEBUG("context: {:X}", (size_t)*context);
auto cdResult = FfxApiProxy::D3D12_DestroyContext()(context, memCb);
LOG_INFO("result: {:X}", (UINT)cdResult);
if (_contexts.contains(*context))
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[*context]);
@@ -242,6 +239,9 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC
_nvParams.erase(*context);
_initParams.erase(*context);
auto cdResult = FfxApiProxy::D3D12_DestroyContext()(context, memCb);
LOG_INFO("result: {:X}", (UINT)cdResult);
return FFX_API_RETURN_OK;
}
+3 -3
View File
@@ -371,9 +371,6 @@ ffxReturnCode_t ffxDestroyContext_Vk(ffxContext* context, const ffxAllocationCal
LOG_DEBUG("context: {:X}", (size_t)*context);
auto cdResult = FfxApiProxy::VULKAN_DestroyContext()(context, memCb);
LOG_INFO("result: {:X}", (UINT)cdResult);
if (_contexts.contains(*context))
NVSDK_NGX_VULKAN_ReleaseFeature(_contexts[*context]);
@@ -381,6 +378,9 @@ ffxReturnCode_t ffxDestroyContext_Vk(ffxContext* context, const ffxAllocationCal
_nvParams.erase(*context);
_initParams.erase(*context);
auto cdResult = FfxApiProxy::VULKAN_DestroyContext()(context, memCb);
LOG_INFO("result: {:X}", (UINT)cdResult);
return FFX_API_RETURN_OK;
}