From: Matteo Bruni Subject: Re: [PATCH vkd3d 4/5] tests: Test a for loop, with break and continue. Message-Id: Date: Thu, 2 Sep 2021 22:14:10 +0200 In-Reply-To: <20210831144023.66911-4-gmascellani@codeweavers.com> References: <20210831144023.66911-1-gmascellani@codeweavers.com> <20210831144023.66911-4-gmascellani@codeweavers.com> On Tue, Aug 31, 2021 at 4:57 PM Giovanni Mascellani wrote: > > Signed-off-by: Giovanni Mascellani > --- > Makefile.am | 2 ++ > tests/hlsl-for.shader_test | 22 ++++++++++++++++++++++ > 2 files changed, 24 insertions(+) > create mode 100644 tests/hlsl-for.shader_test > > diff --git a/Makefile.am b/Makefile.am > index f9d232e2..c14f33c6 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -59,6 +59,7 @@ vkd3d_shader_tests = \ > tests/hlsl-bool-cast.shader_test \ > tests/hlsl-comma.shader_test \ > tests/hlsl-duplicate-modifiers.shader_test \ > + tests/hlsl-for.shader_test \ > tests/hlsl-invalid.shader_test \ > tests/hlsl-majority-pragma.shader_test \ > tests/hlsl-majority-typedef.shader_test \ > @@ -270,6 +271,7 @@ XFAIL_TESTS = \ > tests/hlsl-comma.shader_test \ > tests/hlsl-bool-cast.shader_test \ > tests/hlsl-duplicate-modifiers.shader_test \ > + tests/hlsl-for.shader_test \ > tests/hlsl-majority-pragma.shader_test \ > tests/hlsl-majority-typedef.shader_test \ > tests/hlsl-mul.shader_test \ > diff --git a/tests/hlsl-for.shader_test b/tests/hlsl-for.shader_test > new file mode 100644 > index 00000000..b133ce99 > --- /dev/null > +++ b/tests/hlsl-for.shader_test > @@ -0,0 +1,22 @@ > +[pixel shader] > +float4 main(float4 pos : SV_POSITION) : SV_TARGET > +{ > + int i; > + float x = 0.0; > + for (i = 0; i < 10; i++) > + { > + x += i; > + if (pos.x == 1.5 && i == 5) > + break; > + if (pos.x == 2.5 && i >= 7) > + continue; > + x -= 1; > + } > + return float4(i, x, 0.0, 0.0); > +} > + > +[test] > +draw quad > +probe rgba (0, 0) (10.0, 35.0, 0.0, 0.0) > +probe rgba (1, 0) (5.0, 10.0, 0.0, 0.0) > +probe rgba (2, 0) (10.0, 38.0, 0.0, 0.0) > -- > 2.33.0 This one is probably fine as is. It can't be compiled for ps_2_0 but we do want a test like this for "higher" shader models. We'll probably need to introduce some way to flag individual tests to be skipped for certain shader profiles, whenever the time comes. Maybe it makes sense to also have a second test identical to this one except without the position dependency. The compiler should be able to figure it out for ps_2_0 I think (possibly with further simplifications / hammering).