[PATCH vkd3d 2/5] tests: Add some tests for casting output arguments to functions.

Giovanni Mascellani gmascellani at codeweavers.com
Thu Feb 17 07:36:13 CST 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>

Il 16/02/22 06:29, Zebediah Figura ha scritto:
> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
> ---
>   Makefile.am                          |   2 +
>   tests/hlsl-function-cast.shader_test | 103 +++++++++++++++++++++++++++
>   2 files changed, 105 insertions(+)
>   create mode 100644 tests/hlsl-function-cast.shader_test
> 
> diff --git a/Makefile.am b/Makefile.am
> index dd5966ee..75c5e4b1 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -66,6 +66,7 @@ vkd3d_shader_tests = \
>   	tests/hlsl-duplicate-modifiers.shader_test \
>   	tests/hlsl-for.shader_test \
>   	tests/hlsl-function.shader_test \
> +	tests/hlsl-function-cast.shader_test \
>   	tests/hlsl-function-overload.shader_test \
>   	tests/hlsl-gather-offset.shader_test \
>   	tests/hlsl-gather.shader_test \
> @@ -318,6 +319,7 @@ XFAIL_TESTS = \
>   	tests/hlsl-duplicate-modifiers.shader_test \
>   	tests/hlsl-for.shader_test \
>   	tests/hlsl-function.shader_test \
> +	tests/hlsl-function-cast.shader_test \
>   	tests/hlsl-function-overload.shader_test \
>   	tests/hlsl-gather.shader_test \
>   	tests/hlsl-intrinsic-override.shader_test \
> diff --git a/tests/hlsl-function-cast.shader_test b/tests/hlsl-function-cast.shader_test
> new file mode 100644
> index 00000000..72ee61eb
> --- /dev/null
> +++ b/tests/hlsl-function-cast.shader_test
> @@ -0,0 +1,103 @@
> +% Test implicit and explicit casts on function output parameters.
> +
> +[pixel shader]
> +
> +uniform float4 f;
> +
> +void func(out float4 o)
> +{
> +    o = f;
> +}
> +
> +float4 main() : sv_target
> +{
> +    int4 x;
> +    func(x);
> +    return x;
> +}
> +
> +[test]
> +uniform 0 float4 -1.9 -1.0 2.9 4.0
> +draw quad
> +probe all rgba (-1.0, -1.0, 2.0, 4.0)
> +
> +% As above, but cast "x" to float4 first.
> +
> +[pixel shader]
> +
> +uniform float4 f;
> +
> +void func(out float4 o)
> +{
> +    o = f;
> +}
> +
> +float4 main() : sv_target
> +{
> +    int4 x;
> +    func((float4)x);
> +    return x;
> +}
> +
> +[test]
> +uniform 0 float4 -1.9 -1.0 2.9 4.0
> +draw quad
> +probe all rgba (-1.0, -1.0, 2.0, 4.0)
> +
> +% As above, but declare "x" as float4 and cast it to int4.
> +
> +[pixel shader]
> +
> +uniform float4 f;
> +
> +void func(out float4 o)
> +{
> +    o = f;
> +}
> +
> +float4 main() : sv_target
> +{
> +    float4 x;
> +    func((int4)x);
> +    return x;
> +}
> +
> +[test]
> +uniform 0 float4 -1.9 -1.0 2.9 4.0
> +draw quad
> +probe all rgba (-1.0, -1.0, 2.0, 4.0)
> +
> +[pixel shader]
> +
> +void func(inout float4 a)
> +{
> +    a += 0.1;
> +}
> +
> +float4 main(uniform int4 i) : sv_target
> +{
> +    int4 x = i;
> +    func(x);
> +    return x;
> +}
> +
> +[test]
> +uniform 0 int4 -2 0 1 -3000000
> +draw quad
> +probe all rgba (-1.0, 0.0, 1.0, -3000000.0)
> +
> +% You can't cast an inout parameter, though.
> +
> +[pixel shader fail]
> +
> +void func(inout float4 a)
> +{
> +    a += 0.1;
> +}
> +
> +float4 main(uniform int4 i) : sv_target
> +{
> +    int4 x = i;
> +    func((float4)x);
> +    return x;
> +}



More information about the wine-devel mailing list