vkd3d/libs/vkd3d-shader
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
..
checksum.c vkd3d-shader: Introduce vkd3d_make_u{16, 32}() helpers. 2021-08-11 20:58:24 +02:00
d3d_asm.c vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
d3dbc.c vkd3d-shader/d3dbc: Write default values for SM1. 2024-06-11 15:46:40 +02:00
dxbc.c vkd3d-shader: Use a separate allocation for the "semantic_name" field of shader signature elements. 2024-05-23 23:12:06 +02:00
dxil.c vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
fx.c vkd3d-shader/hlsl: Record default values for uniforms and constant buffers. 2024-06-11 15:46:40 +02:00
glsl.c vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
hlsl_codegen.c vkd3d-shader/hlsl: Record default values for uniforms and constant buffers. 2024-06-11 15:46:40 +02:00
hlsl_constant_ops.c vkd3d-shader/hlsl: Move the "base_type" member to the class-specific union. 2024-05-06 22:12:41 +02:00
hlsl.c vkd3d-shader/hlsl: Fix numeric register offset for matrix components. 2024-06-11 15:46:40 +02:00
hlsl.h vkd3d-shader/hlsl: Record default values for uniforms and constant buffers. 2024-06-11 15:46:40 +02:00
hlsl.l vkd3d-shader/hlsl: Handle "unsigned int" type. 2024-05-30 19:56:29 +02:00
hlsl.y vkd3d-shader/hlsl: Reorder default values for matrices for SM4. 2024-06-11 15:46:40 +02:00
ir.c vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
libvkd3d-shader.pc.in build: Build libvkd3d-shader as public library. 2018-11-02 11:19:00 +01:00
preproc.h build: Make the default symbol visibility "hidden". 2021-08-09 21:43:22 +02:00
preproc.l vkd3d-shader/preproc: Treat CR as whitespace. 2024-05-23 23:11:58 +02:00
preproc.y vkd3d-shader/hlsl: Handle over/underflow when parsing integer literals. 2022-05-12 19:33:56 +02:00
spirv.c vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
tpf.c vkd3d-shader/tpf: Write default values for SM4. 2024-06-11 15:46:40 +02:00
vkd3d_shader_main.c vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
vkd3d_shader_private.h vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
vkd3d_shader.map vkd3d-shader: Implement scanning combined resource/sampler information. 2023-11-13 23:19:23 +01:00