nv-filters: Enable new logger function for Video Effects

This enables a new logger function introduced in SDK >= 0.7.5, which
gives much more details about what is going on during the effect
processing.

Signed-off-by: pkv <pkv@obsproject.com>
This commit is contained in:
pkv
2025-02-25 20:07:05 +01:00
committed by Ryan Foster
parent 5e60e19de3
commit a8b8abe691
2 changed files with 33 additions and 6 deletions
+15 -4
View File
@@ -275,6 +275,12 @@ static bool nvvfx_filter_create_internal(struct nvvfx_data *filter)
return true; return true;
} }
static void nvvfx_logger_callback(void *data, const char *msg)
{
UNUSED_PARAMETER(data);
blog(LOG_ERROR, "[NVIDIA Video Effect: '%s']", msg);
}
static void *nvvfx_filter_create(obs_data_t *settings, obs_source_t *context, enum nvvfx_fx_id id) static void *nvvfx_filter_create(obs_data_t *settings, obs_source_t *context, enum nvvfx_fx_id id)
{ {
struct nvvfx_data *filter = (struct nvvfx_data *)bzalloc(sizeof(*filter)); struct nvvfx_data *filter = (struct nvvfx_data *)bzalloc(sizeof(*filter));
@@ -349,6 +355,10 @@ static void *nvvfx_filter_create(obs_data_t *settings, obs_source_t *context, en
nvvfx_filter_update(filter, settings); nvvfx_filter_update(filter, settings);
/* Setup NVIDIA logger */
if (nvvfx_new_sdk)
vfxErr = NvVFX_ConfigureLogger(NVCV_LOG_ERROR, NULL, &nvvfx_logger_callback, filter);
return filter; return filter;
} }
@@ -1151,6 +1161,10 @@ bool load_nvidia_vfx(void)
LOAD_SYM(NvVFX_Load); LOAD_SYM(NvVFX_Load);
LOAD_SYM(NvVFX_CudaStreamCreate); LOAD_SYM(NvVFX_CudaStreamCreate);
LOAD_SYM(NvVFX_CudaStreamDestroy); LOAD_SYM(NvVFX_CudaStreamDestroy);
LOAD_SYM(NvVFX_SetStateObjectHandleArray);
LOAD_SYM(NvVFX_AllocateState);
LOAD_SYM(NvVFX_DeallocateState);
LOAD_SYM(NvVFX_ResetState);
old_sdk_loaded = true; old_sdk_loaded = true;
#undef LOAD_SYM #undef LOAD_SYM
@@ -1183,10 +1197,7 @@ bool load_nvidia_vfx(void)
#undef LOAD_SYM #undef LOAD_SYM
#define LOAD_SYM(sym) LOAD_SYM_FROM_LIB2(sym, nv_videofx, "NVVideoEffects.dll") #define LOAD_SYM(sym) LOAD_SYM_FROM_LIB2(sym, nv_videofx, "NVVideoEffects.dll")
LOAD_SYM(NvVFX_SetStateObjectHandleArray); LOAD_SYM(NvVFX_ConfigureLogger);
LOAD_SYM(NvVFX_AllocateState);
LOAD_SYM(NvVFX_DeallocateState);
LOAD_SYM(NvVFX_ResetState);
if (!nvvfx_new_sdk) { if (!nvvfx_new_sdk) {
blog(LOG_INFO, "[NVIDIA VIDEO FX]: sdk loaded but old redistributable detected; please upgrade."); blog(LOG_INFO, "[NVIDIA VIDEO FX]: sdk loaded but old redistributable detected; please upgrade.");
} }
+18 -2
View File
@@ -247,6 +247,14 @@ typedef enum NvCVImage_ComponentType {
#define NVVFX_STATE "State" //!< State variable #define NVVFX_STATE "State" //!< State variable
#define NVVFX_STATE_SIZE "StateSize" //!< Number of bytes needed to store state #define NVVFX_STATE_SIZE "StateSize" //!< Number of bytes needed to store state
/** Logging support **/
enum {
NVCV_LOG_FATAL, //!< Message to be printed right before aborting due to an unrecoverable error.
NVCV_LOG_ERROR, //!< An operation has failed, but it is not fatal.
NVCV_LOG_WARNING, //!< Something was not quite right, but we fixed it up, perhaps at a loss in performance.
NVCV_LOG_INFO //!< Nothing is wrong, but this information might be of interest.
};
//! Image descriptor. //! Image descriptor.
typedef struct typedef struct
#ifdef _MSC_VER #ifdef _MSC_VER
@@ -339,6 +347,9 @@ typedef NvCV_Status NvVFX_API (*NvVFX_AllocateState_t)(NvVFX_Handle effect, NvVF
typedef NvCV_Status NvVFX_API (*NvVFX_DeallocateState_t)(NvVFX_Handle effect, NvVFX_StateObjectHandle handle); typedef NvCV_Status NvVFX_API (*NvVFX_DeallocateState_t)(NvVFX_Handle effect, NvVFX_StateObjectHandle handle);
typedef NvCV_Status NvVFX_API (*NvVFX_ResetState_t)(NvVFX_Handle effect, NvVFX_StateObjectHandle handle); typedef NvCV_Status NvVFX_API (*NvVFX_ResetState_t)(NvVFX_Handle effect, NvVFX_StateObjectHandle handle);
/* requires SDK version >= 0.7.5 */
typedef NvCV_Status NvVFX_API (*NvVFX_ConfigureLogger_t)(int verbosity, const char *file,
void (*cb)(void *, const char *), void *cb_data);
/* NvCVImage functions */ /* NvCVImage functions */
typedef NvCV_Status NvCV_API (*NvCVImage_Init_t)(NvCVImage *im, unsigned width, unsigned height, int pitch, typedef NvCV_Status NvCV_API (*NvCVImage_Init_t)(NvCVImage *im, unsigned width, unsigned height, int pitch,
void *pixels, NvCVImage_PixelFormat format, void *pixels, NvCVImage_PixelFormat format,
@@ -401,6 +412,7 @@ typedef NvCV_Status NvCV_API (*NvCVImage_FromD3DColorSpace_t)(DXGI_COLOR_SPACE_T
unsigned char *pNvcvColorSpace); unsigned char *pNvcvColorSpace);
typedef NvCV_Status NvCV_API (*NvCVImage_InitFromD3D11Texture_t)(NvCVImage *im, struct ID3D11Texture2D *tx); typedef NvCV_Status NvCV_API (*NvCVImage_InitFromD3D11Texture_t)(NvCVImage *im, struct ID3D11Texture2D *tx);
typedef NvCV_Status NvCV_API (*NvCVImage_InitFromD3DTexture_t)(NvCVImage *im, struct ID3D11Texture2D *tx); typedef NvCV_Status NvCV_API (*NvCVImage_InitFromD3DTexture_t)(NvCVImage *im, struct ID3D11Texture2D *tx);
/* cuda runtime */ /* cuda runtime */
typedef enum cudaError { typedef enum cudaError {
cudaSuccess = 0, cudaSuccess = 0,
@@ -537,7 +549,7 @@ typedef cudaError_t CUDARTAPI (*cudaFree_t)(void *devPtr);
typedef cudaError_t CUDARTAPI (*cudaMemsetAsync_t)(void *devPtr, int value, size_t count, CUstream stream); typedef cudaError_t CUDARTAPI (*cudaMemsetAsync_t)(void *devPtr, int value, size_t count, CUstream stream);
typedef cudaError_t CUDARTAPI (*cudaMemcpy_t)(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind); typedef cudaError_t CUDARTAPI (*cudaMemcpy_t)(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind);
/* nvvfx */ /* NVVFX */
static NvVFX_GetVersion_t NvVFX_GetVersion = NULL; static NvVFX_GetVersion_t NvVFX_GetVersion = NULL;
static NvVFX_CreateEffect_t NvVFX_CreateEffect = NULL; static NvVFX_CreateEffect_t NvVFX_CreateEffect = NULL;
static NvVFX_DestroyEffect_t NvVFX_DestroyEffect = NULL; static NvVFX_DestroyEffect_t NvVFX_DestroyEffect = NULL;
@@ -564,12 +576,15 @@ static NvVFX_Load_t NvVFX_Load = NULL;
static NvVFX_CudaStreamCreate_t NvVFX_CudaStreamCreate = NULL; static NvVFX_CudaStreamCreate_t NvVFX_CudaStreamCreate = NULL;
static NvVFX_CudaStreamDestroy_t NvVFX_CudaStreamDestroy = NULL; static NvVFX_CudaStreamDestroy_t NvVFX_CudaStreamDestroy = NULL;
/* nvvfx sdk >= 0.7.0 */ /* NVVFX SDK >= 0.7.0 */
static NvVFX_SetStateObjectHandleArray_t NvVFX_SetStateObjectHandleArray = NULL; static NvVFX_SetStateObjectHandleArray_t NvVFX_SetStateObjectHandleArray = NULL;
static NvVFX_AllocateState_t NvVFX_AllocateState = NULL; static NvVFX_AllocateState_t NvVFX_AllocateState = NULL;
static NvVFX_DeallocateState_t NvVFX_DeallocateState = NULL; static NvVFX_DeallocateState_t NvVFX_DeallocateState = NULL;
static NvVFX_ResetState_t NvVFX_ResetState = NULL; static NvVFX_ResetState_t NvVFX_ResetState = NULL;
/* NVVFX SDK >= 0.7.5 */
static NvVFX_ConfigureLogger_t NvVFX_ConfigureLogger = NULL;
/*nvcvimage */ /*nvcvimage */
static NvCVImage_Init_t NvCVImage_Init = NULL; static NvCVImage_Init_t NvCVImage_Init = NULL;
static NvCVImage_InitView_t NvCVImage_InitView = NULL; static NvCVImage_InitView_t NvCVImage_InitView = NULL;
@@ -638,6 +653,7 @@ static inline void release_nv_vfx()
NvVFX_AllocateState = NULL; NvVFX_AllocateState = NULL;
NvVFX_DeallocateState = NULL; NvVFX_DeallocateState = NULL;
NvVFX_ResetState = NULL; NvVFX_ResetState = NULL;
NvVFX_ConfigureLogger = NULL;
if (nv_videofx) { if (nv_videofx) {
FreeLibrary(nv_videofx); FreeLibrary(nv_videofx);
nv_videofx = NULL; nv_videofx = NULL;