fn nvenc_negotiate(lib: &NvencLibrary)Expand description
Resolve the process-wide NVENC API version once, by probing the driver newest-first and remembering the highest version it accepts.
The bundled nv-codec-headers are NVENC 13.0 (pinned), so a current driver negotiates 13.0
natively while older drivers down-negotiate through 12.x / 11.x to the 10.0 floor (~R445). The
compiled struct layouts are the 13.0 ones, handed to older drivers with the tail their own
layouts run longer (Negotiated); only the version words change per negotiated version
(via the NvStruct::rev table), so each struct is stamped with the exact word the negotiated
SDK defined. Steps:
- Cap the search by the driver’s max: query
get_max_versionwhen present, then optionally lower it further fromPIXELFLUX_NVENC_MAX_API(e.g."11.0") for testing / pinning. A cap of 0 means unknown, and probing then relies oncreate_instanceacceptance alone. - Probe candidates newest-first (
pinned, 12.1, 12.0, 11.1, 11.0, 10.0), skipping any above the cap. Each probe stamps anNV_ENCODE_API_FUNCTION_LISTwith that version’s word and callscreate_instance. - Require the whole encode path, not just a success code: the session opener plus
nvEncInitializeEncoder,nvEncGetEncodePresetConfigEx,nvEncEncodePicture, andnvEncLockBitstreammust all be non-null, because a driver can accept the function-list word yet leave newer entry points null. The first fully-populated version wins. - Fall back to
pinnedif nothing qualifies. Stored inNVENC_NEG_VER, set-once.