Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much WebGL memory is available? What happens when I run out?

Tags:

memory

webgl

GPU memory is limited -- typically more limited than JS heap sizes, etc. Thing like lots of high resolution images can fill up the memory, and it is a shared resource, so other applications could be using a lot of it up.

In OpenGL, I can query for available memory.

Is there any way in WebGL do the same? How can I tell if I run out? What will happen if I do?

I'm not sure how to manage the experience for WebGL. I can fall back to SVGs or Canvas if necessary, but I don't know when that is necessary.

like image 652
Paul Draper Avatar asked Sep 18 '15 23:09

Paul Draper


1 Answers

Actually, you can't query VRAM total and available sizes in OpenGL without vendor extensions. OpenGL and consequently WebGL hide that from your application. More over, WebGL manages your resources for you, uploading them to VRAM when they're needed.

If you try to create too much resources, performance of your application will degrade significantly and there is a possibility of generating of the webglcontextlost event. Also, Mozilla's WebGL implementation may generate the OUT_OF_MEMORY error on texImage2D call (it's mentioned in the "WebGL Insights" book), which, in a way, can be used as a sign of exhausting system resources.

like image 105
Kirill Dmitrenko Avatar answered Oct 23 '22 03:10

Kirill Dmitrenko