From b589d6e3ef3cd3032b5491c982915c641d187865 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 9 Dec 2020 18:51:10 -0500 Subject: [PATCH] Fixes retina-display buffer size. --- OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm b/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm index 79d1bc021..90a87e55a 100644 --- a/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm +++ b/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm @@ -396,8 +396,13 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget; } - (void)updateSizeBuffersToSize:(CGSize)size { - const NSUInteger frameBufferWidth = NSUInteger(size.width * _view.layer.contentsScale) * (_isUsingSupersampling ? 2 : 1); - const NSUInteger frameBufferHeight = NSUInteger(size.height * _view.layer.contentsScale) * (_isUsingSupersampling ? 2 : 1); + // Anecdotally, the size provided here, which ultimately is from _view.drawableSize, + // already factors in Retina-style scaling. + // + // 16384 has been the maximum texture size in all Mac versions of Metal so far, and + // I haven't yet found a way to query it dynamically. So it's hard-coded. + const NSUInteger frameBufferWidth = MIN(NSUInteger(size.width) * (_isUsingSupersampling ? 2 : 1), 16384); + const NSUInteger frameBufferHeight = MIN(NSUInteger(size.height) * (_isUsingSupersampling ? 2 : 1), 16384); // Generate a framebuffer and a stencil. MTLTextureDescriptor *const textureDescriptor = [MTLTextureDescriptor