From 586a93d7aaeed093b754b323b935c8e842aeb401 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 13 Jun 2020 20:21:54 -0700 Subject: [PATCH] Use the new EGL renderer for VAAPI by default --- .../video/ffmpeg-renderers/vaapi.cpp | 6 ++++++ app/streaming/video/ffmpeg.cpp | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/vaapi.cpp b/app/streaming/video/ffmpeg-renderers/vaapi.cpp index fecb236e..6c23ee44 100644 --- a/app/streaming/video/ffmpeg-renderers/vaapi.cpp +++ b/app/streaming/video/ffmpeg-renderers/vaapi.cpp @@ -449,6 +449,12 @@ VAAPIRenderer::canExportEGL() { VASurfaceAttrib attrs[2]; int attributeCount = 0; + if (qgetenv("VAAPI_FORCE_DIRECT") == "1") { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Using direct rendering due to environment variable"); + return false; + } + // FFmpeg handles setting these quirk flags for us if (!(vaDeviceContext->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE)) { attrs[attributeCount].type = VASurfaceAttribMemoryType; diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index bdc13bc5..2a8a3ff1 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -194,20 +194,21 @@ void FFmpegVideoDecoder::reset() bool FFmpegVideoDecoder::createFrontendRenderer(PDECODER_PARAMETERS params) { +#ifdef HAVE_EGL + if (m_BackendRenderer->canExportEGL()) { + m_FrontendRenderer = new EGLRenderer(m_BackendRenderer); + if (m_FrontendRenderer->initialize(params)) { + return true; + } + delete m_FrontendRenderer; + } +#endif + if (m_BackendRenderer->isDirectRenderingSupported()) { // The backend renderer can render to the display m_FrontendRenderer = m_BackendRenderer; } else { -#ifdef HAVE_EGL - if (m_BackendRenderer->canExportEGL()) { - m_FrontendRenderer = new EGLRenderer(m_BackendRenderer); - if (m_FrontendRenderer->initialize(params)) { - return true; - } - delete m_FrontendRenderer; - } -#endif // The backend renderer cannot directly render to the display, so // we will create an SDL renderer to draw the frames. m_FrontendRenderer = new SdlRenderer();