From 7e4fddbe625f5837dfc548f231af1aaafdeff81d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 8 Oct 2023 16:16:33 -0500 Subject: [PATCH] Only block EGL rendering on Pi 4 and earlier Hopefully Pi 5 is powerful enough to at least render 1080p 60 FPS. --- app/streaming/video/ffmpeg-renderers/drm.cpp | 34 +++++++++++++++++++ .../video/ffmpeg-renderers/eglvid.cpp | 11 ------ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/drm.cpp b/app/streaming/video/ffmpeg-renderers/drm.cpp index 600eee8f..68f5b17c 100644 --- a/app/streaming/video/ffmpeg-renderers/drm.cpp +++ b/app/streaming/video/ffmpeg-renderers/drm.cpp @@ -1210,6 +1210,40 @@ bool DrmRenderer::canExportEGL() { return false; } + // EGL rendering is so slow on the Raspberry Pi 4 that we should basically + // never use it. It is suitable for 1080p 30 FPS on a good day, and much + // much less than that if you decide to do something crazy like stream + // in full-screen. It's nice that it at least works now on Bullseye, but + // it's so slow that we actually wish it didn't. + if (!strcmp(m_Version->name, "vc4") && qgetenv("RPI_ALLOW_EGL_RENDER") != "1") { + drmDevicePtr device; + bool matchedBadDevice = false; + + if (drmGetDevice(m_DrmFd, &device) == 0) { + if (device->bustype == DRM_BUS_PLATFORM) { + for (int i = 0; device->deviceinfo.platform->compatible[i]; i++) { + QString compatibleId(device->deviceinfo.platform->compatible[i]); + if (compatibleId == "brcm,bcm2835-vc4" || compatibleId == "brcm,bcm2711-vc5") { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Disabling EGL rendering due to low performance on %s", + device->deviceinfo.platform->compatible[i]); + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Set RPI_ALLOW_EGL_RENDER=1 to override"); + + matchedBadDevice = true; + break; + } + } + } + + drmFreeDevice(&device); + } + + if (matchedBadDevice) { + return false; + } + } + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "DRM backend supports exporting EGLImage"); return true; diff --git a/app/streaming/video/ffmpeg-renderers/eglvid.cpp b/app/streaming/video/ffmpeg-renderers/eglvid.cpp index 584b9ed4..90b7d390 100644 --- a/app/streaming/video/ffmpeg-renderers/eglvid.cpp +++ b/app/streaming/video/ffmpeg-renderers/eglvid.cpp @@ -990,17 +990,6 @@ bool EGLRenderer::testRenderFrame(AVFrame* frame) { EGLImage imgs[EGL_MAX_PLANES]; -#ifdef HAVE_MMAL - // EGL rendering is so slow on the Raspberry Pi that we should basically - // never use it. It is suitable for 1080p 30 FPS on a good day, and much - // much less than that if you decide to do something crazy like stream - // in full-screen. It's nice that it at least works now on Bullseye, but - // it's so slow that we actually wish it didn't. - if (qgetenv("RPI_ALLOW_EGL_RENDER") != "1") { - return false; - } -#endif - // Make sure we can get working EGLImages from the backend renderer. // Some devices (Raspberry Pi) will happily decode into DRM formats that // its own GL implementation won't accept in eglCreateImage().