Changeset 52622 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest
- Timestamp:
- Sep 5, 2014 6:25:38 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp
r50406 r52622 6 6 7 7 /* 8 * Copyright (C) 2009-201 2Oracle Corporation8 * Copyright (C) 2009-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 19 19 20 #include <IOKit/IOKitLib.h> 20 21 #include <OpenGL/OpenGL.h> 21 22 #include <ApplicationServices/ApplicationServices.h> … … 28 29 #include <iprt/log.h> 29 30 31 #include <iprt/asm.h> 32 #include <iprt/thread.h> 33 30 34 #include <VBox/VBoxOGLTest.h> 35 36 bool 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 } 31 99 32 100 bool RTCALL VBoxOglIs3DAccelerationSupported() … … 49 117 kCGLPFADoubleBuffer, 50 118 kCGLPFAWindow, 119 VBoxOglIsOfflineRenderingAppropriate() ? kCGLPFAAllowOfflineRenderers : (CGLPixelFormatAttribute)NULL, 51 120 (CGLPixelFormatAttribute)NULL 52 121 };
Note:
See TracChangeset
for help on using the changeset viewer.