Skip to content

vkd3d-shader/hlsl: Fix number of components when creating a swizzle in copy-prop.

Francisco Casas requested to merge fcasas/vkd3d:fixes4 into master

This patch originally was in !93 (closed) but I decided to separate it, since it solves a different bug that the first part of that series.

Currently, in copy-prop, we may create nodes of different dimensions than the ones we are replacing, i.e. the assertions included in this patch fail for many tests.

Without the patch, the following assertion in hlsl_sm4.c fails for me

    /* Narrowing casts were already lowered. */
    assert(src_type->dimx == dst_type->dimx);

for some tests in one of my branches, because narrowing casts end up appearing if the node is replaced with a node with more components. This error happens under quite complex conditions (involving casts and matrices) that I still try to narrow down.

The cause of this problem is that, for the generated swizzles, we are passing count instead of instr_component_count. count is the number of components of the source deref (without considering the swizzle), while instr_component_count is the actual number of components of the instruction to be replaced.

Merge request reports

Loading