mirror of
https://github.com/RPCS3/glslang.git
synced 2024-11-27 13:10:37 +00:00
6a264bed88
This adds support for #pragma pack_matrix() to the HLSL front end. The pragma sets the default matrix layout for subsequent unqualified matrices in structs or buffers. Explicit qualification overrides the pragma value. Matrix layout is not permitted at the structure level in HLSL, so only leaves which are matrix types can be so qualified. Note that due to the semantic (not layout) difference in first matrix indirections between HLSL and SPIR-V, the sense of row and column major are flipped. That's independent of this PR: just a factor to note. A column_major qualifier appears as a RowMajor member decoration in SPIR-V modules, and vice versa.
34 lines
644 B
GLSL
34 lines
644 B
GLSL
#pragma pack_matrix(row_major)
|
|
|
|
struct MyBuffer1
|
|
{
|
|
column_major float4x4 mat1;
|
|
row_major float4x4 mat2;
|
|
/*floating*/ float4x4 mat3;
|
|
};
|
|
|
|
#pragma pack_matrix(column_major)
|
|
|
|
struct MyBuffer2
|
|
{
|
|
column_major float4x4 mat1;
|
|
row_major float4x4 mat2;
|
|
/*floating*/ float4x4 mat3;
|
|
};
|
|
|
|
#pragma pack_matrix(random_string_foo)
|
|
|
|
cbuffer Example
|
|
{
|
|
MyBuffer1 g_MyBuffer1;
|
|
MyBuffer2 g_MyBuffer2;
|
|
column_major float4x4 mat1a;
|
|
};
|
|
|
|
float4 main() : SV_Target0
|
|
{
|
|
return
|
|
g_MyBuffer1.mat1[0] + g_MyBuffer1.mat2[0] + g_MyBuffer1.mat3[0] +
|
|
g_MyBuffer2.mat1[0] + g_MyBuffer2.mat2[0] + g_MyBuffer2.mat3[0];
|
|
}
|