My app use an NSOpenGLView for drawing.
I want to query the current renderer associated with my OpenGL view so that I can figure out how much total VRAM it has, and how much is available.
I can get to the CGLContextObj, for my OpenGL view, but then how do I find the current renderer? It looks like you find the rendered by display ID, but how do I get the display ID for my NSOpenGLView? I’m going around and around in circles with the documentation, trying to figure this out.
Check this old sample code to see how to get a list of all renderers on a display with CGLQueryRendererInfo. You need to pass in a display mask made with CGDisplayIDToOpenGLDisplayMask.
You can get the CGDisplayID corresponding to an NSView via NSScreen:
[[[[[myview window] screen] deviceDescription] objectForKey:@“NSScreenNumber”] longValue]
Also, take a peek at /System/Library/Frameworks/OpenGL.framework/Headers/CGLTypes.h.
If you have a context, you can get the current renderer by ID like this:
CGLGetParameter(ctx, kCGLCPCurrentRendererID, &theID);
So then match kCGLRPRendererID with CGLQueryRendererInfo(), and look at kCGLRPVideoMemory.
As for “how much is available”… VRAM is virtualized. kCGLRPTextureMemory gives you a value which is roughly (kCGLRPVideoMemory - amount_the_framebuffer_is_using). After that, it’s all “available”, you’re just sharing it will all the other apps running. Just like RAM.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.