vkd3d-shader/hlsl: Reinterpret minimum precision types as their regular counterparts.

Reinterpret min16float, min10float, min16int, min12int, and min16uint
as their regular counterparts: float, float, int, int, uint,
respectively.

A proper implementation would require adding minimum precision
indicators to all the dxbc-tpf instructions that use these types.
Consider the output of fxc 10.1 with the following shader:

    uniform int i;

    float4 main() : sv_target
    {
        min16float4 a = {0, 1, 2, i};
        min16int2 b = {4, i};
        min10float3 c = {6.4, 7, i};
        min12int d = 9.4;
        min16uint4x2 e = {14.4, 15, 16, 17, 18, 19, 20, i};

        return mul(e, b) + a + c.xyzx + d;
    }

However, if the graphics driver doesn't have minimum precision support,
it ignores the minimum precision indicators and runs at 32-bit
precision, which is equivalent as working with regular types.
This commit is contained in:
Francisco Casas
2022-12-07 18:06:06 -03:00
committed by Alexandre Julliard
parent 4ce6a17053
commit 404a2d6a3d
Notes: Alexandre Julliard 2023-01-25 22:43:55 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/58
4 changed files with 85 additions and 7 deletions

View File

@@ -4197,7 +4197,8 @@ type:
YYABORT;
}
$$ = hlsl_get_vector_type(ctx, $3->base_type, $5);
$$ = hlsl_type_clone(ctx, hlsl_get_vector_type(ctx, $3->base_type, $5), 0, 0);
$$->is_minimum_precision = $3->is_minimum_precision;
}
| KW_VECTOR
{
@@ -4229,7 +4230,8 @@ type:
YYABORT;
}
$$ = hlsl_get_matrix_type(ctx, $3->base_type, $7, $5);
$$ = hlsl_type_clone(ctx, hlsl_get_matrix_type(ctx, $3->base_type, $7, $5), 0, 0);
$$->is_minimum_precision = $3->is_minimum_precision;
}
| KW_MATRIX
{
@@ -4298,6 +4300,18 @@ type:
| TYPE_IDENTIFIER
{
$$ = hlsl_get_type(ctx->cur_scope, $1, true);
if ($$->is_minimum_precision)
{
if (ctx->profile->major_version < 4)
{
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Target profile doesn't support minimum-precision types.");
}
else
{
FIXME("Reinterpreting type %s.\n", $$->name);
}
}
vkd3d_free($1);
}
| KW_STRUCT TYPE_IDENTIFIER