diff options
author | Graham Madarasz (Graham Linden) <graham@lindenlab.com> | 2013-02-27 06:46:53 -0800 |
---|---|---|
committer | Graham Madarasz (Graham Linden) <graham@lindenlab.com> | 2013-02-27 06:46:53 -0800 |
commit | f5516e0fc0e6c22b25f9dca2b9b24ebd7618332a (patch) | |
tree | 939732d39be7d2a6b2f3596fc5dba020f752b754 | |
parent | 9a85a9d6bf4e41fdfb6113af26caf13f5a08c90e (diff) |
For MAINT-2404 Fixes detection of VRAM on OSX removed along with other AGL code. Code Review: callum
-rw-r--r-- | indra/llwindow/llopenglview-objc.h | 5 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 22 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx-objc.h | 1 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx-objc.mm | 5 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.cpp | 2 |
5 files changed, 35 insertions, 0 deletions
diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index b344bed2ef..c3ae34ea50 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -7,6 +7,9 @@ // #import <Cocoa/Cocoa.h> +#import <IOKit/IOKitLib.h> +#import <CoreFoundation/CFBase.h> +#import <CoreFoundation/CFNumber.h> #include "llwindowmacosx-objc.h" // Some nasty shovelling of LLOpenGLView from LLNativeBindings to prevent any C++ <-> Obj-C interop oddities. @@ -33,6 +36,8 @@ - (CGLContextObj) getCGLContextObj; - (CGLPixelFormatObj*)getCGLPixelFormatObj; +- (unsigned long) getVramSize; + @end @interface LLNSWindow : NSWindow { diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index e89c9267d5..a1dece54f4 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -39,6 +39,28 @@ @implementation LLOpenGLView +- (unsigned long)getVramSize +{ + unsigned long vram_bytes = 0; + + io_service_t display_port = CGDisplayIOServicePort(kCGDirectMainDisplay); + + const void* type_code = IORegistryEntryCreateCFProperty(display_port, CFSTR(kIOFBMemorySizeKey), kCFAllocatorDefault, kNilOptions); + + // Ensure we have valid data from IOKit + if(type_code && CFGetTypeID(type_code) == CFNumberGetTypeID()) + { + long val; + // Retrieve actual number...is Apple ever embarrassed by this nonsense? + // + CFNumberGetValue((const __CFNumber*)type_code, kCFNumberSInt32Type, &val); + vram_bytes = (unsigned long)val; + CFRelease(type_code); + } + + return vram_bytes; +} + - (void)viewDidMoveToWindow { [[NSNotificationCenter defaultCenter] addObserver:self diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index a0eab61e7c..1724b85724 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -62,6 +62,7 @@ NSWindowRef createNSWindow(int x, int y, int width, int height); GLViewRef createOpenGLView(NSWindowRef window, unsigned int samples, bool vsync); void glSwapBuffers(void* context); CGLContextObj getCGLContextObj(GLViewRef view); +unsigned long getVramSize(GLViewRef view); void getContentViewBounds(NSWindowRef window, float* bounds); void getWindowSize(NSWindowRef window, float* size); void setWindowSize(NSWindowRef window, int width, int height); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index b288671219..9b57cd27cd 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -237,6 +237,11 @@ CGLPixelFormatObj* getCGLPixelFormatObj(NSWindowRef window) return [glview getCGLPixelFormatObj]; } +unsigned long getVramSize(GLViewRef view) +{ + return [(LLOpenGLView *)view getVramSize]; +} + void getContentViewBounds(NSWindowRef window, float* bounds) { bounds[0] = [[(LLNSWindow*)window contentView] bounds].origin.x; diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index ac0fa54a68..abb3c1e50c 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -408,6 +408,8 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits mContext = getCGLContextObj(mGLView); // Since we just created the context, it needs to be set up. glNeedsInit = TRUE; + + gGLManager.mVRAM = getVramSize(mGLView); } // Hook up the context to a drawable |