Fix NVIDIA VAAPI X11 deprioritization check to actually check for X11

This commit is contained in:
Cameron Gutman 2023-09-05 20:46:43 -05:00
parent 0261c41574
commit acbe503c12

View file

@ -217,6 +217,7 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
if (status != VA_STATUS_SUCCESS && (m_WindowSystem != SDL_SYSWM_X11 || m_DecoderSelectionPass > 0)) { if (status != VA_STATUS_SUCCESS && (m_WindowSystem != SDL_SYSWM_X11 || m_DecoderSelectionPass > 0)) {
// The unofficial nvidia VAAPI driver over NVDEC/CUDA works well on Wayland, // The unofficial nvidia VAAPI driver over NVDEC/CUDA works well on Wayland,
// but we'd rather use CUDA for XWayland and VDPAU for regular X11. // but we'd rather use CUDA for XWayland and VDPAU for regular X11.
// NB: Remember to update the VA-API NVDEC condition below when modifying this!
qputenv("LIBVA_DRIVER_NAME", "nvidia"); qputenv("LIBVA_DRIVER_NAME", "nvidia");
status = tryVaInitialize(vaDeviceContext, params, &major, &minor); status = tryVaInitialize(vaDeviceContext, params, &major, &minor);
} }
@ -291,22 +292,24 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
"VAAPI driver is affected by RFI latency bug"); "VAAPI driver is affected by RFI latency bug");
} }
// Older versions of the Gallium VAAPI driver have a nasty memory leak that if (m_DecoderSelectionPass == 0 && qgetenv("FORCE_VAAPI") != "1") {
// causes memory to be leaked for each submitted frame. I believe this is // Older versions of the Gallium VAAPI driver have a nasty memory leak that
// resolved in the libva2 drivers (VAAPI 1.x). We will try to use VDPAU // causes memory to be leaked for each submitted frame. I believe this is
// instead for old VAAPI versions or drivers affected by the RFI latency bug. // resolved in the libva2 drivers (VAAPI 1.x). We will try to use VDPAU
if (m_DecoderSelectionPass == 0 && (major == 0 || m_HasRfiLatencyBug) && qgetenv("FORCE_VAAPI") != "1" && vendorStr.contains("Gallium", Qt::CaseInsensitive)) { // instead for old VAAPI versions or drivers affected by the RFI latency bug.
// Fail and let VDPAU pick this up if ((major == 0 || m_HasRfiLatencyBug) && vendorStr.contains("Gallium", Qt::CaseInsensitive)) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, // Fail and let VDPAU pick this up
"Deprioritizing VAAPI on Gallium driver. Set FORCE_VAAPI=1 to override."); SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
return false; "Deprioritizing VAAPI on Gallium driver. Set FORCE_VAAPI=1 to override.");
} return false;
}
if (m_DecoderSelectionPass == 0 && qgetenv("FORCE_VAAPI") != "1" && vendorStr.contains("VA-API NVDEC", Qt::CaseInsensitive)) {
// Prefer CUDA for XWayland and VDPAU for regular X11. // Prefer CUDA for XWayland and VDPAU for regular X11.
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, if (m_WindowSystem == SDL_SYSWM_X11 && vendorStr.contains("VA-API NVDEC", Qt::CaseInsensitive)) {
"Deprioritizing VAAPI for NVIDIA driver on X11/XWayland. Set FORCE_VAAPI=1 to override."); SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
return false; "Deprioritizing VAAPI for NVIDIA driver on X11/XWayland. Set FORCE_VAAPI=1 to override.");
return false;
}
} }
if (WMUtils::isRunningWayland()) { if (WMUtils::isRunningWayland()) {