From 433640de8492dfd5c1b94dd63236add4ea3bc677 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Dec 2017 06:14:22 +0530 Subject: [PATCH] Support running on the "low power" GPU on dual GPU macOS machines Fixes #136 --- CHANGELOG.rst | 2 ++ kitty/glfw.c | 1 + kitty/shaders.c | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 454928766..3b317a607 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -24,6 +24,8 @@ version 0.6.0 [future] - Use CoreText instead of FreeType to render text on macOS +- Support running on the "low power" GPU on dual GPU macOS machines + - Add a new "grid" window layout - Drop the dependency on glfw (kitty now uses a modified, bundled copy of glfw) diff --git a/kitty/glfw.c b/kitty/glfw.c index c573d74ba..1cf7f37b5 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -227,6 +227,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) { glfwWindowHint(GLFW_STENCIL_BITS, 0); #ifdef __APPLE__ if (OPT(macos_hide_titlebar)) glfwWindowHint(GLFW_DECORATED, false); + glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, true); #endif standard_cursor = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR); diff --git a/kitty/shaders.c b/kitty/shaders.c index 0636ce692..535820f26 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -114,6 +114,12 @@ layout_sprite_map() { if (!limits_updated) { glGetIntegerv(GL_MAX_TEXTURE_SIZE, &(sprite_map.max_texture_size)); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &(sprite_map.max_array_texture_layers)); +#ifdef __APPLE__ + // Since on Apple we could have multiple GPUs, with different capabilities, + // upper bound the values according to the data from http://developer.apple.com/graphicsimaging/opengl/capabilities/ + sprite_map.max_texture_size = MIN(8192, sprite_map.max_texture_size); + sprite_map.max_array_texture_layers = MIN(512, sprite_map.max_array_texture_layers); +#endif sprite_tracker_set_limits(sprite_map.max_texture_size, sprite_map.max_array_texture_layers); limits_updated = true; }