After migration from XP x86 to Windows 7 x64 (nvidia driver 197.45) my aplication is no longer working correctly.
When creating Vertex Shader I got such error log during compilation:
Vertex info
-----------
0(36) : error C5058: no buffers available for bindable uniform
....
0(36) : error C5058: no buffers available for bindable uniform
This is exactly 245 times the same error line.
And this is my shader code:
I got identical error log for fragment shader.
It looks like driver interpreters this declaration:
...
} sectors[256];
NOT as Uniform Buffer containing ARRAY but as Array of Uniform Buffers.
Error log mentioned earlier occurs on program linking level (shader object compilation isn’t returning errors).
I have also tested 197.44 developers drivers with ogl 3.3 core context (earlier 3.2 core).
And the results are the same.
Yes, that is exactly the problem. From the GLSL 4.00 spec (p. 41):
For uniform blocks declared as an array, each individual array element corresponds to a separate buffer
object backing one instance of the block. As the array size indicates the number of buffer objects needed,
uniform block array declarations must specify an array size. Any integral expression can be used to index
a uniform block array, as per section 4.1.9 “Arrays”.
To get an array of structures in a single buffer, you need to do something like:
I’m pretty sure that some earlier pre-4.0 NVIDIA drivers incorrectly interpreted this construct as an array of structures within a single buffer, which is presumably what you wanted here. I ran into this problem when exercising indexing into an array of buffers, which is a new feature in OpenGL 4.0. In OpenGL 3.3, you could declare an array of buffers, but you had to use a constant integer expression to index into it.
I’m sorry that this bug caused you problems.
EDIT: Remove the incorrect cut-and-pasted layout() qualifier on the struct declaration in my new example.
Yes, this declaration does declare an array of uniform buffers (and not an array in a single uniform buffer) – earlier drivers had a ‘bug’ here in that if the array was too big (more than the max 12 uniform buffers or whatever it was), they would treat it as an array in single buffer, but that violates the GL spec.
If you want an array in a single buffer, you need to define this as an array of structs all inside a single buffer with no index on the buffer itself.
And now it works. It really has sens for me now. I was always wondering why array of struct should be declared in such way (the old one). Problem I still see is that such method of using instancing is shown in a lot of tutorials and people think it is correct form :p.