cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

schlenk
Journeyman III

Estimating correct amount of GPU texture memory used/free with multiple GPUs/APUs in OpenGL?

I have a setup with one GPU (Vega RX 56) and a 5700G APU on Windows 10 machine with 32GB RAM.

Now i have a program that binds a lot of textures dynamically, while walking through a virtual world. I want to have as many textures loaded, as i can, so i need an estimate of the available free space to trigger discards/loads. For a single GPU the GL_ATI_meminfo() gets some reasonable numbers. For the APU/GPU setup, while rendering on the GPU, the numbers are hugely inflated e.g. 26 GB free texture memory is reported for a 8GB VRAM card. So overshooting the target tends to crash in the GPU driver.

What would be the proper API/way to get reliable dynamic texture memory estimates for the primary GPU only, even if an APU is present as well?

All the numbers i get look kind of bogus:

wglGetGPUInfoAMD(ids[i], WGL_GPU_RAM_AMD, GL_UNSIGNED_INT, sizeof(GLuint), &mem_mb);

this gives me 22202.

glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo);
int vram = meminfo[0] / 1024;

this gives me 11614 MB.

 

 

0 Likes
1 Solution

I have setup a machine with similar configuration to yours: Vega 8 APU + RX 560 GPU + 32GB RAM.

I did not observe any problems with reporting discrete GPU memory. Both glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI) and wglGetGPUInfoAMD() return roughly the same values as actual size of the GPU VRAM. The numbers are sligthly smaller, because of some internal allocations made by our drivers, BIOS, etc.

For APUs the reported values might be a little bit more confusing. APUs take some amount of memory out of your RAM and treat it as their private local memory. This memory will not be used by the rest of the system. You should see this in task manager - the more memory is reserved for the APU, the less RAM task manager will report. This amount is configurable through BIOS. In my case it's under Advanced->NB Configuration->UMA Framebuffer size, yours may be named differently. The rest of the RAM will be used as normal. Half of it can still be accessed by the GPU. This is a Windows design documented here: https://github.com/MicrosoftDocs/windows-driver-docs/blob/staging/windows-driver-docs-pr/display/cal....

glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI) returns value for a default rendering device for current context, which may be the APU, depending on your BIOS setup. To me it looks like your primary device is the APU. Only the "local" memory reserved for the APU is returned from this API call. In your case this would be 12GB.

wglGetGPUInfoAMD() returns all memory available to the device, which is the sum of local memory and GPU-accessible system memory. In your case this would be 12GB + (32GB - 12GB) / 2 = 22GB. You can try changing the UMA Framebuffer size in the BIOS and see if this formula still works.

Summing up, both the numbers you reported - 22202MB and 11614MB - appear to apply to the APU and they look correct to me. To get value for your Vega RX 56 from glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI), you would have to ensure your context is created for the discrete GPU, not the APU. See wglCreateAssociatedContextAMD(). For wglGetGPUInfoAMD() you would have to pass correct ID for the GPU. It seems that you are passing ID for the APU.

Please feel free to ask further questions if any of this description is confusing.

View solution in original post

0 Likes
3 Replies
dipak
Big Boss

Hi @schlenk ,

Thank you for the above query. I have moved the post to the OpenGL forum and whitelisted you for the AMD Devgurus community. I will forward your query to the OpenGL team. 

Thanks.

0 Likes
dipak
Big Boss

Hi @schlenk ,

An internal bug ticket has been created to track this issue. I will let you know once I get any update on this.

Thanks.

0 Likes

I have setup a machine with similar configuration to yours: Vega 8 APU + RX 560 GPU + 32GB RAM.

I did not observe any problems with reporting discrete GPU memory. Both glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI) and wglGetGPUInfoAMD() return roughly the same values as actual size of the GPU VRAM. The numbers are sligthly smaller, because of some internal allocations made by our drivers, BIOS, etc.

For APUs the reported values might be a little bit more confusing. APUs take some amount of memory out of your RAM and treat it as their private local memory. This memory will not be used by the rest of the system. You should see this in task manager - the more memory is reserved for the APU, the less RAM task manager will report. This amount is configurable through BIOS. In my case it's under Advanced->NB Configuration->UMA Framebuffer size, yours may be named differently. The rest of the RAM will be used as normal. Half of it can still be accessed by the GPU. This is a Windows design documented here: https://github.com/MicrosoftDocs/windows-driver-docs/blob/staging/windows-driver-docs-pr/display/cal....

glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI) returns value for a default rendering device for current context, which may be the APU, depending on your BIOS setup. To me it looks like your primary device is the APU. Only the "local" memory reserved for the APU is returned from this API call. In your case this would be 12GB.

wglGetGPUInfoAMD() returns all memory available to the device, which is the sum of local memory and GPU-accessible system memory. In your case this would be 12GB + (32GB - 12GB) / 2 = 22GB. You can try changing the UMA Framebuffer size in the BIOS and see if this formula still works.

Summing up, both the numbers you reported - 22202MB and 11614MB - appear to apply to the APU and they look correct to me. To get value for your Vega RX 56 from glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI), you would have to ensure your context is created for the discrete GPU, not the APU. See wglCreateAssociatedContextAMD(). For wglGetGPUInfoAMD() you would have to pass correct ID for the GPU. It seems that you are passing ID for the APU.

Please feel free to ask further questions if any of this description is confusing.

0 Likes