From 2682ccc33ce6680456be49c6daa8febe36843a69 Mon Sep 17 00:00:00 2001 From: pkv Date: Tue, 11 Mar 2025 21:31:49 +0100 Subject: [PATCH] nv-filters: Fix destruction of Background Blur effect For the background blur effect, it was found that destroying it and then adding any other NVIDIA effect led to a blank picture. This commit swaps the order of destroying the effect and the associated cudaStream. For other effects the order does not matter; I have no idea why the order matters for blur effect and the SDK gives no indication about any proper order at destruction time. Fixes bug #11383. Signed-off-by: pkv --- plugins/nv-filters/nvidia-videofx-filter.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/nv-filters/nvidia-videofx-filter.c b/plugins/nv-filters/nvidia-videofx-filter.c index 3214c685d..afb9adb7a 100644 --- a/plugins/nv-filters/nvidia-videofx-filter.c +++ b/plugins/nv-filters/nvidia-videofx-filter.c @@ -183,10 +183,6 @@ static void nvvfx_filter_actual_destroy(void *data) NvCVImage_Destroy(filter->blur_dst_img); } } - if (filter->stream) - NvVFX_CudaStreamDestroy(filter->stream); - if (filter->stream_blur) - NvVFX_CudaStreamDestroy(filter->stream_blur); if (filter->handle) { if (filter->stateObjectHandle) { @@ -197,6 +193,10 @@ static void nvvfx_filter_actual_destroy(void *data) if (filter->handle_blur) { NvVFX_DestroyEffect(filter->handle_blur); } + if (filter->stream) + NvVFX_CudaStreamDestroy(filter->stream); + if (filter->stream_blur) + NvVFX_CudaStreamDestroy(filter->stream_blur); if (filter->effect) { obs_enter_graphics(); @@ -378,12 +378,6 @@ static void nvvfx_filter_reset(void *data, calldata_t *calldata) os_atomic_set_bool(&filter->processing_stop, true); // [A] first destroy - if (filter->stream) { - NvVFX_CudaStreamDestroy(filter->stream); - } - if (filter->stream_blur) { - NvVFX_CudaStreamDestroy(filter->stream_blur); - } if (filter->handle) { if (filter->stateObjectHandle) { NvVFX_DeallocateState(filter->handle, filter->stateObjectHandle); @@ -393,6 +387,12 @@ static void nvvfx_filter_reset(void *data, calldata_t *calldata) if (filter->handle_blur) { NvVFX_DestroyEffect(filter->handle_blur); } + if (filter->stream) { + NvVFX_CudaStreamDestroy(filter->stream); + } + if (filter->stream_blur) { + NvVFX_CudaStreamDestroy(filter->stream_blur); + } // [B] recreate /* 1. Create FX */ /* 2. Set models path & initialize CudaStream */