0

My question is close to this one What is the actual number of vertex uniform components for GLSL shader on ATI graphics card?

In his case,

  • he had a GL_MAX_VERTEX_UNIFORM_COMPONENTS of 4096
  • he was using a mat4[] array
  • below 64 mat4, shader is fine, above, it isn't

As written on the wiki, on amd card, to obtain the correct value, it should be divided by 4, wich gave him 4096/4 = 1024 floats.

As a mat4 is 16 floats, he then divided it by 16, which gave him 1024/16 = 64 mat4.

So the limit is coherent with his use.


But it's not with mine, here's what i have:

  • GL_MAX_VERTEX_UNIFORM_COMPONENTS: 16384
  • array of vec3

I'm using vectors to translate instances of a cube, so the number of vectors is equals to the number of instances passed to glDrawArraysInstanced() . The code is really just gl_Position = vp * translateVec[gl_InstaceID] * pos (with vp a unique ViewProjection matrix). If there are less than 256 vectors, the cubes are correctly translated. Above 256 vectors, the first 256 cubes are ok but all the others are not, they are located at (0, 0, 0) point, looks like the vectors are (0, 0, 0).

I have an amd 6490m so like him, i should do the division by 4 step 16384/4 = 4096 floats

The wiki says that due to the vector architecture, "you should assume that each separate uniform takes up 4 components". This means that a vec3 will use 4 components instead of 3.

So 4096/4 = 1024 vec3

As you see, it isn't coherent with my observation.

What am i missing ? And also what about GL_MAX_UNIFORM_VECTORS (4096 for me) ?

Notes: I upload the vec3 array with glUniform3fv() and the array is declared with uniform vec3[255] Core profile 4.2, win7, 13.1 catalyst.

Community
  • 1
  • 1
Teybeo
  • 490
  • 4
  • 11
  • Did something confuse you about this statement: "*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.*"? Shaders can fail to compile for whatever reason the implementation so desires. If it doesn't like arrays of 256 items, then it won't compile them. – Nicol Bolas Mar 04 '13 at 12:34
  • Actually it compiles and links with zero warnings. Could it still be an implementation choice then ? – Teybeo Mar 04 '13 at 14:34
  • If it compiles and links, what problem are you getting? – Nicol Bolas Mar 04 '13 at 22:10
  • Yeah sorry, didn't really explained what happens. I'm using those vectors to translate instances of a cube (via gl_InstaceID)). The first 256 are correctly translated, the others are not translated, they are all located at (0, 0, 0) point. – Teybeo Mar 05 '13 at 21:41
  • Have you considered using [instance arrays](http://www.opengl.org/wiki/Vertex_Specification#Instanced_arrays) instead of uniform arrays? BTW, if you're making a Minecraft knockoff, don't render cubes. Render the surface of the objects, not cubes. – Nicol Bolas Mar 05 '13 at 21:44
  • Actually yes, i tried different techniques and instanced arrays works out the best for me :) ; no size limitation, i can draw up to 60k cubes with it. But i still wants to know about this issue :) – Teybeo Mar 05 '13 at 21:54

0 Answers0