WebGL 中工作项(着色器实例)内存的限制是多少?

What is the limit on work item (shader instance) memory in WebGL?

我在我的 WebGL 顶点着色器中声明了一个数组:

属性 vec2 位置;

void main() {

  #define length 1024
  float arr[length];
  // use arr so that it doesn't get optimized away

这有效,但如果我将 length 增加到 2048,那么 gl.drawArrays 什么都不做。没有错误 - 着色器编译、程序链接和传递 gl.validateProgram。我猜我试图在堆栈上使用太多内存。有没有更好的程序化方法来发现这个限制?我是不是做错了什么?

There are no errors- shaders compile, program links and passes gl.validateProgram.

如规范所保证!

Section 2.10: "Vertex Shaders", page 42:

A shader should not fail to compile, and a program object should not fail to link due to lack of instruction space or lack of temporary variables.

GLSL 规范有帮助地指出:

Appendix A, section 3: "Usage of Temporary Variables":

The maximum number of variables is defined by the conformance tests.

您可以以 ,000-,000 的极低价格获得您自己的一致性测试副本。

但是,您至少可以检测这种情况(第 2.10 节,第 41 页):

It is not always possible to determine at link time if a program object actually will execute. Therefore validation is done when the first rendering command (DrawArrays or DrawElements) is issued, to determine if the currently active program object can be executed. If it cannot be executed then no fragments will be rendered, and the rendering command will generate the error INVALID_OPERATION.