Skip to content

vkd3d-shader/d3dbc: Fix regression when declaring structs in SM1.

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

This commit is part of a series of commits intended to remove all uses of hlsl_type_get_regset().

However, I think it deserves to be upstreamed sooner since it solves a rather important SM1 regression (explained below) introduced in e0031d2a .


In SM1 we can expect all variables to always belong to a single regset. structs in particular, should always be allocated to HLSL_REGSET_NUM, since they are only allowed if all their components are numeric.

We are not covering the structs case because of the use of hlsl_type_get_regset(), which is currently not defined for structs.

So the current shader

struct
{
    float4 a;
    float4 b;
} apple;

float4 main() : sv_target
{
    return apple.a + apple.b;
}

fails with

vkd3d/libs/vkd3d-shader/hlsl.c:224: Aborting, reached unreachable code.

The solution is to iterate over all regsets to find the one where the variable is allocated (if any), and ignore all others.

Edited by Francisco Casas

Merge request reports

Loading