[PATCH 5/5] d3dcompiler_43/tests: Added trigonometric function tests to HLSL test suite

Travis Athougies iammisc at gmail.com
Fri Nov 12 14:08:56 CST 2010


Changed test format to reuse pre-existing testing framework.

---
 dlls/d3dcompiler_43/tests/hlsl.c |  116 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dcompiler_43/tests/hlsl.c b/dlls/d3dcompiler_43/tests/hlsl.c
index 33fbca7..ba5fc31 100644
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ b/dlls/d3dcompiler_43/tests/hlsl.c
@@ -495,6 +495,121 @@ static void test_float_vectors(IDirect3DDevice9 *device, IDirect3DVertexBuffer9
     }
 }
 
+static void test_trig(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
+        IDirect3DVertexShader9 *vshader_passthru)
+{
+    static struct hlsl_probe_info sin_probes[] =
+    {
+        {0, 0, {0.5000f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {1, 0, {0.5975f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {2, 0, {0.6913f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {3, 0, {0.7778f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {4, 0, {0.8536f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {5, 0, {0.9157f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {6, 0, {0.9620f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {7, 0, {0.9904f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {8, 0, {1.0000f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {9, 0, {0.9904f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {10, 0, {0.9619f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {11, 0, {0.9157f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {12, 0, {0.8536f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {13, 0, {0.7778f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {14, 0, {0.6913f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {15, 0, {0.5975f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {16, 0, {0.5000f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {17, 0, {0.4025f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {18, 0, {0.3087f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {19, 0, {0.2222f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {20, 0, {0.1464f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {21, 0, {0.0843f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {22, 0, {0.0381f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {23, 0, {0.0096f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {24, 0, {0.0000f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {25, 0, {0.0096f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {26, 0, {0.0381f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {27, 0, {0.0843f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {28, 0, {0.1464f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {29, 0, {0.2222f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {30, 0, {0.3087f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+        {31, 0, {0.4025f, 0.0f, 0.0f, 0.0f}, 0.001f, "sin test failed"},
+    };
+
+    static const char *sin_shader =
+        "float4 test(float x: TEXCOORD0): COLOR    \
+         {                                         \
+            const float pi2 = 6.2831853;           \
+            float calcd = (sin(x * pi2) + 1)/2;    \
+            return float4(calcd, 0, 0, 0);         \
+         }";
+
+    static struct hlsl_probe_info cos_probes[] =
+    {
+        {0, 0, {1.0000f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {1, 0, {0.9904f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {2, 0, {0.9620f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {3, 0, {0.9160f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {4, 0, {0.8536f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {5, 0, {0.7778f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {6, 0, {0.6913f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {7, 0, {0.5975f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {8, 0, {0.5000f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {9, 0, {0.4025f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {10, 0, {0.3087f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {11, 0, {0.2222f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {12, 0, {0.1464f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {13, 0, {0.0843f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {14, 0, {0.0381f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {15, 0, {0.0096f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {16, 0, {0.0000f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {17, 0, {0.0096f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {18, 0, {0.0381f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {19, 0, {0.0843f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {20, 0, {0.1464f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {21, 0, {0.2222f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {22, 0, {0.3087f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {23, 0, {0.4025f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {24, 0, {0.5000f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {25, 0, {0.5975f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {26, 0, {0.6913f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {27, 0, {0.7778f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {28, 0, {0.8536f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {29, 0, {0.9157f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {30, 0, {0.9619f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+        {31, 0, {0.9904f, 0.0f, 0.0f, 0.0f}, 0.001f, "cos test failed"},
+    };
+
+    static const char *cos_shader =
+        "float4 test(float x: TEXCOORD0): COLOR    \
+        {                                          \
+            const float pi2 = 6.2831853;           \
+            float calcd = (cos(x * pi2) + 1)/2;    \
+            return float4(calcd, 0, 0, 0);         \
+        }";
+
+    ID3DXConstantTable *constants;
+    IDirect3DPixelShader9 *pshader;
+
+    pshader = compile_pixel_shader9(device, sin_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
+                sin_probes, 32, 32, 1, __LINE__);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+
+    pshader = compile_pixel_shader9(device, cos_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
+                cos_probes, 32, 32, 1, __LINE__);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+}
+
 START_TEST(hlsl)
 {
     D3DCAPS9 caps;
@@ -518,6 +633,7 @@ START_TEST(hlsl)
             test_math(device, quad_geometry, vshader_passthru);
             test_conditionals(device, quad_geometry, vshader_passthru);
             test_float_vectors(device, quad_geometry, vshader_passthru);
+            test_trig(device, quad_geometry, vshader_passthru);
         }
     } else skip("no pixel shader support\n");
 
-- 
1.7.0.4




More information about the wine-patches mailing list