Don't use VAAPI fallback driver names on libva 2.20+

libva 2.20 is good enough at detecting driver names (even under XWayland)
that we don't need to use the fallback name list anymore. This saves time
probing drivers, avoids excessive log output from failed probes, and avoids
tickling bugs in VAAPI drivers that are installed but unused.
This commit is contained in:
Cameron Gutman 2024-06-18 00:31:59 -05:00
parent bd60b873ec
commit d3219ae24a

View File

@ -224,8 +224,32 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
bool setPathVar = false;
for (;;) {
// vaInitialize() will return the libva library version even if the function
// fails. This has been the case since libva v2.6 from 5 years ago. This
// doesn't seem to be documented anywhere, so we will be conservative to
// protect against changes in libva behavior by reinitializing major/minor
// each time and clamping it to the valid range of versions based upon
// the version of libva that we compiled with.
major = minor = 0;
status = tryVaInitialize(vaDeviceContext, params, &major, &minor);
if (status != VA_STATUS_SUCCESS && qEnvironmentVariableIsEmpty("LIBVA_DRIVER_NAME")) {
if (status != VA_STATUS_SUCCESS) {
major = std::max(major, VA_MAJOR_VERSION);
minor = std::max(minor, VA_MINOR_VERSION);
// If LIBVA_DRIVER_NAME has not been set manually and we're running a
// version of libva less than 2.20, we'll try our own fallback names.
// Beginning in libva 2.20, the driver name detection code is much
// more robust than earlier versions and it includes DRI3 support for
// driver name detection under Xwayland.
if (!qEnvironmentVariableIsEmpty("LIBVA_DRIVER_NAME")) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Skipping VAAPI fallback driver names due to LIBVA_DRIVER_NAME");
}
else if (major > 1 || (major == 1 && minor >= 20)) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Skipping VAAPI fallback driver names on libva 2.20+");
}
else {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Trying fallback VAAPI driver names");
@ -271,6 +295,7 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
qunsetenv("LIBVA_DRIVER_NAME");
}
}
}
if (status == VA_STATUS_SUCCESS) {
// Success!