[PATCH vkd3d 2/5] tests: Test the shape of the sum of two numeric values.

Matteo Bruni matteo.mystral at gmail.com
Thu Sep 2 15:08:24 CDT 2021


On Tue, Aug 31, 2021 at 4:47 PM Giovanni Mascellani
<gmascellani at codeweavers.com> wrote:
>
> Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
> ---
>  Makefile.am                  |   2 +
>  tests/hlsl-shape.shader_test | 121 +++++++++++++++++++++++++++++++++++
>  2 files changed, 123 insertions(+)
>  create mode 100644 tests/hlsl-shape.shader_test

I agree with Zeb about starting to work towards eventually making
these tests ps_2_0-compatible.

At any rate, interesting results...

> diff --git a/Makefile.am b/Makefile.am
> index 3de58991..8dbbefc7 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -65,6 +65,7 @@ vkd3d_shader_tests = \
>         tests/hlsl-nested-arrays.shader_test \
>         tests/hlsl-return-implicit-conversion.shader_test \
>         tests/hlsl-return-void.shader_test \
> +       tests/hlsl-shape.shader_test \
>         tests/hlsl-static-initializer.shader_test \
>         tests/hlsl-storage-qualifiers.shader_test \
>         tests/hlsl-struct-assignment.shader_test \
> @@ -273,6 +274,7 @@ XFAIL_TESTS = \
>         tests/hlsl-nested-arrays.shader_test \
>         tests/hlsl-return-implicit-conversion.shader_test \
>         tests/hlsl-return-void.shader_test \
> +       tests/hlsl-shape.shader_test \
>         tests/hlsl-static-initializer.shader_test \
>         tests/hlsl-storage-qualifiers.shader_test \
>         tests/hlsl-vector-indexing.shader_test \
> diff --git a/tests/hlsl-shape.shader_test b/tests/hlsl-shape.shader_test
> new file mode 100644
> index 00000000..0d488da4
> --- /dev/null
> +++ b/tests/hlsl-shape.shader_test
> @@ -0,0 +1,121 @@
> +[pixel shader]
> +float4 main(float4 pos : sv_position) : sv_target
> +{
> +    /* Scalar and scalar */
> +    float x = 1.0;
> +    float y = 2.0;
> +    if (pos.x == 0.5)
> +        return float4(x + y, 0.0, 0.0, 0.0);
> +
> +    /* Vector and vector */
> +    float1 v1 = float1(1.0);
> +    float2 v2 = float2(2.0, 3.0);
> +    float4 v4 = float4(4.0, 5.0, 6.0, 7.0);
> +    if (pos.x == 10.5)
> +        return float4(v1 + v2, 0.0, 0.0);
> +    if (pos.x == 11.5)
> +        return float4(v1 + v4);
> +    if (pos.x == 12.5)
> +        return float4(v2 + v4, 0.0, 0.0);

This is actual madness...

> +    /* Scalar and vector */
> +    if (pos.x == 20.5)
> +        return float4(x + v1, v1 + x, 0.0, 0.0);
> +    if (pos.x == 21.5)
> +        return float4(v4 + x);
> +    if (pos.x == 22.5)
> +        return float4(x + v4);
> +
> +    /* Matrix and matrix */
> +    float1x4 m14 = float1x4(1.0, 2.0, 3.0, 4.0);
> +    float4x1 m41 = float4x1(5.0, 6.0, 7.0, 8.0);
> +    float2x2 m22 = float2x2(9.0, 10.0, 11.0, 12.0);
> +    float2x3 m23 = float2x3(13.0, 14.0, 15.0,
> +                            16.0, 17.0, 18.0);
> +    float4x4 m44 = float4x4(35.0, 36.0, 37.0, 38.0,
> +                            39.0, 40.0, 41.0, 42.0,
> +                            43.0, 44.0, 45.0, 46.0,
> +                            47.0, 48.0, 49.0, 50.0);
> +    if (pos.x == 30.5)
> +        return float4(m22 + m23);
> +    if (pos.x == 31.5)
> +        return float4(m23 + m22);
> +    if (pos.x == 32.5)
> +        return float4(m14 + m44);
> +    if (pos.x == 33.5)
> +        return float4(m44 + m14);
> +    if (pos.x == 34.5)
> +        return float4(m41 + m44);
> +    if (pos.x == 35.5)
> +        return float4(m44 + m41);
> +    if (pos.x == 36.5)
> +        return float4((m44 + m23)[0], 0.0);
> +    if (pos.x == 37.5)
> +        return float4((m44 + m23)[1], 0.0);

And this isn't much better. The upside is that if (when) we find some
game that happens to depend on some weird corner case of the
expression promotion / conversion rules that we will inevitably miss,
it should be pretty easy to figure out and fix.



More information about the wine-devel mailing list