[PATCH vkd3d v2 4/5] tests: Try to avoid using SV_Position from shaders which can be tested with SM1.

Zebediah Figura zfigura at codeweavers.com
Thu Apr 7 18:58:16 CDT 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
v2: Instead of using uniforms, change to using texcoord.

In order to avoid depending on pixel-exact rendering (and in order to work
around different pixel centers for d3d9), don't validate pixels near a border
(for conditional and hlsl-for), and quantize the input (for trigonometry).
Thanks to Henri Verbeet for the latter idea.

 tests/conditional.shader_test           | 16 +++++++----
 tests/hlsl-for.shader_test              | 18 ++++++++-----
 tests/hlsl-struct-semantics.shader_test | 35 ++++++++++++++++++++-----
 tests/trigonometry.shader_test          | 15 ++++++++---
 4 files changed, 63 insertions(+), 21 deletions(-)

diff --git a/tests/conditional.shader_test b/tests/conditional.shader_test
index 1a1b8fee5..e665ac1d2 100644
--- a/tests/conditional.shader_test
+++ b/tests/conditional.shader_test
@@ -1,7 +1,13 @@
-[pixel shader]
-float4 main(float4 pos : SV_POSITION) : SV_TARGET
+[vertex shader]
+void main(out float tex : texcoord, inout float4 pos : sv_position)
 {
-    if(pos.x > 200.0)
+    tex = pos.x;
+}
+
+[pixel shader]
+float4 main(float tex : texcoord) : SV_TARGET
+{
+    if (tex > 0.0)
         return float4(0.1, 0.2, 0.3, 0.4);
     else
         return float4(0.9, 0.8, 0.7, 0.6);
@@ -9,5 +15,5 @@ float4 main(float4 pos : SV_POSITION) : SV_TARGET
 
 [test]
 draw quad
-probe rect rgba (0, 0, 200, 480) (0.9, 0.8, 0.7, 0.6)
-probe rect rgba (200, 0, 640, 480) (0.1, 0.2, 0.3, 0.4)
+probe rect rgba (  0, 0, 319, 480) (0.9, 0.8, 0.7, 0.6)
+probe rect rgba (321, 0, 640, 480) (0.1, 0.2, 0.3, 0.4)
diff --git a/tests/hlsl-for.shader_test b/tests/hlsl-for.shader_test
index b133ce996..4e91ce412 100644
--- a/tests/hlsl-for.shader_test
+++ b/tests/hlsl-for.shader_test
@@ -1,14 +1,20 @@
+[vertex shader]
+void main(out float tex : texcoord, inout float4 pos : sv_position)
+{
+    tex = pos.x;
+}
+
 [pixel shader]
-float4 main(float4 pos : SV_POSITION) : SV_TARGET
+float4 main(float tex : texcoord) : sv_target
 {
     int i;
     float x = 0.0;
     for (i = 0; i < 10; i++)
     {
         x += i;
-        if (pos.x == 1.5 && i == 5)
+        if (tex > 0.5 && i == 5)
             break;
-        if (pos.x == 2.5 && i >= 7)
+        if (tex > -0.5 && i >= 7)
             continue;
         x -= 1;
     }
@@ -17,6 +23,6 @@ float4 main(float4 pos : SV_POSITION) : SV_TARGET
 
 [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)
+probe rect rgba (  0, 0, 159, 480) (10.0, 35.0, 0.0, 0.0)
+probe rect rgba (161, 0, 479, 480) (10.0, 38.0, 0.0, 0.0)
+probe rect rgba (481, 0, 640, 480) ( 5.0, 10.0, 0.0, 0.0)
diff --git a/tests/hlsl-struct-semantics.shader_test b/tests/hlsl-struct-semantics.shader_test
index b623a998c..43b07bb86 100644
--- a/tests/hlsl-struct-semantics.shader_test
+++ b/tests/hlsl-struct-semantics.shader_test
@@ -1,9 +1,34 @@
+[input layout]
+0 r32g32b32a32 float texcoord
+0 r32g32 float sv_position
+
+[vertex buffer 0]
+0.0 1.0 0.0 1.0   -2.0 -2.0
+0.0 1.0 0.0 1.0   -2.0  2.0
+0.0 1.0 0.0 1.0    2.0 -2.0
+0.0 1.0 0.0 1.0    2.0  2.0
+
+[vertex shader]
+
+struct vertex
+{
+    struct
+    {
+        float4 texcoord : texcoord;
+        float4 pos : sv_position;
+    } m;
+};
+
+void main(inout struct vertex v)
+{
+}
+
 [pixel shader]
 struct input
 {
     struct
     {
-        float4 pos : sv_position;
+        float4 texcoord : texcoord;
     } m;
 };
 
@@ -18,12 +43,10 @@ struct output
 struct output main(struct input i)
 {
     struct output o;
-    o.m.color = i.m.pos;
+    o.m.color = i.m.texcoord;
     return o;
 }
 
 [test]
-draw quad
-probe rgba (0, 1) (0.5, 1.5, 0.0, 1.0)
-probe rgba (1, 0) (1.5, 0.5, 0.0, 1.0)
-probe rgba (3, 5) (3.5, 5.5, 0.0, 1.0)
+draw triangle strip 4
+probe all rgba (0.0, 1.0, 0.0, 1.0)
diff --git a/tests/trigonometry.shader_test b/tests/trigonometry.shader_test
index 07a280a02..cf53d7a12 100644
--- a/tests/trigonometry.shader_test
+++ b/tests/trigonometry.shader_test
@@ -1,7 +1,14 @@
-[pixel shader]
-float4 main(float4 pos : SV_POSITION) : SV_TARGET
+[vertex shader]
+void main(out float tex : texcoord, inout float4 pos : sv_position)
 {
-    return float4(sin(pos.x - 0.5), cos(pos.x - 0.5), 0, 0);
+    tex = (pos.x + 1) * 320;
+}
+
+[pixel shader]
+float4 main(float tex : texcoord) : sv_target
+{
+    tex = floor(tex + 0.25);
+    return float4(sin(tex), cos(tex), 0, 0);
 }
 
 [test]
@@ -17,7 +24,7 @@ probe rgba ( 7, 0) ( 0.65698660,  0.75390225, 0.0, 0.0) 1024
 probe rgba ( 8, 0) ( 0.98935825, -0.14550003, 0.0, 0.0) 1024
 probe rgba ( 9, 0) ( 0.41211849, -0.91113026, 0.0, 0.0) 1024
 probe rgba (10, 0) (-0.54402111, -0.83907153, 0.0, 0.0) 1024
-probe rgba (11, 0) (-0.99999021,  0.00442570, 0.0, 0.0) 1024
+probe rgba (11, 0) (-0.99999021,  0.00442570, 0.0, 0.0) 2048
 probe rgba (12, 0) (-0.53657292,  0.84385396, 0.0, 0.0) 1024
 probe rgba (13, 0) ( 0.42016704,  0.90744678, 0.0, 0.0) 1024
 probe rgba (14, 0) ( 0.99060736,  0.13673722, 0.0, 0.0) 1024
-- 
2.35.1




More information about the wine-devel mailing list