有多少 WebGL 内存可用?当我用完时会发生什么? [英] How much WebGL memory is available? What happens when I run out?

查看:32
本文介绍了有多少 WebGL 内存可用?当我用完时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GPU 内存有限——通常比 JS 堆大小等更有限.诸如大量高分辨率图像之类的东西可以填满内存,而且它是共享资源,因此其他应用程序可能会占用大量内存.

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.

在 OpenGL 中,我可以查询可用内存.

In OpenGL, I can query for available memory.

在 WebGL 中有什么方法可以做同样的事情吗?我怎么知道我是否用完了?如果我这样做会怎样?

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

我不确定如何管理 WebGL 体验.如有必要,我可以回退到 SVG 或 Canvas,但我不知道什么时候有必要.

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.

推荐答案

实际上,如果没有供应商扩展,您无法在 OpenGL 中查询 VRAM 总数和可用大小.OpenGL 和 WebGL 将其隐藏在您的应用程序中.此外,WebGL 会为您管理资源,在需要时将它们上传到 VRAM.

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.

如果您尝试创建过多的资源,您的应用程序的性能将显着下降,并且有可能生成 webglcontextlost 事件.此外,Mozilla 的 WebGL 实现可能会在 texImage2D 调用上生成 OUT_OF_MEMORY 错误(在WebGL Insights"一书中提到),在某种程度上,它可以用作耗尽系统资源的迹象.

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.

这篇关于有多少 WebGL 内存可用?当我用完时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆