0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

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.
This commit is contained in:
Ryan Foster 2024-03-27 14:20:02 -04:00
parent 24470b351a
commit 6f3f7b4e5a

View File

@ -32,6 +32,8 @@
((ver) << 16) | (0x7 << 28))
#define NV_ENC_CONFIG_COMPAT_VER (NVENCAPI_STRUCT_VERSION(7) | (1 << 31))
#define NV_ENC_INITIALIZE_PARAMS_COMPAT_VER \
(NVENCAPI_STRUCT_VERSION(5) | (1 << 31))
#define NV_ENC_PIC_PARAMS_COMPAT_VER (NVENCAPI_STRUCT_VERSION(4) | (1 << 31))
#define NV_ENC_LOCK_BITSTREAM_COMPAT_VER NVENCAPI_STRUCT_VERSION(1)
#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,
NV_ENC_INITIALIZE_PARAMS *params = &enc->params;
memset(params, 0, sizeof(*params));
params->version = NV_ENC_INITIALIZE_PARAMS_VER;
params->version = enc->needs_compat_ver
? NV_ENC_INITIALIZE_PARAMS_COMPAT_VER
: NV_ENC_INITIALIZE_PARAMS_VER;
params->encodeGUID = enc->codec_guid;
params->presetGUID = *nv_preset;
params->encodeWidth = width;