Why do GLSL matrices use row-major layout with the HLSL backend?

42 views
Skip to first unread message

Nicholas Chapman

unread,
Oct 6, 2024, 10:51:13 AM10/6/24
to angleproject
Hi All,
Why do GLSL matrices use row-major layout with the HLSL backend?
GLSL uses column-major layout by default.  HLSL uses column-major layout by default, AFAIK.  
So why is ANGLE emitting a bunch of row-major layout code?
For example, this is from some HLSL output from a dumped shader:

 #pragma pack_matrix(row_major)
 struct rm__PerObjectVertUniformsStruct
 {
     float4x4 _model_matrix;
    //...
 };

Because of this row-major storage, in the HLSL shader it then has to compute the transpose of matrices:

_pos_ws = mul(transpose(_model_skin_matrix5659), vec4_ctor(_final_pos_os5661, 1.0)).xyz);

This seems like a needless addition of uneeded work done.

So why use row-major at all?
Thanks,
  Nick C.



Nicholas Chapman

unread,
Oct 7, 2024, 7:12:16 AM10/7/24
to angleproject
And by the HLSL backend I mean the D3D 11 backend.

Geoff Lang

unread,
Oct 7, 2024, 10:27:28 AM10/7/24
to x_ono_s...@yahoo.com, angleproject
My memory is really fuzzy here. I believe it was that the HLSL structs do not allow per-matrix packing information but ESSL does so we have to choose one packing method. There were some other limitations around column major matrices in HLSL, at least at the time this was implemented ~2013.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/b2b970de-61e8-408b-8792-308364e748b7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages