From 1c0491c5c3234635cefa06cbf5cc2f6c4dd3818d Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Fri, 20 Dec 2024 21:06:27 -0400 Subject: [PATCH] metal: hook up t.graphics.lowpower. Resolves #2127. --- src/modules/graphics/metal/Graphics.mm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/metal/Graphics.mm b/src/modules/graphics/metal/Graphics.mm index 1e3fa2a89..92f79e0dd 100644 --- a/src/modules/graphics/metal/Graphics.mm +++ b/src/modules/graphics/metal/Graphics.mm @@ -289,7 +289,21 @@ static inline void setSampler(id encoder, Graphics::Re if (@available(macOS 10.15, iOS 13.0, *)) { graphicsInstance = this; - device = MTLCreateSystemDefaultDevice(); +#ifdef LOVE_MACOS + if (isLowPowerPreferred()) + { + for (id dev in MTLCopyAllDevices()) + { + if (dev.isLowPower) + { + device = dev; + break; + } + } + } +#endif + if (device == nil) + device = MTLCreateSystemDefaultDevice(); if (device == nil) throw love::Exception("Metal is not supported on this system."); }