Commit Graph

6329 Commits

Author SHA1 Message Date
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
460abeb03e vkd3d-shader/ir: Make FOG and PSIZE write masks 0x1 on I/O normalization.
The validator checks that on normalized vsir I/O destination write masks
are always a subset of the element's write mask.

This is currently not always happening for FOG and PSIZE outputs, because
d3dbc input might use the 0xf mask instead, despite these semantics being
scalar.

Note that this problem is hidden when using varying mapping, because in
that case the vsir_program_remap_output_signature() pass, specifically
the remove_unread_output_components() function, fixes the write mask.
2025-11-10 16:15:55 +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
Henri Verbeet
74ebd4621f vkd3d-shader/msl: Implement VSIR_OP_FIRSTBIT_HI. 2025-11-04 14:59:38 +01:00
Henri Verbeet
c576a09d57 vkd3d-shader/msl: Implement VSIR_OP_FIRSTBIT_LO. 2025-11-04 14:59:38 +01:00
Henri Verbeet
08026880d6 vkd3d-shader/msl: Implement VSIR_OP_COUNTBITS. 2025-11-04 14:59:38 +01:00
Henri Verbeet
f431cddc9f vkd3d-shader/msl: Implement support for VKD3DSPR_IMMCONSTBUFFER registers. 2025-11-04 14:59:38 +01:00
Henri Verbeet
51cce61770 vkd3d-shader/msl: Implement VSIR_OP_SYNC. 2025-11-04 14:59:38 +01:00
Henri Verbeet
3660a5a79c vkd3d-shader/msl: Include metal_stdlib in the generated code.
We're already using functions not made available through either
metal_common or metal_texture. This doesn't seem to be an issue for the
Metal shader runner, possibly because the "online" compiler includes the
required headers by default. In any case, including metal_stdlib should
make all of MSLib available.
2025-11-04 14:59:38 +01:00
Giovanni Mascellani
cc1db404b0 vkd3d-shader/msl: Implement support for VKD3DSPR_UNDEF registers.
MSL doesn't seem to have any special handling for undefined values,
differently from SPIR-V. Thus we just emit zeros.

UNDEF registers are sometimes created by the DXIL parser,
for example in sm6_parser_emit_composite_construct().
2025-10-30 18:18:14 +01:00
Giovanni Mascellani
eaabd2ffd7 vkd3d-shader/msl: Allow binding to descriptor arrays.
This requires merging adjacent bindings in the Metal shader runner,
mostly like 805a4bc1e8 did for the
d3d12 backend.
2025-10-30 17:53:10 +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
Shaun Ren
cd9a5bf2b4 vkd3d-shader/hlsl: Dump the jump condition node in dump_ir_jump(). 2025-10-30 16:32:30 +01:00
Giovanni Mascellani
39391230d2 vkd3d-shader/msl: Pass a descriptor to msl_get_binding(). 2025-10-29 13:37:12 +01:00