0 Replies
      Latest reply on Mar 2, 2018 3:39 AM by MennoResolume
      MennoResolume Level 1 Level 1 (0 points)

        In the application i'm working on we're streaming a lot of texture data. I'm currently working on removing OpenGL pipeline bubbles, as part of this effort i want to make sure i'm not reusing a texture for uploading data while that texture is still being used for rendering by the gpu. When i need a texture to upload data to i've got the case where the texture is still in use. In this case i want to create a new texture, but only if there's plenty free vram memory available.


        To get the amount of available texture memory i need to know the maximum amount of memory and the currently used amount of memory.

        The OpenGL driver doesn't implement the GL_NVX_gpu_memory_info extension, so i need to use native functions to detect it.

        The maximum amount of memory i'm retreiving using the example code described in https://developer.apple.com/library/content/qa/qa1168/_index.html

        Retreiving the current amount of used/free memory seems to be an undocumented feature. I did manage to extract some information from the registry by finding a kIOAcceleratorClassName service connected to the brootstrap_port. These services contain a PerformanceStatistics dictionary with a vramFreeBytes member.


        This works in most cases, but now i want to run on a machine containing multiple gpu's. For example an integrated intel in combination with one dedicated gpu.

        In this case i need to make sure i'm getting the information from the right device. I tried using the rendererID for this, but i did not manage to match my context's rendererID to that of the service.

        To get my context's id i do this:

        NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLContext currentContext] pixelFormat];

        [pixelFormat getValues:&rendererID  forAttribute:NSOpenGLPFARendererID forVirtualScreen:virtualScreen];

        Then to get the accelerator service's rendererID i do this:

        CFDataRef ridRef = (CFDataRef)CFDictionaryGetValue( properties, CFSTR( "IOVARendererID" ) );

        const GLint* ridBytes = (const GLint*)CFDataGetBytePtr( ridRef );


        Is there a way to match these rendererID's? Or any other way to get the currently available texture vram?