Commit Graph

778 Commits

Author SHA1 Message Date
Shaun Ren
52f00ceec5 vkd3d-shader/hlsl: Use a block in split_copy(). 2025-12-08 17:01:57 +01:00
Henri Verbeet
9ddb815127 vkd3d-shader/ir: Rename struct vkd3d_shader_src_param to struct vsir_src_operand. 2025-12-04 19:22:30 +01:00
Henri Verbeet
59c8c1b8fa vkd3d-shader/ir: Rename struct vkd3d_shader_dst_param to struct vsir_dst_operand. 2025-12-04 19:21:37 +01:00
Elizabeth Figura
647482b6f4 vkd3d-shader/hlsl: Avoid creating "index-val" synthetic temps if we can detect the variable was unmodified. 2025-11-25 20:23:19 +01:00
Elizabeth Figura
26a6272073 vkd3d-shader/hlsl: Handle HLSL_CLASS_VECTOR in hlsl_regset_index_from_deref().
Loads of components of vectors (i.e. functionally a subset of SWIZZLE
instructions, but expressed using LOAD) are legal, and generated elsewhere.
Due to circumstances they never reach this point currently, but we shouldn't use
vkd3d_unreachable() here.
2025-11-25 20:23:19 +01:00
Elizabeth Figura
73c8529e6e vkd3d-shader/hlsl: Calculate the bind count from the vector width.
Scalars have a reg_size of 4 on sm1. In the case of a deref of a vector or
matrix resulting in a scalar, however, this yields a required_bind_count that is
one higher than it should be. reg_size is the wrong thing to be using here,
since it describes the size of a type in isolation, but this is conceptually an
embedded type that doesn't include any padding. Since we're only dealing with
scalars and vectors here, just use their width.
2025-11-25 20:23:19 +01:00
Henri Verbeet
60fc072877 vkd3d-shader/ir: Move "has_descriptor_info" and "has_no_modifiers" to struct vsir_normalisation_flags. 2025-11-25 19:49:28 +01:00
Henri Verbeet
4039168bca vkd3d-shader/hlsl: Consider scalars to be equivalent to 1-component vectors in hlsl_add_conditional(). 2025-11-12 15:12:30 +01:00
Elizabeth Figura
1569bb3fb8 vkd3d-shader/hlsl: Only prepend a $ for parameters with the uniform keyword. 2025-11-10 16:20:08 +01:00
Elizabeth Figura
6801f50422 vkd3d-shader/hlsl: Write a "dimx" of 4 for combined sampler types in the CTAB. 2025-11-10 16:20:01 +01:00
Elizabeth Figura
da456b1fb4 vkd3d-shader/hlsl: Do not deduplicate sampler types in the CTAB. 2025-11-10 16:18:59 +01:00
Elizabeth Figura
03d02f9018 vkd3d-shader/hlsl: Write the used sampler dimension for generic samplers in the CTAB. 2025-11-10 16:18:59 +01:00
Francisco Casas
6ca05f458e vkd3d-shader/hlsl: Actually emit 0xf write masks for FOG and PSIZE destination operands. 2025-11-10 15:54:59 +01:00
Shaun Ren
58d02da892 vkd3d-shader/hlsl: Use a bool type for "new_cond" in lower_conditional_block_discard_nz().
This fixes the assertion error

    "sm4_generate_vsir_instr_expr Failed assertion: dst_type->e.numeric.type == HLSL_TYPE_BOOL"

which occurs when compiling the following HLSL shader using the ps_4_0 target profile:

    uniform float4 x;
    uniform bool b;

    float4 main() : SV_Target
    {
        if (!b)
            clip(x.x);
        else
            clip(x.y);

        return x;
    }
2025-11-10 15:51:26 +01:00
Elizabeth Figura
67d391fad8 vkd3d-shader/hlsl: Use replace_ir() for lower_discard_nz(). 2025-11-06 15:59:50 +01:00
Elizabeth Figura
88b218cae1 vkd3d-shader/hlsl: Use replace_ir() for lower_resource_load_bias(). 2025-11-06 15:59:01 +01:00
Elizabeth Figura
bf702331d9 vkd3d-shader/hlsl: Use replace_ir() for hlsl_normalize_binary_exprs(). 2025-11-06 14:10:53 +01:00
Elizabeth Figura
974db85d07 vkd3d-shader/hlsl: Use replace_ir() for fold_unary_identities(). 2025-11-06 14:10:53 +01:00
Shaun Ren
59b87c769a vkd3d-shader/hlsl: Flatten conditional blocks containing discard_neg instructions.
For any `discard_neg c` instruction in a conditional block, we replace c with
    cond ? c : 0    in a then block,
and
    cond ? 0 : c    in an else block.
2025-10-30 17:46:12 +01:00
Shaun Ren
787d49d6d8 vkd3d-shader/hlsl: Flatten conditional blocks containing discard_nz instructions.
For any `discard_nz c` instruction in a conditional block, we replace c with
    (cond && c)     in a then block,
and
    (!cond && c)    in an else block.
2025-10-30 17:46:12 +01:00
Shaun Ren
4d5a1528ab vkd3d-shader/hlsl: Flatten conditional branches containing stores.
For an if block

    if (cond)
    {
        <then_block>
    }
    else
    {
        <else_block>
    }

We flatten it by first replacing any store instruction `v[[k]] = x`
in the then_block with the following:

    1: load(v[[k]])
    2: cond ? x : @1
    3: v[[k]] = @2

Similarly, we replace any store instruction `v[[k]] = x` in the
else_block with the following:

    1: load(v[[k]])
    2: cond ? @1 : x
    3: v[[k]] = @2

Then we can concatenate <then_block> and <else_block> together and
get rid of the if block.
2025-10-30 17:46:12 +01:00
Shaun Ren
200e66ba4f vkd3d-shader/hlsl: Store the flatten type in struct hlsl_ir_if. 2025-10-30 17:46:12 +01:00
Shaun Ren
cf688f87f1 vkd3d-shader/hlsl: Cast discard_neg conditions to vec4 for d3dbc target profiles. 2025-10-30 17:46:12 +01:00
Elizabeth Figura
94c9595196 vkd3d-shader/hlsl: Use replace_ir() for fold_conditional_identities(). 2025-10-28 16:30:49 +01:00
Elizabeth Figura
1f40222a0d vkd3d-shader/hlsl: Use replace_ir() for hlsl_fold_constant_exprs(). 2025-10-28 16:30:49 +01:00