소스 검색

metal: hook up t.graphics.lowpower.

Resolves #2127.
Sasha Szpakowski 8 달 전
부모
커밋
1c0491c5c3
1개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. 15 1
      src/modules/graphics/metal/Graphics.mm

+ 15 - 1
src/modules/graphics/metal/Graphics.mm

@@ -289,7 +289,21 @@ Graphics::Graphics()
 	if (@available(macOS 10.15, iOS 13.0, *))
 	{
 		graphicsInstance = this;
-		device = MTLCreateSystemDefaultDevice();
+#ifdef LOVE_MACOS
+		if (isLowPowerPreferred())
+		{
+			for (id<MTLDevice> 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.");
 	}