Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Makefile.am | 2 ++ tests/hlsl-bool-cast.shader_test | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/hlsl-bool-cast.shader_test
diff --git a/Makefile.am b/Makefile.am index c66f7b50..3de58991 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,7 @@ vkd3d_shader_runners = \ vkd3d_shader_tests = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ + tests/hlsl-bool-cast.shader_test \ tests/hlsl-comma.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-invalid.shader_test \ @@ -265,6 +266,7 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-comma.shader_test \ + tests/hlsl-bool-cast.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ diff --git a/tests/hlsl-bool-cast.shader_test b/tests/hlsl-bool-cast.shader_test new file mode 100644 index 00000000..8880b2f5 --- /dev/null +++ b/tests/hlsl-bool-cast.shader_test @@ -0,0 +1,14 @@ +[pixel shader] +float4 main() : SV_TARGET +{ + return float4( + (float)(bool)0.0, + (float)(bool)0, + (float)(bool)2.0, + (float)(bool)2 + ); +} + +[test] +draw quad +probe all rgba (0.0, 0.0, 1.0, 1.0)
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Makefile.am | 2 + tests/hlsl-shape.shader_test | 121 +++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 tests/hlsl-shape.shader_test
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); + + /* 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); + + /* Matrix and vector */ + if (pos.x == 50.5) + return v4 + m14; + if (pos.x == 51.5) + return m14 + v4; + if (pos.x == 52.5) + return v4 + m41; + if (pos.x == 53.5) + return m41 + v4; + if (pos.x == 54.5) + return v4 + m22; + if (pos.x == 55.5) + return m22 + v4; + if (pos.x == 56.5) + return float4(v1 + m14); + if (pos.x == 57.5) + return float4(m14 + v1); + if (pos.x == 58.5) + return float4(v2 + m41, 0.0, 0.0); + if (pos.x == 59.5) + return float4(m41 + v2, 0.0, 0.0); + + /* Matrix and scalar */ + if (pos.x == 70.5) + return (x + m44)[0]; + if (pos.x == 71.5) + return (m44 + x)[1]; + + return float4(0.0, 0.0, 0.0, 0.0); +} + +[test] +draw quad +probe rgba (0, 0) (3.0, 0.0, 0.0, 0.0) + +probe rgba (10, 0) (3.0, 4.0, 0.0, 0.0) +probe rgba (11, 0) (5.0, 6.0, 7.0, 8.0) +probe rgba (12, 0) (6.0, 8.0, 0.0, 0.0) + +probe rgba (20, 0) (2.0, 2.0, 0.0, 0.0) +probe rgba (21, 0) (5.0, 6.0, 7.0, 8.0) +probe rgba (22, 0) (5.0, 6.0, 7.0, 8.0) + +probe rgba (30, 0) (22.0, 24.0, 27.0, 29.0) +probe rgba (31, 0) (22.0, 24.0, 27.0, 29.0) +probe rgba (32, 0) (36.0, 38.0, 40.0, 42.0) +probe rgba (33, 0) (36.0, 38.0, 40.0, 42.0) +probe rgba (34, 0) (40.0, 45.0, 50.0, 55.0) +probe rgba (35, 0) (40.0, 45.0, 50.0, 55.0) +probe rgba (36, 0) (48.0, 50.0, 52.0, 0.0) +probe rgba (37, 0) (55.0, 57.0, 59.0, 0.0) + +probe rgba (50, 0) (5.0, 7.0, 9.0, 11.0) +probe rgba (51, 0) (5.0, 7.0, 9.0, 11.0) +probe rgba (52, 0) (9.0, 11.0, 13.0, 15.0) +probe rgba (53, 0) (9.0, 11.0, 13.0, 15.0) +probe rgba (54, 0) (13.0, 15.0, 17.0, 19.0) +probe rgba (55, 0) (13.0, 15.0, 17.0, 19.0) +probe rgba (56, 0) (2.0, 3.0, 4.0, 5.0) +probe rgba (57, 0) (2.0, 3.0, 4.0, 5.0) +probe rgba (58, 0) (7.0, 9.0, 0.0, 0.0) +probe rgba (59, 0) (7.0, 9.0, 0.0, 0.0) + + +probe rgba (70, 0) (36.0, 37.0, 38.0, 39.0) +probe rgba (71, 0) (40.0, 41.0, 42.0, 43.0)
On 8/31/21 9:40 AM, Giovanni Mascellani wrote:
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
I'm not a huge fan of this name; it's not immediately clear to me what it means :-(
Maybe "hlsl-expression-dimensions"?
@@ -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);
- /* 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);
- /* Matrix and vector */
- if (pos.x == 50.5)
return v4 + m14;
- if (pos.x == 51.5)
return m14 + v4;
- if (pos.x == 52.5)
return v4 + m41;
- if (pos.x == 53.5)
return m41 + v4;
- if (pos.x == 54.5)
return v4 + m22;
- if (pos.x == 55.5)
return m22 + v4;
- if (pos.x == 56.5)
return float4(v1 + m14);
- if (pos.x == 57.5)
return float4(m14 + v1);
- if (pos.x == 58.5)
return float4(v2 + m41, 0.0, 0.0);
- if (pos.x == 59.5)
return float4(m41 + v2, 0.0, 0.0);
- /* Matrix and scalar */
- if (pos.x == 70.5)
return (x + m44)[0];
- if (pos.x == 71.5)
return (m44 + x)[1];
- return float4(0.0, 0.0, 0.0, 0.0);
+}
This doesn't compile with native for ps_2_0 either (see my comment on 5/5). Part of this is because it uses SV_Position, which is kind of my fault too as I've been using that. We should probably find a way to change that to texcoords instead.
With that hacked out of the way, it breaks because of the following error:
Z:\home\hazel\test.hlsl(83,38): error X5608: Compiled shader code uses too many arithmetic instruction slots (83). Max. allowed by the target (ps_2_0) is 64. Consider increasing optimization level to reduce instruction count.
(Increasing optimization level does nothing, of course.)
Hi,
thanks for the review.
Il 31/08/21 19:32, Zebediah Figura (she/her) ha scritto:
On 8/31/21 9:40 AM, Giovanni Mascellani wrote:
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
I'm not a huge fan of this name; it's not immediately clear to me what it means :-(
Maybe "hlsl-expression-dimensions"?
I though "shape" was a rather standard term. For sure it is standard in scientific computing (a trend probably set by MatLab[1]), but maybe only there. No problem in switching to your suggestion.
[1] https://www.mathworks.com/help/matlab/matrices-and-arrays.html
This doesn't compile with native for ps_2_0 either (see my comment on 5/5). Part of this is because it uses SV_Position, which is kind of my fault too as I've been using that. We should probably find a way to change that to texcoords instead.
Ok, I'll try to set it up.
With that hacked out of the way, it breaks because of the following error:
Z:\home\hazel\test.hlsl(83,38): error X5608: Compiled shader code uses too many arithmetic instruction slots (83). Max. allowed by the target (ps_2_0) is 64. Consider increasing optimization level to reduce instruction count.
(Increasing optimization level does nothing, of course.)
I guess the only way there is to split the test in many smaller shaders. Not a big problem.
Giovanni.
On 9/1/21 2:04 AM, Giovanni Mascellani wrote:
Hi,
thanks for the review.
Il 31/08/21 19:32, Zebediah Figura (she/her) ha scritto:
On 8/31/21 9:40 AM, Giovanni Mascellani wrote:
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
I'm not a huge fan of this name; it's not immediately clear to me what it means :-(
Maybe "hlsl-expression-dimensions"?
I though "shape" was a rather standard term. For sure it is standard in scientific computing (a trend probably set by MatLab[1]), but maybe only there. No problem in switching to your suggestion.
[1] https://www.mathworks.com/help/matlab/matrices-and-arrays.html
Alright, I wasn't familiar with it. If it's a standard term then no objections from me.
This doesn't compile with native for ps_2_0 either (see my comment on 5/5). Part of this is because it uses SV_Position, which is kind of my fault too as I've been using that. We should probably find a way to change that to texcoords instead.
Ok, I'll try to set it up.
With that hacked out of the way, it breaks because of the following error:
Z:\home\hazel\test.hlsl(83,38): error X5608: Compiled shader code uses too many arithmetic instruction slots (83). Max. allowed by the target (ps_2_0) is 64. Consider increasing optimization level to reduce instruction count.
(Increasing optimization level does nothing, of course.)
I guess the only way there is to split the test in many smaller shaders. Not a big problem.
Giovanni.
On Tue, Aug 31, 2021 at 4:47 PM Giovanni Mascellani gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@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.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Makefile.am | 2 + tests/hlsl-mul.shader_test | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/hlsl-mul.shader_test
diff --git a/Makefile.am b/Makefile.am index 8dbbefc7..f9d232e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,6 +62,7 @@ vkd3d_shader_tests = \ tests/hlsl-invalid.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ + tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ @@ -271,6 +272,7 @@ XFAIL_TESTS = \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ + tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ diff --git a/tests/hlsl-mul.shader_test b/tests/hlsl-mul.shader_test new file mode 100644 index 00000000..4d5af691 --- /dev/null +++ b/tests/hlsl-mul.shader_test @@ -0,0 +1,78 @@ +[pixel shader] +float4 main(float4 pos : sv_position) : sv_target +{ + float x = 10.0; + float1 v1 = float1(10.0); + float3 v3 = float3(1.0, 2.0, 3.0); + float4 v4 = float4(1.0, 2.0, 3.0, 4.0); + float1x1 m11 = float1x1(10.0); + float1x4 m14 = float1x4(1.0, 2.0, 3.0, 4.0); + float4x1 m41 = float4x1(1.0, 2.0, 3.0, 4.0); + float3x3 m33 = float3x3(1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0); + float4x4 m44 = float4x4(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0, 16.0); + + if (pos.x == 0.5) + return mul(m44, v4); + if (pos.x == 1.5) + return mul(v4, m44); + if (pos.x == 2.5) + return mul(m44, v3); + if (pos.x == 3.5) + return mul(v3, m44); + if (pos.x == 4.5) + return float4(mul(m33, v4), 0.0); + if (pos.x == 5.5) + return float4(mul(v4, m33), 0.0); + if (pos.x == 6.5) + return mul(x, m44)[1]; + if (pos.x == 7.5) + return mul(m44, x)[1]; + if (pos.x == 8.5) + return mul(v1, m44); + if (pos.x == 9.5) + return mul(m44, v1); + if (pos.x == 10.5) + return mul(m11, m44); + if (pos.x == 11.5) + return mul(m44, m11); + if (pos.x == 12.5) + return mul(m14, m44); + if (pos.x == 13.5) + return mul(m44, m14)[1]; + if (pos.x == 14.5) + return mul(m41, m44)[1]; + if (pos.x == 15.5) + return mul(m44, m41); + if (pos.x == 16.5) + return mul(m33, m44)[1]; + if (pos.x == 17.5) + return float4(mul(m44, m33)[1], 0.0); + + return float4(0.0, 0.0, 0.0, 0.0); +} + +[test] +draw quad +probe rgba (0, 0) (30.0, 70.0, 110.0, 150.0) +probe rgba (1, 0) (90.0, 100.0, 110.0, 120.0) +probe rgba (2, 0) (14.0, 38.0, 62.0, 86.0) +probe rgba (3, 0) (38.0, 44.0, 50.0, 56.0) +probe rgba (4, 0) (14.0, 32.0, 50.0, 0.0) +probe rgba (5, 0) (30.0, 36.0, 42.0, 0.0) +probe rgba (6, 0) (50.0, 60.0, 70.0, 80.0) +probe rgba (7, 0) (50.0, 60.0, 70.0, 80.0) +probe rgba (8, 0) (10.0, 20.0, 30.0, 40.0) +probe rgba (9, 0) (10.0, 50.0, 90.0, 130.0) +probe rgba (10, 0) (10.0, 20.0, 30.0, 40.0) +probe rgba (11, 0) (10.0, 50.0, 90.0, 130.0) +probe rgba (12, 0) (90.0, 100.0, 110.0, 120.0) +probe rgba (13, 0) (5.0, 10.0, 15.0, 20.0) +probe rgba (14, 0) (2.0, 4.0, 6.0, 8.0) +probe rgba (15, 0) (30.0, 70.0, 110.0, 150.0) +probe rgba (16, 0) (83.0, 98.0, 113.0, 128.0) +probe rgba (17, 0) (78.0, 96.0, 114.0, 0.0)
On Tue, Aug 31, 2021 at 4:40 PM Giovanni Mascellani gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Makefile.am | 2 + tests/hlsl-mul.shader_test | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/hlsl-mul.shader_test
diff --git a/Makefile.am b/Makefile.am index 8dbbefc7..f9d232e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,6 +62,7 @@ vkd3d_shader_tests = \ tests/hlsl-invalid.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \
tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \
@@ -271,6 +272,7 @@ XFAIL_TESTS = \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \
tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \
diff --git a/tests/hlsl-mul.shader_test b/tests/hlsl-mul.shader_test new file mode 100644 index 00000000..4d5af691 --- /dev/null +++ b/tests/hlsl-mul.shader_test @@ -0,0 +1,78 @@ +[pixel shader] +float4 main(float4 pos : sv_position) : sv_target +{
- float x = 10.0;
- float1 v1 = float1(10.0);
- float3 v3 = float3(1.0, 2.0, 3.0);
- float4 v4 = float4(1.0, 2.0, 3.0, 4.0);
- float1x1 m11 = float1x1(10.0);
- float1x4 m14 = float1x4(1.0, 2.0, 3.0, 4.0);
- float4x1 m41 = float4x1(1.0, 2.0, 3.0, 4.0);
- float3x3 m33 = float3x3(1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0);
- float4x4 m44 = float4x4(1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0,
13.0, 14.0, 15.0, 16.0);
- if (pos.x == 0.5)
return mul(m44, v4);
- if (pos.x == 1.5)
return mul(v4, m44);
- if (pos.x == 2.5)
return mul(m44, v3);
- if (pos.x == 3.5)
return mul(v3, m44);
- if (pos.x == 4.5)
return float4(mul(m33, v4), 0.0);
- if (pos.x == 5.5)
return float4(mul(v4, m33), 0.0);
- if (pos.x == 6.5)
return mul(x, m44)[1];
- if (pos.x == 7.5)
return mul(m44, x)[1];
- if (pos.x == 8.5)
return mul(v1, m44);
- if (pos.x == 9.5)
return mul(m44, v1);
More differences between scalar and vector1. Nice catch.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- 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)
On Tue, Aug 31, 2021 at 4:57 PM Giovanni Mascellani gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
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).
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Makefile.am | 2 + tests/hlsl-operations.shader_test | 86 +++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tests/hlsl-operations.shader_test
diff --git a/Makefile.am b/Makefile.am index c14f33c6..35599d9a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ vkd3d_shader_tests = \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ + tests/hlsl-operations.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ tests/hlsl-shape.shader_test \ @@ -276,6 +277,7 @@ XFAIL_TESTS = \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ + tests/hlsl-operations.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ tests/hlsl-shape.shader_test \ diff --git a/tests/hlsl-operations.shader_test b/tests/hlsl-operations.shader_test new file mode 100644 index 00000000..3c8036b5 --- /dev/null +++ b/tests/hlsl-operations.shader_test @@ -0,0 +1,86 @@ +[pixel shader] +float4 main(uniform float zero, uniform float one, uniform float x, uniform float y, + float4 pos : SV_POSITION) : SV_TARGET +{ + int izero = zero; + int ione = one; + int ix = x; + int iy = y; + uint uzero = zero; + uint uone = one; + uint ux = x; + uint uy = y; + + if (pos.x == 0.5) + return float4(x + y, x - y, x * y, x / y); + if (pos.x == 1.5) + return float4(ix + iy, ix - iy, ix * iy, ix / iy); + if (pos.x == 2.5) + return float4(ux + uy, ux - uy, ux * uy, ux / uy); + if (pos.x == 3.5) + return float4(x % y, +x, -x, y / x); + if (pos.x == 4.5) + return float4(ix % iy, +ix, -ix, iy / ix); + if (pos.x == 5.5) + return float4(ux % uy, +ux, -ux, uy / ux); + if (pos.x == 6.5) + return float4(x == y, x != y, x < y, x <= y); + if (pos.x == 7.5) + return float4(x > y, x >= y, !x, !zero); + if (pos.x == 8.5) + return float4(ix == iy, ix != iy, ix < iy, ix <= iy); + if (pos.x == 9.5) + return float4(ix > iy, ix >= iy, !ix, !izero); + if (pos.x == 10.5) + return float4(ix & iy, ix | iy, ix ^ iy, ~ix); + if (pos.x == 11.5) + return float4(ix >> 2, ix << 2, iy >> 2, iy << 2); + if (pos.x == 12.5) + return float4(ux == uy, ux != uy, ux < uy, ux <= uy); + if (pos.x == 13.5) + return float4(ux > uy, ux >= uy, !ux, !uzero); + if (pos.x == 14.5) + return float4(ux & uy, ux | uy, ux ^ uy, ~ux); + if (pos.x == 15.5) + return float4(ux >> 2, ux << 2, uy >> 2, uy << 2); + if (pos.x == 16.5) + return float4(zero && zero, zero && one, one && zero, one && one); + if (pos.x == 17.5) + return float4(zero || zero, zero || one, one || zero, one || one); + if (pos.x == 18.5) + return float4(izero && izero, izero && ione, ione && izero, ione && ione); + if (pos.x == 19.5) + return float4(izero || izero, izero || ione, ione || izero, ione || ione); + if (pos.x == 20.5) + return float4(uzero && uzero, uzero && uone, uone && uzero, uone && uone); + if (pos.x == 21.5) + return float4(uzero || uzero, uzero || uone, uone || uzero, uone || uone); + + return float4(0.0, 0.0, 0.0, 0.0); +} + +[test] +uniform 0 float4 0.0 1.0 5.0 15.0 +draw quad +probe rgba (0, 0) (20.0, -10.0, 75.0, 0.33333333) 1 +probe rgba (1, 0) (20.0, -10.0, 75.0, 0.0) +probe rgba (2, 0) (20.0, 4294967300.0, 75.0, 0.0) +probe rgba (3, 0) (5.0, 5.0, -5.0, 3.0) 1 +probe rgba (4, 0) (5.0, 5.0, -5.0, 3.0) +probe rgba (5, 0) (5.0, 5.0, 4294967300.0, 3.0) +probe rgba (6, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (7, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (8, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (9, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (10, 0) (5.0, 15.0, 10.0, -6.0) +probe rgba (11, 0) (1.0, 20.0, 3.0, 60.0) +probe rgba (12, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (13, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (14, 0) (5.0, 15.0, 10.0, 4294967300.0) +probe rgba (15, 0) (1.0, 20.0, 3.0, 60.0) +probe rgba (16, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (17, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (18, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (19, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (20, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (21, 0) (0.0, 1.0, 1.0, 1.0)
On 8/31/21 9:40 AM, Giovanni Mascellani wrote:
diff --git a/tests/hlsl-operations.shader_test b/tests/hlsl-operations.shader_test new file mode 100644 index 00000000..3c8036b5 --- /dev/null +++ b/tests/hlsl-operations.shader_test @@ -0,0 +1,86 @@ +[pixel shader] +float4 main(uniform float zero, uniform float one, uniform float x, uniform float y,
float4 pos : SV_POSITION) : SV_TARGET
+{
- int izero = zero;
- int ione = one;
- int ix = x;
- int iy = y;
- uint uzero = zero;
- uint uone = one;
- uint ux = x;
- uint uy = y;
- if (pos.x == 0.5)
return float4(x + y, x - y, x * y, x / y);
- if (pos.x == 1.5)
return float4(ix + iy, ix - iy, ix * iy, ix / iy);
- if (pos.x == 2.5)
return float4(ux + uy, ux - uy, ux * uy, ux / uy);
- if (pos.x == 3.5)
return float4(x % y, +x, -x, y / x);
- if (pos.x == 4.5)
return float4(ix % iy, +ix, -ix, iy / ix);
- if (pos.x == 5.5)
return float4(ux % uy, +ux, -ux, uy / ux);
- if (pos.x == 6.5)
return float4(x == y, x != y, x < y, x <= y);
- if (pos.x == 7.5)
return float4(x > y, x >= y, !x, !zero);
- if (pos.x == 8.5)
return float4(ix == iy, ix != iy, ix < iy, ix <= iy);
- if (pos.x == 9.5)
return float4(ix > iy, ix >= iy, !ix, !izero);
- if (pos.x == 10.5)
return float4(ix & iy, ix | iy, ix ^ iy, ~ix);
- if (pos.x == 11.5)
return float4(ix >> 2, ix << 2, iy >> 2, iy << 2);
- if (pos.x == 12.5)
return float4(ux == uy, ux != uy, ux < uy, ux <= uy);
- if (pos.x == 13.5)
return float4(ux > uy, ux >= uy, !ux, !uzero);
- if (pos.x == 14.5)
return float4(ux & uy, ux | uy, ux ^ uy, ~ux);
- if (pos.x == 15.5)
return float4(ux >> 2, ux << 2, uy >> 2, uy << 2);
- if (pos.x == 16.5)
return float4(zero && zero, zero && one, one && zero, one && one);
- if (pos.x == 17.5)
return float4(zero || zero, zero || one, one || zero, one || one);
- if (pos.x == 18.5)
return float4(izero && izero, izero && ione, ione && izero, ione && ione);
- if (pos.x == 19.5)
return float4(izero || izero, izero || ione, ione || izero, ione || ione);
- if (pos.x == 20.5)
return float4(uzero && uzero, uzero && uone, uone && uzero, uone && uone);
- if (pos.x == 21.5)
return float4(uzero || uzero, uzero || uone, uone || uzero, uone || uone);
- return float4(0.0, 0.0, 0.0, 0.0);
+}
+[test] +uniform 0 float4 0.0 1.0 5.0 15.0 +draw quad +probe rgba (0, 0) (20.0, -10.0, 75.0, 0.33333333) 1 +probe rgba (1, 0) (20.0, -10.0, 75.0, 0.0) +probe rgba (2, 0) (20.0, 4294967300.0, 75.0, 0.0) +probe rgba (3, 0) (5.0, 5.0, -5.0, 3.0) 1 +probe rgba (4, 0) (5.0, 5.0, -5.0, 3.0) +probe rgba (5, 0) (5.0, 5.0, 4294967300.0, 3.0) +probe rgba (6, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (7, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (8, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (9, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (10, 0) (5.0, 15.0, 10.0, -6.0) +probe rgba (11, 0) (1.0, 20.0, 3.0, 60.0) +probe rgba (12, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (13, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (14, 0) (5.0, 15.0, 10.0, 4294967300.0) +probe rgba (15, 0) (1.0, 20.0, 3.0, 60.0) +probe rgba (16, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (17, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (18, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (19, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (20, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (21, 0) (0.0, 1.0, 1.0, 1.0)
Some of these operations work with SM2-3, but not all of them. We don't currently have tests for anything other than 4.0, but ideally we'd like to compile all tests on all targets possible.
Not to mention that this is kind of a lot, and I'm not convinced that we won't want more tests for any given operation. If nothing else it'd be nice to split these into arithmetic, shift, logical, and bitwise tests.
On Tue, Aug 31, 2021 at 7:21 PM Zebediah Figura (she/her) zfigura@codeweavers.com wrote:
On 8/31/21 9:40 AM, Giovanni Mascellani wrote:
diff --git a/tests/hlsl-operations.shader_test b/tests/hlsl-operations.shader_test new file mode 100644 index 00000000..3c8036b5 --- /dev/null +++ b/tests/hlsl-operations.shader_test @@ -0,0 +1,86 @@ +[pixel shader] +float4 main(uniform float zero, uniform float one, uniform float x, uniform float y,
float4 pos : SV_POSITION) : SV_TARGET
+{
- int izero = zero;
- int ione = one;
- int ix = x;
- int iy = y;
- uint uzero = zero;
- uint uone = one;
- uint ux = x;
- uint uy = y;
- if (pos.x == 0.5)
return float4(x + y, x - y, x * y, x / y);
- if (pos.x == 1.5)
return float4(ix + iy, ix - iy, ix * iy, ix / iy);
- if (pos.x == 2.5)
return float4(ux + uy, ux - uy, ux * uy, ux / uy);
- if (pos.x == 3.5)
return float4(x % y, +x, -x, y / x);
- if (pos.x == 4.5)
return float4(ix % iy, +ix, -ix, iy / ix);
- if (pos.x == 5.5)
return float4(ux % uy, +ux, -ux, uy / ux);
- if (pos.x == 6.5)
return float4(x == y, x != y, x < y, x <= y);
- if (pos.x == 7.5)
return float4(x > y, x >= y, !x, !zero);
- if (pos.x == 8.5)
return float4(ix == iy, ix != iy, ix < iy, ix <= iy);
- if (pos.x == 9.5)
return float4(ix > iy, ix >= iy, !ix, !izero);
- if (pos.x == 10.5)
return float4(ix & iy, ix | iy, ix ^ iy, ~ix);
- if (pos.x == 11.5)
return float4(ix >> 2, ix << 2, iy >> 2, iy << 2);
- if (pos.x == 12.5)
return float4(ux == uy, ux != uy, ux < uy, ux <= uy);
- if (pos.x == 13.5)
return float4(ux > uy, ux >= uy, !ux, !uzero);
- if (pos.x == 14.5)
return float4(ux & uy, ux | uy, ux ^ uy, ~ux);
- if (pos.x == 15.5)
return float4(ux >> 2, ux << 2, uy >> 2, uy << 2);
- if (pos.x == 16.5)
return float4(zero && zero, zero && one, one && zero, one && one);
- if (pos.x == 17.5)
return float4(zero || zero, zero || one, one || zero, one || one);
- if (pos.x == 18.5)
return float4(izero && izero, izero && ione, ione && izero, ione && ione);
- if (pos.x == 19.5)
return float4(izero || izero, izero || ione, ione || izero, ione || ione);
- if (pos.x == 20.5)
return float4(uzero && uzero, uzero && uone, uone && uzero, uone && uone);
- if (pos.x == 21.5)
return float4(uzero || uzero, uzero || uone, uone || uzero, uone || uone);
- return float4(0.0, 0.0, 0.0, 0.0);
+}
+[test] +uniform 0 float4 0.0 1.0 5.0 15.0 +draw quad +probe rgba (0, 0) (20.0, -10.0, 75.0, 0.33333333) 1 +probe rgba (1, 0) (20.0, -10.0, 75.0, 0.0) +probe rgba (2, 0) (20.0, 4294967300.0, 75.0, 0.0) +probe rgba (3, 0) (5.0, 5.0, -5.0, 3.0) 1 +probe rgba (4, 0) (5.0, 5.0, -5.0, 3.0) +probe rgba (5, 0) (5.0, 5.0, 4294967300.0, 3.0) +probe rgba (6, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (7, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (8, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (9, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (10, 0) (5.0, 15.0, 10.0, -6.0) +probe rgba (11, 0) (1.0, 20.0, 3.0, 60.0) +probe rgba (12, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (13, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (14, 0) (5.0, 15.0, 10.0, 4294967300.0) +probe rgba (15, 0) (1.0, 20.0, 3.0, 60.0) +probe rgba (16, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (17, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (18, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (19, 0) (0.0, 1.0, 1.0, 1.0) +probe rgba (20, 0) (0.0, 0.0, 0.0, 1.0) +probe rgba (21, 0) (0.0, 1.0, 1.0, 1.0)
Some of these operations work with SM2-3, but not all of them. We don't currently have tests for anything other than 4.0, but ideally we'd like to compile all tests on all targets possible.
Not to mention that this is kind of a lot, and I'm not convinced that we won't want more tests for any given operation. If nothing else it'd be nice to split these into arithmetic, shift, logical, and bitwise tests.
Agreed. It just occurred to me that this kind of shader with a sequence of branches is a nightmare to generate in ps_2_0 (where there is no control flow at all). Also there's the issue with pixel coordinates being offset by 0.5 in d3d9 vs d3d11. And the general troubles with equality comparisons with floats. All in addition to the missing vpos in ps_2_0 mentioned by Zeb for patch 2/5. These concerns can all be worked around to some degree but also make the whole thing a bit brittle.
I think it would be nicer to rework these tests to split them up somewhat and avoid branches / conditionals as much as possible. The tests might calculate e.g. the sum of all the partial results and just output that for every pixels. Maybe add some comments to explain some intermediate results when not obvious at a glance.