summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2017-01-23 20:45:41 +0000
committerJose Fonseca <jfonseca@vmware.com>2017-01-23 20:46:30 +0000
commit429e2cdb2ea5ba156a0a64c78338c6db979e2230 (patch)
treedc90d7819e478900d4f148d3eb76c8767de3436d
parentd83ab10a737d861f6c25a3727f6e28dbf876e62b (diff)
glretrace: Try to enable automatic GPU switching on macOS.
Minimal testing.
-rw-r--r--retrace/CMakeLists.txt6
-rw-r--r--retrace/Info.plist20
-rwxr-xr-xretrace/glretrace_main.cpp5
-rw-r--r--retrace/glws_cocoa.mm5
4 files changed, 36 insertions, 0 deletions
diff --git a/retrace/CMakeLists.txt b/retrace/CMakeLists.txt
index 2df63d02..57fe28f9 100644
--- a/retrace/CMakeLists.txt
+++ b/retrace/CMakeLists.txt
@@ -131,6 +131,12 @@ if (WIN32 OR APPLE OR X11_FOUND)
"-framework ApplicationServices" # CGS*
#"-framework OpenGL" # CGL*
)
+
+ # Bundle Info.plist
+ set_target_properties (glretrace PROPERTIES
+ LINK_FLAGS "-sectcreate __TEXT __info_plist ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
+ LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
+ )
else ()
target_link_libraries (glretrace ${X11_X11_LIB})
endif ()
diff --git a/retrace/Info.plist b/retrace/Info.plist
new file mode 100644
index 00000000..7429b07b
--- /dev/null
+++ b/retrace/Info.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>glretrace</string>
+ <key>CFBundleExecutable</key>
+ <string>glretrace</string>
+ <key>CFBundleIdentifier</key>
+ <string>io.github.apitrace.glretrace</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>LSUIElement</key>
+ <string>1</string>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp
index a7688e8e..829fbc87 100755
--- a/retrace/glretrace_main.cpp
+++ b/retrace/glretrace_main.cpp
@@ -430,6 +430,11 @@ initContext() {
glretrace::Context *currentContext = glretrace::getCurrentContext();
assert(currentContext);
+#if defined(__APPLE__)
+ std::cerr << "GL_RENDERER: " << (const char *)glGetString(GL_RENDERER) << std::endl;
+ std::cerr << "GL_VENDOR: " << (const char *)glGetString(GL_VENDOR) << std::endl;
+#endif
+
/* Ensure we have adequate extension support */
glfeatures::Profile currentProfile = currentContext->actualProfile();
supportsTimestamp = currentProfile.versionGreaterOrEqual(glfeatures::API_GL, 3, 3) ||
diff --git a/retrace/glws_cocoa.mm b/retrace/glws_cocoa.mm
index e27e8d6c..8e4971d7 100644
--- a/retrace/glws_cocoa.mm
+++ b/retrace/glws_cocoa.mm
@@ -277,6 +277,11 @@ createVisual(bool doubleBuffer, unsigned samples, Profile profile) {
attribs.add(NSOpenGLPFANoRecovery);
}
+ // Tell this context is offline renderer aware
+ // https://developer.apple.com/library/content/technotes/tn2229/_index.html
+ // TODO: override NSOpenGLView::update to receive notifications
+ attribs.add(NSOpenGLPFAAllowOfflineRenderers);
+
attribs.end();
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc]