Login  Register

JOGL and NVX_gpu_memory_info extension

Posted by maany on Mar 29, 2014; 5:59am
URL: https://forum.jogamp.org/JOGL-and-NVX-gpu-memory-info-extension-tp4032074.html

Hi, I am new to JOGL.
I want to write a method to monitor GPU size and usage using JOGL. I know how to do this using openGL (http://nasutechtips.blogspot.fr/2011/02/how-to-get-gpu-memory-size-and-usage-in.html)

I wish to access the tokens GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX (0x9047)   and GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX  (0x9048) from NVX_gpu_memory_info NVIDIA openGL extension in JOGL, but i can't find them in the in any class or interface in the JOGL javadocs.

As an alternate approach, i have directly passed the value of these tokens to the gl.glGetIntegerv method ( gl is an instance of the class javax.media.opengl.GL). Unfortunately, I can't test the output as a NVIDIA gpu is not available to me.
here is the code snippet :

public int getFreeMemory() {
       GL gl = GLContext.getCurrentGL();
       IntBuffer freeMemory= BufferUtils.createIntBuffer(3);
       freeMemory.put(-1);
       try {                  
            if(gl.glGetString(GL.GL_VENDOR).equals("NVIDIA Corporation") && gl.isExtensionAvailable("GL_NVX_gpu_memory_info"))
            {
               freeMemory.clear();
               gl.glGetIntegerv(0x9048,freeMemory);
            }
       } catch (Exception e) {
           logger.log(Level.WARNING,"Cannot retrieve free memory for the NVIDIA GPU");
       }
       return freeMemory.get(0);
    }

Can you tell me
1)if JOGL API provides the constants GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX and GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
2) will the getFreeMemory() method which involves direct passing of the values of these constants to the getIntegerv method work?  

Thanks
Maany