When a [`ffxQuery`](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/f4c1da8e92f3fe563b5c28c44e6267ce6b6b8eb2/Kits/FidelityFX/api/internal/ffx_api.cpp#L72) is called with a [`ID3D12Device*`](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nn-d3d12-id3d12device), the [`GetExternalProviders`](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/c6efa6bf7f2027b3ec94f28578bb5965eabb9e55/ffx-api/src/ffx_provider.cpp#L74) is going to leak the resource. ``` ffxQueryDescGetVersions versionsDesc{ .header{ .type = FFX_API_QUERY_DESC_TYPE_GET_VERSIONS, }, .createDescType = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE, .device = device, .outputCount = &versionCount, }; ffxQuery(nullptr, &versionsDesc.header); ``` The [`GetExternalProviders`](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/c6efa6bf7f2027b3ec94f28578bb5965eabb9e55/ffx-api/src/ffx_provider.cpp#L74) creates an `IAmdExtFfxApi*` object which holds a reference to the device [HRESULT hr = AmdExtD3DCreateInterface(device, IID_PPV_ARGS(&apiExtension));](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/c6efa6bf7f2027b3ec94f28578bb5965eabb9e55/ffx-api/src/ffx_provider.cpp#L93C21-L93C28) but this `IAmdExtFfxApi*` is a function visible global pointer which never will be released. I understand that the intention behind this function visible global pointer was to cache the `IAmdExtFfxApi*` but now at teardown of engine and hardware abstraction layer the engine's [`ID3D12Device*`](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nn-d3d12-id3d12device) can not be released due to the increased refence count by [`static IAmdExtFfxApi* apiExtension`](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/c6efa6bf7f2027b3ec94f28578bb5965eabb9e55/ffx-api/src/ffx_provider.cpp#L76C27-L76C39). during [`ffxDestroyContext`](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/f4c1da8e92f3fe563b5c28c44e6267ce6b6b8eb2/Kits/FidelityFX/api/internal/ffx_api.cpp#L56) this cache should be released as well. While this problem exists, we are going to use a workaround in our projects https://github.com/GaijinEntertainment/FidelityFX-SDK/commit/64fa37e6c022be47b584b3e6cdd3a5023c8dcdfb
When a
ffxQueryis called with aID3D12Device*, theGetExternalProvidersis going to leak the resource.The
GetExternalProviderscreates anIAmdExtFfxApi*object which holds a reference to the deviceHRESULT hr = AmdExtD3DCreateInterface(device, IID_PPV_ARGS(&apiExtension));
but this
IAmdExtFfxApi*is a function visible global pointer which never will be released.I understand that the intention behind this function visible global pointer was to cache the
IAmdExtFfxApi*but now at teardown of engine and hardware abstraction layer the engine'sID3D12Device*can not be released due to the increased refence count bystatic IAmdExtFfxApi* apiExtension.during
ffxDestroyContextthis cache should be released as well.While this problem exists, we are going to use a workaround in our projects
GaijinEntertainment@64fa37e