Suppose I want to init the following 3x3 matrix
1.0, 2.0, 3.0
4.0, 5.0, 6.0
7.0, 8.0, 9.0
Should I use
floata3x3 = float3x3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0,7.0, 8.0, 9.0)
or
floata3x3 = float3x3(1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0)
Suppose I want to init the following 3x3 matrix
1.0, 2.0, 3.0
4.0, 5.0, 6.0
7.0, 8.0, 9.0
Should I use
floata3x3 = float3x3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0,7.0, 8.0, 9.0)
or
floata3x3 = float3x3(1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0)
It's not currently possible to initialize a matrix in the Metal shading language using a list of scalars. To answer your real question, though, elements are listed in column-major order, so the correct way to declare this matrix is:
float3x3 m = float3x3({1.0, 4.0, 7.0}, {2.0, 5.0, 8.0}, {3.0, 6.0, 9.0});
Nowadays the metal shading language specification states that it's possible, but still it doesn't specify the order, section 2.3.2 Matrix Constructors says:
Since Metal 2, a matrix of type T with n columns and m rows > can also be constructed from n * m scalars of type T. The following examples are legal constructors: float2x2(float, float, float, float); float3x2(float, float, float, float, float, float);
I'm too lazy to bounce data to the shader and back just to check, but I'd appreciate if anybody who knows would answer to the initial question, and even better would make a clarification in that document
BTW the document: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf