Clarification for layout rules in section 7.6.2.2 of the OpenGL 4.5 spec.
Reading the layout rules, rule 6.
- If the member is an array of S column-major matrices with C columns and R rows, the matrix is stored identically to a row of S x C column vectors with R components each, according to rule (4).
What is the meaning of row in this point (similar with point 8). Should it instead say array to signal the array rules should apply (so, effectively, a mat2x2[] becomes an array of arrays of vec2's?)
First, let's use mat3x4 for the example, to avoid A) ambiguity of whether a mat2x2 can be stored as a single vec4, and B) ambiguity of which number is a row and which is a column.
So, for example, let's use an array of 10 column-major matrices with 3 columns and 4 rows mat3x4[10].
Second, I am sure it is saying that a mat3x4[10] is stored identically to an array of 3x10=30 vec4s, with the columns taken, in order, to become the vec4s.
I'm assuming there is no doubt about that. Yes?
I would use language that says "...the array of matrices is stored identically to an array of S x C column vectors with R components each..."
The problem is it is casually mapping from matrix terminology (rows and columns) to array terminology (elements and vector sizes), and it further seems to be trying to demote the types one level, to discuss a single matrix in the array, and I think it got messed up a bit.
So, to say the whole thing fully correctly, I think it needs to say something like:
If the member is an array of
Scolumn-major matrices withCcolumns andRrows, the array of matrices is stored identically to an array ofSxCR-component vectors, according to rule (4), where each matrix column becomes a vector, ordered by the original array order, and within that by column number.
Whether or not we actually need to change the language, I'm less clear on.
If the language is confusing, what's the downside in changing it?
Changing things has cost too; this text is published in many revisions of multiple things. The Khronos working group can decide what to do about it. I hadn't thought it actually led you to the wrong conclusion (I asked above if it left doubt), only that it was as stupid wording.
Khronos decided to make the change I suggested (which improves on more than one problem), both to rules 6 and 8, to the next revisions of OpenGL|ES and OpenGL specifications:
- If the member is an array of
Scolumn-major matrices withCcolumns andRrows, the array of matrices is stored identically to an array ofSxCvectors withRcomponents, according to rule (4), where each matrix column becomes a vector, ordered by the original array order, and within that by column number.
- If the member is an array of
Srow-major matrices withCcolumns andRrows, the array of matrices is stored identically to an array ofSxRvectors withCcomponents, according to rule (4), where each matrix row becomes a vector, ordered by the original array order, and within that by row number.
Assigned to @oddhack to fold into the next spec update.
I ran into this independently. To me, it is clearly worded wrongly (as in: a typo), and should read:
the matrix is stored identically to *an array* of S x C column vectors
instead of "a row".