From d06e58805bbe3f3aac5dbee352c743fa1246a11b Mon Sep 17 00:00:00 2001 From: balr0g Date: Wed, 8 Aug 2012 19:56:18 -0400 Subject: [PATCH] Fix graphics card query (thanks to http://is.gd/D2rSCR) --- .../project.pbxproj | 8 +-- .../Plugins/System Profiler/SystemProfiler.h | 3 +- .../Plugins/System Profiler/TPI_SP_SysInfo.m | 68 +++++++++++-------- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/Resources/Plugins/System Profiler/System Profiler Extension.xcodeproj/project.pbxproj b/Resources/Plugins/System Profiler/System Profiler Extension.xcodeproj/project.pbxproj index f18b3d3876..9b288a7fa3 100755 --- a/Resources/Plugins/System Profiler/System Profiler Extension.xcodeproj/project.pbxproj +++ b/Resources/Plugins/System Profiler/System Profiler Extension.xcodeproj/project.pbxproj @@ -10,10 +10,10 @@ 4C1BE0FA159A5FCF00DB3341 /* TPISystemProfiler.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1BE0F8159A5FCF00DB3341 /* TPISystemProfiler.xib */; }; 4C57A681131D378900252759 /* TPI_SP_SysInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C57A67E131D378900252759 /* TPI_SP_SysInfo.m */; }; 4C57A682131D378900252759 /* TPISystemProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C57A680131D378900252759 /* TPISystemProfiler.m */; }; - 4C57A695131D37F000252759 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C57A694131D37F000252759 /* OpenGL.framework */; }; 4C8884B0158EB9CE00747ABB /* PLWeakCompatibilityStubs.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8884AE158EB9CE00747ABB /* PLWeakCompatibilityStubs.m */; }; 4CD69D82131E2BD200F4618E /* MacintoshModels.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4CD69D81131E2BD200F4618E /* MacintoshModels.plist */; }; 4CEE0DD112E09A1900C5096E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CEE0DD012E09A1900C5096E /* Cocoa.framework */; }; + 63EF581515D2D5FE001071C8 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63EF581215D2D57F001071C8 /* IOKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -24,10 +24,10 @@ 4C57A67E131D378900252759 /* TPI_SP_SysInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TPI_SP_SysInfo.m; sourceTree = ""; }; 4C57A67F131D378900252759 /* TPISystemProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TPISystemProfiler.h; sourceTree = ""; }; 4C57A680131D378900252759 /* TPISystemProfiler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TPISystemProfiler.m; sourceTree = ""; }; - 4C57A694131D37F000252759 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; 4C8884AE158EB9CE00747ABB /* PLWeakCompatibilityStubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLWeakCompatibilityStubs.m; sourceTree = ""; }; 4CD69D81131E2BD200F4618E /* MacintoshModels.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = MacintoshModels.plist; sourceTree = ""; }; 4CEE0DD012E09A1900C5096E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 63EF581215D2D57F001071C8 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 8D576316048677EA00EA77CD /* SystemProfiler.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SystemProfiler.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D576317048677EA00EA77CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ @@ -38,7 +38,7 @@ buildActionMask = 2147483647; files = ( 4CEE0DD112E09A1900C5096E /* Cocoa.framework in Frameworks */, - 4C57A695131D37F000252759 /* OpenGL.framework in Frameworks */, + 63EF581515D2D5FE001071C8 /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -59,9 +59,9 @@ 089C1671FE841209C02AAC07 /* Frameworks */ = { isa = PBXGroup; children = ( + 63EF581215D2D57F001071C8 /* IOKit.framework */, 4CEE0DD012E09A1900C5096E /* Cocoa.framework */, 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */, - 4C57A694131D37F000252759 /* OpenGL.framework */, ); name = Frameworks; sourceTree = ""; diff --git a/Resources/Plugins/System Profiler/SystemProfiler.h b/Resources/Plugins/System Profiler/SystemProfiler.h index 965ef2e81e..1b4846378a 100755 --- a/Resources/Plugins/System Profiler/SystemProfiler.h +++ b/Resources/Plugins/System Profiler/SystemProfiler.h @@ -1,5 +1,4 @@ -#import -#import +#import #import "TextualApplication.h" diff --git a/Resources/Plugins/System Profiler/TPI_SP_SysInfo.m b/Resources/Plugins/System Profiler/TPI_SP_SysInfo.m index a9042f4177..8f29e0ded2 100755 --- a/Resources/Plugins/System Profiler/TPI_SP_SysInfo.m +++ b/Resources/Plugins/System Profiler/TPI_SP_SysInfo.m @@ -482,34 +482,48 @@ + (NSString *)applicationMemoryUsage + (NSString *)graphicsCardInfo { - CGDirectDisplayID displayID = CGMainDisplayID(); - CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask(displayID); - - GLint numPixelFormats = 0; - - CGLContextObj cglContext = 0; - CGLPixelFormatObj pixelFormat = NULL; - CGLContextObj curr_ctx = CGLGetCurrentContext(); - -#pragma unused(curr_ctx) - - CGLPixelFormatAttribute attribs[] = {kCGLPFADisplayMask, displayMask, 0}; - CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats); - - if (pixelFormat) { - CGLCreateContext(pixelFormat, NULL, &cglContext); - - CGLDestroyPixelFormat(pixelFormat); - CGLSetCurrentContext(cglContext); - - if (cglContext) { - NSString *model = @((const char *)glGetString(GL_RENDERER)); + CFMutableDictionaryRef pciDevices = IOServiceMatching("IOPCIDevice"); + io_iterator_t entry_iterator; + if(IOServiceGetMatchingServices(kIOMasterPortDefault, + pciDevices, + &entry_iterator) == kIOReturnSuccess) + { + NSMutableArray *gpuList = [[NSMutableArray alloc] init]; + io_iterator_t serviceObject; + while ((serviceObject = IOIteratorNext(entry_iterator))) { + CFMutableDictionaryRef serviceDictionary; + if (IORegistryEntryCreateCFProperties(serviceObject, + &serviceDictionary, + kCFAllocatorDefault, + kNilOptions) != kIOReturnSuccess) + { + IOObjectRelease(serviceObject); + continue; + } - return [model stringByReplacingOccurrencesOfString:@" OpenGL Engine" withString:NSStringEmptyPlaceholder]; - } - } - - return nil; + const void *model = CFDictionaryGetValue(serviceDictionary, @"model"); + if (model != nil) { + if (CFGetTypeID(model) == CFDataGetTypeID()) { + NSString *s = [[NSString alloc] initWithData:(__bridge NSData *)model + encoding:NSASCIIStringEncoding]; + [gpuList addObject:s]; + } + } + + CFRelease(serviceDictionary); + } + NSString *res = [[NSString alloc] init]; + for(int i=0; i < [gpuList count]; i++) + { + res = [res stringByAppendingString:[gpuList objectAtIndex:i]]; + if(i + 1 < [gpuList count]) + { + res = [res stringByAppendingString:@", "]; + } + } + return res; + } + return nil; } + (NSString *)diskInfo