Skip to content

vkd3d-shader/d3dbc: Make signature masks contiguous.

Giovanni Mascellani requested to merge giomasce/vkd3d:etna into master

Consider this HLSL pixel shader:

float4 main(float4 color : COLOR) : SV_Target
{
    return float4(color.x, 10.0f, 11.0f, color.w);
}

Currently the parser describes the input signature element corresponding to semantic COLOR as having mask .xw, which is sensible. However, the SPIR-V parser will interpret that as a mask starting at x and with popcount 2, and assuming it is contiguous it will implicitly act as if it were .xy. This is not correct, because the wrong component will be loaded from the vertex stage.

This MR seeks to fix this problem by making all signature masks contiguous, adding the missing bits if necessary. AFAICT that's already the case for all TPF and DXIL programs. But I'm not sure there are no corner cases in which adding mask bits can be a problem, so I'd welcome some feedback especially by @zfigura. It might be that the correct solution is to make the SPIR-V backend able to handle discontiguous masks.

Merge request reports

Loading