Question

I am looking for some JOGL classes/methods/examples to retrieve the size of total available GPU memory and the current available GPU memory.

I know it can be done using OpenGl (JOGL Java docs).

Was it helpful?

Solution

The link you posted uses NVidia proprietary extensions. However given the way modern GPUs operate it's absolutely useless to know how much "memory" there's left. Why?

Because OpenGL always operated on an abstract memory model. Single data objects (textures, VBOs) may be too large to fit into the working memory of a GPU, but there's virtually no limit on how many textures and VBOs you can have other than your system memory (CPU RAM). OpenGL always did swap the contents on demand.

And ever since OpenGL-4 / DirectX-11 capable GPUs came around which have integrated MMUs even the notion of a data object size became meaningless. Today's GPUs support sparse data objects. On a modern GPU you can allocate textures several thousand pixels wide and high and only sparsely populate them with data. So even if only one texture object is bound, parts of it may reside dormant in system memory while other parts are in GPU working memory.

Old OpenGL actually had functions to query if a texture was loaded into fast memory. But with the boundaries between GPU and system RAM vanishing those no longer made sense had subsequently have been removed.

Effectively the GPU RAM nowadays is a cache and you should treat it as such. You'll hardly query the size of the CPU caches at runtime except for very special applications.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top