Skip to content

Commit 5c53390

Browse files
committed
obs-ffmpeg: Fix NVENC compatibility hack for old drivers/hardware
Add a COMPAT version of NV_ENC_INITIALIZE_PARAMS_VER, which changed between SDK 12.0 and 12.1. If using drivers older than the configured SDK/API requires, fall back to the compatibility version of the API (11.1). An example scenario would be encoding in H.264 on driver version 512.15. SDK 12.1 requires driver version 531.61 on Windows. Currently, in this scenario, OBS will fall back to the FFmpeg encoder path, which will do its own driver check, which will fail on this driver version. With this change, this scenario will instead leverage the existing compatibility hack to fall back to the compatibility version of the API without falling back to FFmpeg. It should be noted that while neat, the compatibility hack that enables Kepler GPUs to continue to be able to use NVENC in this way is expected to be removed at some point. (cherry picked from commit 6f3f7b4)
1 parent 925a1b2 commit 5c53390

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

plugins/obs-ffmpeg/obs-nvenc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
((ver) << 16) | (0x7 << 28))
3333

3434
#define NV_ENC_CONFIG_COMPAT_VER (NVENCAPI_STRUCT_VERSION(7) | (1 << 31))
35+
#define NV_ENC_INITIALIZE_PARAMS_COMPAT_VER \
36+
(NVENCAPI_STRUCT_VERSION(5) | (1 << 31))
3537
#define NV_ENC_PIC_PARAMS_COMPAT_VER (NVENCAPI_STRUCT_VERSION(4) | (1 << 31))
3638
#define NV_ENC_LOCK_BITSTREAM_COMPAT_VER NVENCAPI_STRUCT_VERSION(1)
3739
#define NV_ENC_REGISTER_RESOURCE_COMPAT_VER NVENCAPI_STRUCT_VERSION(3)
@@ -387,7 +389,9 @@ static void initialize_params(struct nvenc_data *enc, const GUID *nv_preset,
387389

388390
NV_ENC_INITIALIZE_PARAMS *params = &enc->params;
389391
memset(params, 0, sizeof(*params));
390-
params->version = NV_ENC_INITIALIZE_PARAMS_VER;
392+
params->version = enc->needs_compat_ver
393+
? NV_ENC_INITIALIZE_PARAMS_COMPAT_VER
394+
: NV_ENC_INITIALIZE_PARAMS_VER;
391395
params->encodeGUID = enc->codec_guid;
392396
params->presetGUID = *nv_preset;
393397
params->encodeWidth = width;

0 commit comments

Comments
 (0)