vkd3d/libs
Francisco Casas f5bfa728eb vkd3d-shader/hlsl: Reorder default values for matrices for SM4.
Default value initializers behave differently than regular initializers
for matrices on SM4 profiles.

While regular initializers assign the rhs elements in reading-order
(completing one row at the time), default initializers assing the rhs
elements in Chinese reading-order (completing one column at the time).

So after lowering a default value to a constant, the index of the
component to which this default value is stored is computed to meet
this expectation. This can be done because the default values.

For reference, compiling this shader:

    row_major int2x3 m = {1, 2, 3, 4, 5, 6};

    float4 main() : sv_target
    {
        return float4(m[0][0], 99, 99, 99);
    }

gives the following buffer definition:

    // cbuffer $Globals
    // {
    //
    //   row_major int2x3 m;                // Offset:    0 Size:    28
    //      = 0x00000001 0x00000003 0x00000005 0x00000000
    //        0x00000002 0x00000004 0x00000006
    //
    // }

Given that the matrix is column-major, m's default value is actually
{{1, 3, 5}, {2, 4, 6}}, unlike the {{1, 2, 3}, {4, 5, 6}} one would
expect in a regular initializer.

SM1 profiles assign the elements in regular reading order.
2024-06-11 15:46:40 +02:00
..
vkd3d Release 1.12. 2024-05-29 22:05:28 +02:00
vkd3d-common vkd3d: Implement vkd3d_shader_cache_get. 2024-04-24 23:49:20 +02:00
vkd3d-shader vkd3d-shader/hlsl: Reorder default values for matrices for SM4. 2024-06-11 15:46:40 +02:00
vkd3d-utils Release 1.12. 2024-05-29 22:05:28 +02:00
.gitignore libs/vkd3d: Trace build version. 2018-06-27 22:43:49 +02:00