mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Use nvidia-vaapi-driver on Wayland systems if available
This commit is contained in:
@@ -193,6 +193,17 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status != VA_STATUS_SUCCESS
|
||||||
|
#if defined(HAVE_CUDA) || defined(HAVE_LIBVDPAU)
|
||||||
|
&& m_WindowSystem != SDL_SYSWM_X11
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
// 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.
|
||||||
|
qputenv("LIBVA_DRIVER_NAME", "nvidia");
|
||||||
|
status = vaInitialize(vaDeviceContext->display, &major, &minor);
|
||||||
|
}
|
||||||
|
|
||||||
if (status != VA_STATUS_SUCCESS) {
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
// Unset LIBVA_DRIVER_NAME if none of the drivers we tried worked. This ensures
|
// Unset LIBVA_DRIVER_NAME if none of the drivers we tried worked. This ensures
|
||||||
// we will get a fresh start using the default driver selection behavior after
|
// we will get a fresh start using the default driver selection behavior after
|
||||||
@@ -269,6 +280,15 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_CUDA) || defined(HAVE_LIBVDPAU)
|
||||||
|
if (m_WindowSystem == SDL_SYSWM_X11 && qgetenv("FORCE_VAAPI") != "1" && vendorStr.contains("VA-API NVDEC", Qt::CaseInsensitive)) {
|
||||||
|
// Prefer CUDA for XWayland and VDPAU for regular X11.
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Avoiding VAAPI for NVIDIA on X11/XWayland");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (WMUtils::isRunningWayland()) {
|
if (WMUtils::isRunningWayland()) {
|
||||||
// The iHD VAAPI driver can initialize on XWayland but it crashes in
|
// The iHD VAAPI driver can initialize on XWayland but it crashes in
|
||||||
// vaPutSurface() so we must also not directly render on XWayland.
|
// vaPutSurface() so we must also not directly render on XWayland.
|
||||||
|
|||||||
Reference in New Issue
Block a user