PDA

View Full Version : Nvidia dmat3x4 in std140 UBO layout



anisotropic
06-17-2011, 10:25 AM
Hi,
This is NVidia 270.61 OpenGL 4.0 / ARB_gpu_shader_fp64 - specific question:

Using following shader


"layout(std140) uniform BLOCK {"
" uniform double udouble;"
" uniform dvec2 udvec2;"
" uniform dvec3 udvec3;"
" uniform dvec4 udvec4;"
" uniform dmat2 udmat2;"
" uniform dmat3 udmat3;"
" uniform dmat4 udmat4;"
" uniform dmat2x3 udmat2x3;"
" uniform dmat2x4 udmat2x4;"
" uniform dmat3x2 udmat3x2;"
" uniform dmat3x4 udmat3x4;"
" uniform dmat4x2 udmat4x2;"
" uniform dmat4x3 udmat4x3;"
"} block;"
"out vec4 v_Color;"
"void main() {"
" gl_Position = vec4(0, 0, 0, 0);"
"}";

I have got 528 for udmat3x4 GL_UNIFORM_OFFSET (obtained via glGetActiveUniformsiv). Is this correct?

Spec says, that matrices are treated as arrays of vectors, arrays should have align exact as align of single element, So:

2. If the member is a two- or four-component vector with components consuming N basic machine units, the base
alignment is 2N or 4N, respectively.

4N = 4 * sizeof(GLdouble) = 32
So the udmat3x4 should be aligned to 32, but is not! (528 % 32 = 16)
Am I right?