简体   繁体   English

WebGL 参数在浏览器之间不一致

[英]WebGL parameters not consistent between browsers

I run into memory related issues with my WebGL app, mainly on PCs with Intel Graphics IGPs.我的 WebGL 应用程序遇到了与内存相关的问题,主要是在配备英特尔显卡 IGP 的 PC 上。

When trying tho find the bottleneck, I get inconsistent data from the browsers.在尝试找到瓶颈时,我从浏览器中获得了不一致的数据。

Using:使用:

var viewport = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
var texturesize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
var renderbuffer = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);

The values I get on the same PC are inconsistent:我在同一台 PC 上得到的值不一致:

Chrome铬合金

  • gl.MAX_VIEWPORT_DIMS = 16384 gl.MAX_VIEWPORT_DIMS = 16384
  • gl.MAX_TEXTURE_SIZE = 16384 gl.MAX_TEXTURE_SIZE = 16384
  • gl.MAX_RENDERBUFFER_SIZE = 16384 gl.MAX_RENDERBUFFER_SIZE = 16384

Firefox火狐

  • gl.MAX_VIEWPORT_DIMS = 16384 gl.MAX_VIEWPORT_DIMS = 16384
  • gl.MAX_TEXTURE_SIZE = 8192 gl.MAX_TEXTURE_SIZE = 8192
  • gl.MAX_RENDERBUFFER_SIZE = 8192 gl.MAX_RENDERBUFFER_SIZE = 8192

Safari苹果浏览器

  • gl.MAX_VIEWPORT_DIMS = 8192 gl.MAX_VIEWPORT_DIMS = 8192
  • gl.MAX_TEXTURE_SIZE = 16384 gl.MAX_TEXTURE_SIZE = 16384
  • gl.MAX_RENDERBUFFER_SIZE = 8192 gl.MAX_RENDERBUFFER_SIZE = 8192

I get the same values using the online WebGL browser reports我使用在线 WebGL 浏览器报告获得相同的值

Who knows what's happening here?谁知道这里发生了什么?

In https://browserleaks.com/webgl check for differences, for example which underneath api is being used (Unmasked Renderer), or which VS and PS versions are being used: perhaps one browser is using one library version and other is using other (for example Direct3D9 one and Direct3D11 other).https://browserleaks.com/webgl检查差异,例如正在使用哪个底层 API(Unmasked Renderer),或者正在使用哪些 VS 和 PS 版本:也许一个浏览器正在使用一个库版本而另一个正在使用其他(例如 Direct3D9 一个和 Direct3D11 其他)。 Maybe even the different browsers clamp the value downwards for some reason.甚至不同的浏览器也可能出于某种原因限制该值。

However, even getting different values from different browsers, those are 1D limits and your app should use much smaller values.然而,即使从不同的浏览器获得不同的值,这些都是一维限制,你的应用程序应该使用更小的值。

For example for renderbuffers and viewports: 4K resolution is 3840 x 2160 pixels (smaller) and even 8K is less than 8192. Probably your computer does not support 8K for memory reasons even with a 8192 1D limit.例如渲染缓冲区和视口:4K 分辨率是 3840 x 2160 像素(更小),甚至 8K 也小于 8192。可能由于内存原因,即使有 8192 1D 限制,您的计算机也不支持 8K。

For textures the same problem: a 16384 x 16384 will probably use 1GB of VRAM (depending on texel format and other issues), and because of allocation problems (VRAM already has allocated blocks) such a big texture maybe even have problems to be allocated in a 2GB or 4GB GPU... in a Intel GPU probably will be even harder.对于纹理同样的问题:16384 x 16384 可能会使用 1GB 的 VRAM(取决于 texel 格式和其他问题),并且由于分配问题(VRAM 已经分配了块)如此大的纹理甚至可能有问题需要分配2GB 或 4GB GPU……在英特尔 GPU 中可能会更难。

And if you want your app to be executed on different PCs, you should use much smaller values so those different values you mention doesn't really affect you: you must use much smaller ones (or at least have different alternatives which use much smaller values) if you want your app to be run in different pcs without problems.如果您希望您的应用程序在不同的 PC 上执行,您应该使用更小的值,这样您提到的那些不同的值不会真正影响您:您必须使用更小的值(或至少有使用更小的值的不同替代品) 如果您希望您的应用程序在不同的电脑上运行而不会出现问题。

  1. Browsers are free to implement their own limits浏览器可以自由实施自己的限制

    As one example Firefox has a development feature to force many smaller limits.例如, Firefox 有一项开发功能可以强制执行许多较小的限制。

    Looking in the WebKit (Safari) source we can see it's hard coded to return 8192 or less .查看 WebKit (Safari) 源代码,我们可以看到它被硬编码为返回 8192 或更少 No idea why.不知道为什么。 You'd have to ask the WebKit team.您必须询问 WebKit 团队。

  2. On Machines with multiple GPUs browsers are free to choose one GPU or the other.在具有多个 GPU 的机器上,浏览器可以自由选择一个 GPU 或另一个。 The user might also set at an OS level or in their browser's settings which GPU to use for each browser.用户还可以在操作系统级别或浏览器的设置中设置每个浏览器使用哪个 GPU。

  3. Browsers can choose different ways to implement WebGL (via OpenGL, via OpenGL ES, via DirectX, via Metal, via Vulkan, in software, etc...)浏览器可以选择不同的方式来实现 WebGL(通过 OpenGL、通过 OpenGL ES、通过 DirectX、通过 Metal、通过 Vulkan、在软件中等......)

As this was no actual question, there is no answer.由于这不是实际问题,因此没有答案。

Conclusion, the browsers don't reveal reliable data, so stats like: https://webglstats.com/webgl/parameter/MAX_RENDERBUFFER_SIZE are just an indication not 'real' data.结论,浏览器不会显示可靠数据,因此像: https : //webglstats.com/webgl/parameter/MAX_RENDERBUFFER_SIZE这样的统计数据只是一个指示,而不是“真实”数据。

For what I can see, the most useful information is the Unmasked Renderer.据我所知,最有用的信息是 Unmasked Renderer。 Guess I have to build my own detection in WebGL and test for the min values I need.猜猜我必须在 WebGL 中构建自己的检测并测试我需要的最小值。 Then store the results on the server with the Unmasked Renderer info, this way I can provide a list of GPU's that meet minimum requirements.然后将结果与 Unmasked Renderer 信息一起存储在服务器上,这样我就可以提供满足最低要求的 GPU 列表。

Thanks for the excellent information!感谢您提供非常有用的信息!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM