VirtualBox

Changeset 52622 in vbox


Ignore:
Timestamp:
Sep 5, 2014 6:25:38 PM (10 years ago)
Author:
vboxsync
Message:

3D: Mac OS X host: enable support for offline rendering.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxOGLTest.h

    r40858 r52622  
    44 */
    55/*
    6  * Copyright (C) 2012 Oracle Corporation
     6 * Copyright (C) 2012-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3030RT_C_DECLS_BEGIN
    3131
     32bool RTCALL VBoxOglIsOfflineRenderingAppropriate();
    3233bool RTCALL VBoxOglIs3DAccelerationSupported();
    3334
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/Info.plist

    r42085 r52622  
    1616    <key>LSCanProvideIMVideoDataSource</key>    <false/>
    1717    <key>NSHighResolutionCapable</key>          <true/>
     18    <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
    1819    <key>CFBundleDocumentTypes</key>
    1920    <array>
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VM-Info.plist

    r42085 r52622  
    1616    <key>LSCanProvideIMVideoDataSource</key>    <true/>
    1717    <key>NSHighResolutionCapable</key>          <true/>
     18    <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
    1819</dict>
    1920</plist>
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/vmstarter-Info.plist

    r42085 r52622  
    1616    <key>LSUIElement</key>                      <true/>
    1717    <key>NSHighResolutionCapable</key>          <true/>
     18    <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
    1819    <key>CFBundleDocumentTypes</key>
    1920    <array>
  • trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk

    r51676 r52622  
    55
    66#
    7 # Copyright (C) 2008-2012 Oracle Corporation
     7# Copyright (C) 2008-2014 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    264264VBoxOGLrenderspu_OBJCFLAGS.darwin = -Wno-shadow
    265265VBoxOGLrenderspu_SOURCES.darwin  = \
     266        OpenGLTest/OpenGLTestDarwin.cpp \
    266267        render/renderspu_cocoa.c \
    267268        render/renderspu_cocoa_helper.m
     
    272273VBoxOGLrenderspu_DEFS += VBOX_WITH_VDMA
    273274endif
    274 VBoxOGLrenderspu_LDFLAGS.darwin += -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxOGLrenderspu.dylib
     275VBoxOGLrenderspu_LDFLAGS.darwin += -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxOGLrenderspu.dylib -framework IOKit
    275276VBoxOGLrenderspu_LIBS = \
    276277        $(PATH_STAGE_LIB)/VBoxOGLhostspuload$(VBOX_SUFF_LIB) \
  • trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp

    r50406 r52622  
    66
    77/*
    8  * Copyright (C) 2009-2012 Oracle Corporation
     8 * Copyright (C) 2009-2014 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818
    1919
     20#include <IOKit/IOKitLib.h>
    2021#include <OpenGL/OpenGL.h>
    2122#include <ApplicationServices/ApplicationServices.h>
     
    2829#include <iprt/log.h>
    2930
     31#include <iprt/asm.h>
     32#include <iprt/thread.h>
     33
    3034#include <VBox/VBoxOGLTest.h>
     35
     36bool RTCALL VBoxOglIsOfflineRenderingAppropriate()
     37{
     38    /* It is assumed that it is makes sense to enable offline rendering
     39       only in case if host has more than one GPU installed. This routine
     40       counts all the PCI devices in IORegistry which have IOName property
     41       set to "display". If the amount of such devices if greater than one,
     42       it returns TRUE or FALSE otherwise. */
     43
     44    kern_return_t   krc;
     45    io_iterator_t   matchingServices;
     46    CFDictionaryRef pMatchingDictionary;
     47    static bool     fAppropriate = false;
     48
     49    /* In order to do not slowdown 3D engine which can ask about offline rendering several times,
     50       let's cache the result and assume that renderers amount value is constant. Also prevent threads race
     51       on startup. */
     52
     53    static bool volatile fState = false;
     54    if (!ASMAtomicCmpXchgBool(&fState, true, false))
     55    {
     56        while (ASMAtomicReadBool(&fState) != true)
     57            RTThreadSleep(5);
     58
     59        return fAppropriate;
     60    }
     61
     62#define VBOX_OGL_RENDERER_MATCH_KEYS_NUM    (2)
     63
     64    CFStringRef ppDictionaryKeys[VBOX_OGL_RENDERER_MATCH_KEYS_NUM] = { CFSTR(kIOProviderClassKey), CFSTR(kIONameMatchKey) };
     65    CFStringRef ppDictionaryVals[VBOX_OGL_RENDERER_MATCH_KEYS_NUM] = { CFSTR("IOPCIDevice"),       CFSTR("display") };
     66
     67    pMatchingDictionary = CFDictionaryCreate(kCFAllocatorDefault,
     68                                             (const void **)ppDictionaryKeys,
     69                                             (const void **)ppDictionaryVals,
     70                                             VBOX_OGL_RENDERER_MATCH_KEYS_NUM,
     71                                             &kCFTypeDictionaryKeyCallBacks,
     72                                             &kCFTypeDictionaryValueCallBacks);
     73    if (pMatchingDictionary)
     74    {
     75        /* The reference to pMatchingDictionary is consumed by the function below => no IORelease(pMatchingDictionary)! */
     76        krc = IOServiceGetMatchingServices(kIOMasterPortDefault, pMatchingDictionary, &matchingServices);
     77        if (krc == kIOReturnSuccess)
     78        {
     79            io_object_t matchingService;
     80            int         cMatchingServices = 0;
     81
     82            while ((matchingService = IOIteratorNext(matchingServices)) != 0)
     83            {
     84                cMatchingServices++;
     85                IOObjectRelease(matchingService);
     86            }
     87
     88            fAppropriate = (cMatchingServices > 1);
     89
     90            IOObjectRelease(matchingServices);
     91        }
     92
     93    }
     94
     95    LogRel(("OpenGL: Offline rendering support is %s (PID=%d)\n", fAppropriate ? "ON" : "OFF", (int)getpid()));
     96
     97    return fAppropriate;
     98}
    3199
    32100bool RTCALL VBoxOglIs3DAccelerationSupported()
     
    49117        kCGLPFADoubleBuffer,
    50118        kCGLPFAWindow,
     119        VBoxOglIsOfflineRenderingAppropriate() ? kCGLPFAAllowOfflineRenderers : (CGLPixelFormatAttribute)NULL,
    51120        (CGLPixelFormatAttribute)NULL
    52121    };
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r52616 r52622  
    55
    66/*
    7  * Copyright (C) 2009-2012 Oracle Corporation
     7 * Copyright (C) 2009-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828#include <iprt/time.h>
    2929#include <iprt/assert.h>
     30#include <VBox/VBoxOGLTest.h>
    3031
    3132#include <cr_vreg.h>
     
    24182419    }
    24192420
     2421    if (VBoxOglIsOfflineRenderingAppropriate())
     2422    {
     2423        DEBUG_MSG(("Offline rendering is enabled\n"));
     2424        attribs[i++] = NSOpenGLPFAAllowOfflineRenderers;
     2425    }
     2426
    24202427    /* Mark the end */
    24212428    attribs[i++] = 0;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette