From c5bb1278f4dee866a2aed12d82f2a8e5cec0c639 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Thu, 27 May 2021 00:05:49 +0200 Subject: [PATCH] obs-filters: Test if NVAFX is supported on load Prevents situations where the redistributable is installed and OBS enables the RTX denoiser but it is non-functional. Changes were tested on systems with both supported / unsupported GPUs and it adds around 10-20ms to the load time in both cases. --- plugins/obs-filters/noise-suppress-filter.c | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/obs-filters/noise-suppress-filter.c b/plugins/obs-filters/noise-suppress-filter.c index 2c9f797bf..e8fa775b6 100644 --- a/plugins/obs-filters/noise-suppress-filter.c +++ b/plugins/obs-filters/noise-suppress-filter.c @@ -514,8 +514,6 @@ bool load_nvafx(void) blog(LOG_INFO, "[noise suppress: Nvidia RTX denoiser disabled, redistributable not found]"); return false; - } else { - blog(LOG_INFO, "[noise suppress: Nvidia RTX denoiser enabled]"); } pthread_mutex_init(&nvafx_initializer_mutex, PTHREAD_MUTEX_DEFAULT); @@ -542,7 +540,31 @@ bool load_nvafx(void) LOAD_SYM(NvAFX_Load); LOAD_SYM(NvAFX_Run); #undef LOAD_SYM + + int err; + NvAFX_Handle h = NULL; + + err = NvAFX_CreateEffect(NVAFX_EFFECT_DENOISER, &h); + if (err != NVAFX_STATUS_SUCCESS) { + if (err == NVAFX_STATUS_GPU_UNSUPPORTED) { + blog(LOG_INFO, + "[noise suppress: Nvidia RTX denoiser disabled: unsupported GPU]"); + } else { + blog(LOG_ERROR, + "[noise suppress: Nvidia RTX denoiser disabled: error %i", + err); + } + goto unload_everything; + } + + err = NvAFX_DestroyEffect(h); + if (err != NVAFX_STATUS_SUCCESS) { + blog(LOG_ERROR, "NvAFX_DestroyEffect() failed, error %i", err); + goto unload_everything; + } + nvafx_loaded = true; + blog(LOG_INFO, "[noise suppress: Nvidia RTX denoiser enabled]"); return true; unload_everything: