Index: /trunk/include/VBox/VBoxOGLTest.h
===================================================================
--- /trunk/include/VBox/VBoxOGLTest.h	(revision 52621)
+++ /trunk/include/VBox/VBoxOGLTest.h	(revision 52622)
@@ -4,5 +4,5 @@
  */
 /*
- * Copyright (C) 2012 Oracle Corporation
+ * Copyright (C) 2012-2014 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -30,4 +30,5 @@
 RT_C_DECLS_BEGIN
 
+bool RTCALL VBoxOglIsOfflineRenderingAppropriate();
 bool RTCALL VBoxOglIs3DAccelerationSupported();
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/Info.plist
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/Info.plist	(revision 52621)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/Info.plist	(revision 52622)
@@ -16,4 +16,5 @@
     <key>LSCanProvideIMVideoDataSource</key>    <false/>
     <key>NSHighResolutionCapable</key>          <true/>
+    <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
     <key>CFBundleDocumentTypes</key>
     <array>
Index: /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VM-Info.plist
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VM-Info.plist	(revision 52621)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VM-Info.plist	(revision 52622)
@@ -16,4 +16,5 @@
     <key>LSCanProvideIMVideoDataSource</key>    <true/>
     <key>NSHighResolutionCapable</key>          <true/>
+    <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
 </dict>
 </plist>
Index: /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/vmstarter-Info.plist
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/vmstarter-Info.plist	(revision 52621)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/vmstarter-Info.plist	(revision 52622)
@@ -16,4 +16,5 @@
     <key>LSUIElement</key>                      <true/>
     <key>NSHighResolutionCapable</key>          <true/>
+    <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
     <key>CFBundleDocumentTypes</key>
     <array>
Index: /trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk	(revision 52621)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk	(revision 52622)
@@ -5,5 +5,5 @@
 
 #
-# Copyright (C) 2008-2012 Oracle Corporation
+# Copyright (C) 2008-2014 Oracle Corporation
 #
 # This file is part of VirtualBox Open Source Edition (OSE), as
@@ -264,4 +264,5 @@
 VBoxOGLrenderspu_OBJCFLAGS.darwin = -Wno-shadow
 VBoxOGLrenderspu_SOURCES.darwin  = \
+	OpenGLTest/OpenGLTestDarwin.cpp \
 	render/renderspu_cocoa.c \
 	render/renderspu_cocoa_helper.m
@@ -272,5 +273,5 @@
 VBoxOGLrenderspu_DEFS += VBOX_WITH_VDMA
 endif
-VBoxOGLrenderspu_LDFLAGS.darwin += -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxOGLrenderspu.dylib
+VBoxOGLrenderspu_LDFLAGS.darwin += -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxOGLrenderspu.dylib -framework IOKit
 VBoxOGLrenderspu_LIBS = \
 	$(PATH_STAGE_LIB)/VBoxOGLhostspuload$(VBOX_SUFF_LIB) \
Index: /trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp	(revision 52621)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp	(revision 52622)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2009-2012 Oracle Corporation
+ * Copyright (C) 2009-2014 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -18,4 +18,5 @@
 
 
+#include <IOKit/IOKitLib.h>
 #include <OpenGL/OpenGL.h>
 #include <ApplicationServices/ApplicationServices.h>
@@ -28,5 +29,72 @@
 #include <iprt/log.h>
 
+#include <iprt/asm.h>
+#include <iprt/thread.h>
+
 #include <VBox/VBoxOGLTest.h>
+
+bool RTCALL VBoxOglIsOfflineRenderingAppropriate()
+{
+    /* It is assumed that it is makes sense to enable offline rendering
+       only in case if host has more than one GPU installed. This routine
+       counts all the PCI devices in IORegistry which have IOName property
+       set to "display". If the amount of such devices if greater than one,
+       it returns TRUE or FALSE otherwise. */
+
+    kern_return_t   krc;
+    io_iterator_t   matchingServices;
+    CFDictionaryRef pMatchingDictionary;
+    static bool     fAppropriate = false;
+
+    /* In order to do not slowdown 3D engine which can ask about offline rendering several times,
+       let's cache the result and assume that renderers amount value is constant. Also prevent threads race
+       on startup. */
+
+    static bool volatile fState = false;
+    if (!ASMAtomicCmpXchgBool(&fState, true, false))
+    {
+        while (ASMAtomicReadBool(&fState) != true)
+            RTThreadSleep(5);
+
+        return fAppropriate;
+    }
+
+#define VBOX_OGL_RENDERER_MATCH_KEYS_NUM    (2)
+
+    CFStringRef ppDictionaryKeys[VBOX_OGL_RENDERER_MATCH_KEYS_NUM] = { CFSTR(kIOProviderClassKey), CFSTR(kIONameMatchKey) };
+    CFStringRef ppDictionaryVals[VBOX_OGL_RENDERER_MATCH_KEYS_NUM] = { CFSTR("IOPCIDevice"),       CFSTR("display") };
+
+    pMatchingDictionary = CFDictionaryCreate(kCFAllocatorDefault,
+                                             (const void **)ppDictionaryKeys,
+                                             (const void **)ppDictionaryVals,
+                                             VBOX_OGL_RENDERER_MATCH_KEYS_NUM,
+                                             &kCFTypeDictionaryKeyCallBacks,
+                                             &kCFTypeDictionaryValueCallBacks);
+    if (pMatchingDictionary)
+    {
+        /* The reference to pMatchingDictionary is consumed by the function below => no IORelease(pMatchingDictionary)! */
+        krc = IOServiceGetMatchingServices(kIOMasterPortDefault, pMatchingDictionary, &matchingServices);
+        if (krc == kIOReturnSuccess)
+        {
+            io_object_t matchingService;
+            int         cMatchingServices = 0;
+
+            while ((matchingService = IOIteratorNext(matchingServices)) != 0)
+            {
+                cMatchingServices++;
+                IOObjectRelease(matchingService);
+            }
+
+            fAppropriate = (cMatchingServices > 1);
+
+            IOObjectRelease(matchingServices);
+        }
+
+    }
+
+    LogRel(("OpenGL: Offline rendering support is %s (PID=%d)\n", fAppropriate ? "ON" : "OFF", (int)getpid()));
+
+    return fAppropriate;
+}
 
 bool RTCALL VBoxOglIs3DAccelerationSupported()
@@ -49,4 +117,5 @@
         kCGLPFADoubleBuffer,
         kCGLPFAWindow,
+        VBoxOglIsOfflineRenderingAppropriate() ? kCGLPFAAllowOfflineRenderers : (CGLPixelFormatAttribute)NULL,
         (CGLPixelFormatAttribute)NULL
     };
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 52621)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 52622)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2009-2012 Oracle Corporation
+ * Copyright (C) 2009-2014 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -28,4 +28,5 @@
 #include <iprt/time.h>
 #include <iprt/assert.h>
+#include <VBox/VBoxOGLTest.h>
 
 #include <cr_vreg.h>
@@ -2418,4 +2419,10 @@
     }
 
+    if (VBoxOglIsOfflineRenderingAppropriate())
+    {
+        DEBUG_MSG(("Offline rendering is enabled\n"));
+        attribs[i++] = NSOpenGLPFAAllowOfflineRenderers;
+    }
+
     /* Mark the end */
     attribs[i++] = 0;
