From 12624bc5c459d922d74f96281eedd45e1322cd19 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 8 Feb 2024 18:19:01 -0600 Subject: [PATCH] Avoid the composited display path for our Metal layer --- app/streaming/video/ffmpeg-renderers/vt.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/vt.mm b/app/streaming/video/ffmpeg-renderers/vt.mm index 7b04111e..391ba8ff 100644 --- a/app/streaming/video/ffmpeg-renderers/vt.mm +++ b/app/streaming/video/ffmpeg-renderers/vt.mm @@ -638,10 +638,20 @@ public: } } - // Configure the Metal layer for rendering + // Allow EDR content if we're streaming in a 10-bit format m_MetalLayer.wantsExtendedDynamicRangeContent = !!(params->videoFormat & VIDEO_FORMAT_MASK_10BIT); + + // Ideally, we don't actually want triple buffering due to increased + // latency since our render time is very short. However, we *need* 3 + // drawables in order to hit the offloaded "direct" display path. + // + // If we only use 2 drawables, we'll be stuck in the composited path + // (particularly for windowed mode) and our latency will actually be + // higher than opting for triple buffering. + m_MetalLayer.maximumDrawableCount = 3; + + // Allow tearing if V-Sync is off (also requires direct display path) m_MetalLayer.displaySyncEnabled = params->enableVsync; - m_MetalLayer.maximumDrawableCount = 2; // Double buffering // Create the Metal texture cache for our CVPixelBuffers CFStringRef keys[1] = { kCVMetalTextureUsage };