GLSL float/vec3/vec4 array max size = GL_MAX_VERTEX_UNIFORM_VECTORS?

前端 未结 2 1490
谎友^
谎友^ 2020-12-16 05:07

I run

glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &maxVertUniformsVect);

and get 1024.

Than in GLSL I do

unif         


        
相关标签:
2条回答
  • 2020-12-16 05:39

    According to http://www.opengl.org/wiki/Uniform_%28GLSL%29 (Implementation limits):

    Implementation note: OpenGL implementations are allowed to reject shaders for implementation-dependent reasons. So you can have fewer active uniform components by your reckoning and still fail to link due to uniform limits. This is usually on hardware that is innately vector hardware. Pre-GeForce 8xxx hardware, and all ATi hardware does this. In this case, you should assume that each separate uniform takes up 4 components, much like it would in D3D. That means a "uniform float" is 4 components, a mat2x4 is 16 components (each row is 4 components), but a mat4x2 is 8 components.

    Which is my case, also. But it not has to be always like that. Of course, for compatible reasons it is always better to count each float/vec2/vec3 uniform value, as max size value (vec4)

    0 讨论(0)
  • 2020-12-16 05:48

    The OpenGL Docs says it all.

    GL_MAX_VERTEX_UNIFORM_VECTORS

    data returns one value, the maximum number of 4-vectors that may be held in uniform variable storage for the vertex shader. The value of GL_MAX_VERTEX_UNIFORM_VECTORS is equal to the value of GL_MAX_VERTEX_UNIFORM_COMPONENTS and must be at least 256.

    Thereby that means that no matter the type, you can only hold an array of max GL_MAX_VERTEX_UNIFORM_VECTORS in length. Even though that vec4 == 4 floats

    The maximum value of course vary by the different hardward implementations and how old/new the individual graphics card may be of OpenGL.

    0 讨论(0)
提交回复
热议问题