From fe6562e31cca1b276cb02a3648c23b3071cbba76 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 19 Apr 2024 00:27:45 -0500 Subject: [PATCH] Allow forcing Metal renderer on or off via VT_FORCE_METAL=1 and VT_FORCE_METAL=0 respectively --- .../video/ffmpeg-renderers/vt_metal.mm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/vt_metal.mm b/app/streaming/video/ffmpeg-renderers/vt_metal.mm index f4aaf98c..2404a5e0 100644 --- a/app/streaming/video/ffmpeg-renderers/vt_metal.mm +++ b/app/streaming/video/ffmpeg-renderers/vt_metal.mm @@ -587,6 +587,12 @@ public: } id getMetalDevice() { + if (qgetenv("VT_FORCE_METAL") == "0") { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Avoiding Metal renderer due to VT_FORCE_METAL=0 override."); + return nullptr; + } + if (@available(macOS 11.0, *)) { NSArray> *devices = [MTLCopyAllDevices() autorelease]; if (devices.count == 0) { @@ -601,8 +607,15 @@ public: } } - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Avoiding Metal renderer due to use of dGPU/eGPU"); + if (qgetenv("VT_FORCE_METAL") == "1") { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Using Metal renderer due to VT_FORCE_METAL=1 override."); + return MTLCreateSystemDefaultDevice(); + } + else { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Avoiding Metal renderer due to use of dGPU/eGPU. Use VT_FORCE_METAL=1 to override."); + } } else { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,