Commit 69b1a484 authored by sr55's avatar sr55

NVEnc: Check SDK version and disable feature if driver is too old. Prevent...

NVEnc: Check SDK version and disable feature if driver is too old.  Prevent re-checks by caching result.
parent 8b09ede8
......@@ -35,6 +35,7 @@ int hb_nvenc_h265_available()
#endif
}
static int isAvailable = -1;
int hb_check_nvenc_available()
{
if (is_hardware_disabled())
......@@ -42,6 +43,10 @@ int hb_check_nvenc_available()
return 0;
}
if (isAvailable != -1){
return isAvailable;
}
#if HB_PROJECT_FEATURE_NVENC
uint32_t nvenc_ver;
void *context = NULL;
......@@ -49,15 +54,25 @@ int hb_check_nvenc_available()
int loadErr = nvenc_load_functions(&nvenc_dl, context);
if (loadErr < 0) {
isAvailable = 0;
return 0;
}
NVENCSTATUS apiErr = nvenc_dl->NvEncodeAPIGetMaxSupportedVersion(&nvenc_ver);
if (apiErr != NV_ENC_SUCCESS)
{
isAvailable = 0;
return 0;
}
hb_log("Nvenc version %d.%d\n", nvenc_ver >> 4, nvenc_ver & 0xf);
if ((NVENCAPI_MAJOR_VERSION << 4 | NVENCAPI_MINOR_VERSION) > nvenc_ver) {
hb_log("NVENC version not supported. Disabling feature.");
isAvailable = 0;
return 0;
}
isAvailable = 1;
return 1;
#else
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment