GLSL icon indicating copy to clipboard operation
GLSL copied to clipboard

Clarification for layout rules in section 7.6.2.2 of the OpenGL 4.5 spec.

Open dj2 opened this issue 6 years ago • 6 comments

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?)

dj2 avatar Oct 07 '19 14:10 dj2

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 S column-major matrices with C columns and R rows, the array of matrices is stored identically to an array of SxC R-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.

johnkslang avatar Oct 11 '19 08:10 johnkslang

If the language is confusing, what's the downside in changing it?

dj2 avatar Oct 15 '19 13:10 dj2

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.

johnkslang avatar Oct 16 '19 13:10 johnkslang

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:

  1. If the member is an array of S column-major matrices with C columns and R rows, the array of matrices is stored identically to an array of SxC vectors with R components, according to rule (4), where each matrix column becomes a vector, ordered by the original array order, and within that by column number.
  1. If the member is an array of S row-major matrices with C columns and R rows, the array of matrices is stored identically to an array of SxR vectors with C components, according to rule (4), where each matrix row becomes a vector, ordered by the original array order, and within that by row number.

johnkslang avatar Oct 16 '19 15:10 johnkslang

Assigned to @oddhack to fold into the next spec update.

pdaniell-nv avatar Oct 16 '19 15:10 pdaniell-nv

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".

CarloWood avatar Jul 27 '22 09:07 CarloWood