1awuesterose
1awuesterose

Reputation: 557

Matrix multiplication in Metal Shading Language

I am working with Apple's Metal 2 framework. The official Metal Shading Language Documentation, section 2.3. Matrix Data Types states that:

Metal supports a subset of the matrix data types implemented by the system math library. The matrix type names supported are: halfnxm and floatnxm. Where n and m are numbers of columns and rows. n and m must be 2, 3, or 4.

So just to be sure: The largest matrix that I can define in a shader function is a 4x4 matrix?

What about larger matrices? Do I have to implement them by myself?

Upvotes: 1

Views: 2715

Answers (1)

Matthijs Hollemans
Matthijs Hollemans

Reputation: 7892

Those small matrices are primarily for doing 2D and 3D graphics work.

If you want to multiply larger matrices, look at the MPSMatrix class and the Matrices and Vectors section of the Metal Performance Shaders framework.

If you want to do a matrix multiplication as part of some larger compute kernel then you'll have to implement it yourself. (There is some Metal sample code for this.)

Upvotes: 1

Related Questions