diff --git a/FSR3UnityPlugin.cpp b/FSR3UnityPlugin.cpp index 12ad251..64922f4 100644 --- a/FSR3UnityPlugin.cpp +++ b/FSR3UnityPlugin.cpp @@ -260,6 +260,16 @@ static void DestroyFeature(uint32_t featureSlot) WaitForSingleObjectEx(s_FrameFenceEventHandle, INFINITE, false); } } + else if (s_GraphicsVulkan != nullptr) + { + UnityVulkanRecordingState state; + s_GraphicsVulkan->CommandRecordingState(&state, kUnityVulkanGraphicsQueueAccess_DontCare); + if (feature.dispatchFrameValue > state.safeFrameNumber) + { + UnityVulkanInstance instance = s_GraphicsVulkan->Instance(); + vkQueueWaitIdle(instance.graphicsQueue); + } + } if (feature.upscalingContext != nullptr) { @@ -483,7 +493,7 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data) s_GraphicsVulkan->CommandRecordingState(&state, kUnityVulkanGraphicsQueueAccess_DontCare); dispatchUpscale.commandList = state.commandBuffer; - // TODO: probably need to make use of state.currentFrameNumber and state.safeFrameNumber to keep track of when it's safe to destroy the upscaling context + // Keep track of which frame this dispatch is happening on, so we can verify when it's finished feature.dispatchFrameValue = state.currentFrameNumber; UnityVulkanInstance instance = s_GraphicsVulkan->Instance();