[v2 5/6] d3dx9/tests: Factor out vertex shader constants check helper function from test_effect_preshader().

Paul Gofman gofmanp at gmail.com
Tue Mar 14 07:47:00 CDT 2017


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
v2:
    - represented constants update flags as hexadecimal bitmasks instead of booleans.
---
 dlls/d3dx9_36/tests/effect.c | 166 ++++++++++++++++++++++++++++---------------
 1 file changed, 108 insertions(+), 58 deletions(-)

diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index 66fab7d..4fcffc4 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -4016,45 +4016,111 @@ static void test_effect_preshader_op_results_(unsigned int line, IDirect3DDevice
     }
 }
 
-static void test_effect_preshader(IDirect3DDevice9 *device)
+static const D3DXVECTOR4 fvect_empty = {-9999.0f, -9999.0f, -9999.0f, -9999.0f};
+
+static void test_effect_preshader_clear_vconsts(IDirect3DDevice9 *device)
 {
-    static const D3DXVECTOR4 test_effect_preshader_fconstsv[] =
+    unsigned int i;
+    HRESULT hr;
+
+    for (i = 0; i < 256; ++i)
     {
-        {0.0f,   0.0f,  0.0f,  0.0f},
-        {0.0f,   0.0f,  0.0f,  0.0f},
-        {0.0f,   0.0f,  0.0f,  0.0f},
-        {1.0f,   2.0f,  3.0f,  0.0f},
-        {4.0f,   0.0f,  0.0f,  0.0f},
-        {5.0f,   6.0f,  7.0f,  8.0f},
-        {1.0f,   2.0f,  3.0f,  0.0f},
-        {4.0f,   0.0f,  0.0f,  0.0f},
-        {5.0f,   6.0f,  7.0f,  8.0f},
-        {9.0f,  10.0f, 11.0f,  0.0f},
-        {12.0f,  0.0f,  0.0f,  0.0f},
-        {13.0f, 14.0f, 15.0f, 16.0f},
-        {11.0f, 12.0f, 13.0f,  0.0f},
-        {21.0f, 22.0f, 23.0f,  0.0f},
-        {31.0f, 32.0f, 33.0f,  0.0f},
-        {41.0f, 42.0f, 43.0f,  0.0f},
-        {11.0f, 21.0f, 31.0f,  0.0f},
-        {12.0f, 22.0f, 32.0f,  0.0f},
-        {13.0f, 23.0f, 33.0f,  0.0f},
-        {14.0f, 24.0f, 34.0f,  0.0f},
-        {11.0f, 12.0f, 13.0f, 14.0f},
-        {21.0f, 22.0f, 23.0f, 24.0f},
-        {31.0f, 32.0f, 33.0f, 34.0f},
-        {11.0f, 21.0f, 31.0f, 41.0f},
-        {12.0f, 22.0f, 32.0f, 42.0f},
-        {13.0f, 23.0f, 33.0f, 43.0f},
-        {9.0f,  10.0f, 11.0f,  0.0f},
-        {12.0f,  0.0f,  0.0f,  0.0f},
-        {13.0f, 14.0f, 15.0f, 16.0f},
-        {92.0f,  0.0f,  0.0f,  0.0f},
-        {93.0f,  0.0f,  0.0f,  0.0f},
-        {0.0f,   0.0f,  0.0f,  0.0f},
-        {91.0f,  0.0f,  0.0f,  0.0f},
-        {4.0f,   5.0f,  6.0f,  7.0f},
-    };
+        hr = IDirect3DDevice9_SetVertexShaderConstantF(device, i, &fvect_empty.x, 1);
+        ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    }
+}
+
+static const D3DXVECTOR4 test_effect_preshader_fconstsv[] =
+{
+    {0.0f,   0.0f,  0.0f,  0.0f},
+    {0.0f,   0.0f,  0.0f,  0.0f},
+    {0.0f,   0.0f,  0.0f,  0.0f},
+    {1.0f,   2.0f,  3.0f,  0.0f},
+    {4.0f,   0.0f,  0.0f,  0.0f},
+    {5.0f,   6.0f,  7.0f,  8.0f},
+    {1.0f,   2.0f,  3.0f,  0.0f},
+    {4.0f,   0.0f,  0.0f,  0.0f},
+    {5.0f,   6.0f,  7.0f,  8.0f},
+    {9.0f,  10.0f, 11.0f,  0.0f},
+    {12.0f,  0.0f,  0.0f,  0.0f},
+    {13.0f, 14.0f, 15.0f, 16.0f},
+    {11.0f, 12.0f, 13.0f,  0.0f},
+    {21.0f, 22.0f, 23.0f,  0.0f},
+    {31.0f, 32.0f, 33.0f,  0.0f},
+    {41.0f, 42.0f, 43.0f,  0.0f},
+    {11.0f, 21.0f, 31.0f,  0.0f},
+    {12.0f, 22.0f, 32.0f,  0.0f},
+    {13.0f, 23.0f, 33.0f,  0.0f},
+    {14.0f, 24.0f, 34.0f,  0.0f},
+    {11.0f, 12.0f, 13.0f, 14.0f},
+    {21.0f, 22.0f, 23.0f, 24.0f},
+    {31.0f, 32.0f, 33.0f, 34.0f},
+    {11.0f, 21.0f, 31.0f, 41.0f},
+    {12.0f, 22.0f, 32.0f, 42.0f},
+    {13.0f, 23.0f, 33.0f, 43.0f},
+    {9.0f,  10.0f, 11.0f,  0.0f},
+    {12.0f,  0.0f,  0.0f,  0.0f},
+    {13.0f, 14.0f, 15.0f, 16.0f},
+    {92.0f,  0.0f,  0.0f,  0.0f},
+    {93.0f,  0.0f,  0.0f,  0.0f},
+    {0.0f,   0.0f,  0.0f,  0.0f},
+    {91.0f,  0.0f,  0.0f,  0.0f},
+    {4.0f,   5.0f,  6.0f,  7.0f},
+};
+#define TEST_EFFECT_PRES_NFLOATV ARRAY_SIZE(test_effect_preshader_fconstsv)
+#define TEST_EFFECT_FLOATV_BITMASK_BLOCK_SIZE (sizeof(unsigned int) * 8)
+
+#define test_effect_preshader_compare_vconsts(a, b, c) \
+        test_effect_preshader_compare_vconsts_(__LINE__, a, b, c)
+static void test_effect_preshader_compare_vconsts_(unsigned int line, IDirect3DDevice9 *device,
+        const unsigned int *const_updated_mask, const char *updated_param)
+{
+    HRESULT hr;
+    unsigned int i;
+    D3DXVECTOR4 fdata[TEST_EFFECT_PRES_NFLOATV];
+
+    hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, &fdata[0].x, TEST_EFFECT_PRES_NFLOATV);
+    ok_(__FILE__, line)(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    if (!const_updated_mask)
+    {
+        ok_(__FILE__, line)(!memcmp(fdata, test_effect_preshader_fconstsv, sizeof(test_effect_preshader_fconstsv)),
+                "Vertex shader float constants do not match.\n");
+    }
+    else
+    {
+        for (i = 0; i < TEST_EFFECT_PRES_NFLOATV; ++i)
+        {
+            if (const_updated_mask[i / TEST_EFFECT_FLOATV_BITMASK_BLOCK_SIZE]
+                    & (1 << (i % TEST_EFFECT_FLOATV_BITMASK_BLOCK_SIZE)))
+            {
+                ok_(__FILE__, line)(!memcmp(&fdata[i], &test_effect_preshader_fconstsv[i], sizeof(fdata[i])),
+                        "Vertex shader float constants do not match, expected (%g, %g, %g, %g), \
+got (%g, %g, %g, %g), parameter %s.\n",
+                        test_effect_preshader_fconstsv[i].x, test_effect_preshader_fconstsv[i].y,
+                        test_effect_preshader_fconstsv[i].z, test_effect_preshader_fconstsv[i].w,
+                        fdata[i].x, fdata[i].y, fdata[i].z, fdata[i].w, updated_param);
+            }
+            else
+            {
+                ok_(__FILE__, line)(!memcmp(&fdata[i], &fvect_empty, sizeof(fdata[i])),
+                        "Vertex shader float constants updated unexpectedly, parameter %s.\n", updated_param);
+            }
+        }
+    }
+
+    for (i = TEST_EFFECT_PRES_NFLOATV; i < 256; ++i)
+    {
+        hr = IDirect3DDevice9_GetVertexShaderConstantF(device, i, &fdata[0].x, 1);
+        ok_(__FILE__, line)(hr == D3D_OK, "Got result %#x.\n", hr);
+        ok_(__FILE__, line)(!memcmp(fdata, &fvect_empty, sizeof(fvect_empty)),
+                "Vertex shader float constants do not match.\n");
+    }
+
+}
+
+static void test_effect_preshader(IDirect3DDevice9 *device)
+{
     static const D3DXVECTOR4 test_effect_preshader_fconstsp[] =
     {
         {11.0f, 21.0f,  0.0f, 0.0f},
@@ -4080,16 +4146,12 @@ static void test_effect_preshader(IDirect3DDevice9 *device)
     {
         {4, 3, 2, 1}
     };
-#define TEST_EFFECT_PRES_NFLOATV ARRAY_SIZE(test_effect_preshader_fconstsv)
 #define TEST_EFFECT_PRES_NFLOATP ARRAY_SIZE(test_effect_preshader_fconstsp)
-#define TEST_EFFECT_PRES_NFLOATMAX (TEST_EFFECT_PRES_NFLOATV > TEST_EFFECT_PRES_NFLOATP ? \
-            TEST_EFFECT_PRES_NFLOATV : TEST_EFFECT_PRES_NFLOATP)
 #define TEST_EFFECT_PRES_NBOOL ARRAY_SIZE(test_effect_preshader_bconsts)
 #define TEST_EFFECT_PRES_NINT ARRAY_SIZE(test_effect_preshader_iconsts)
 
     static const D3DXVECTOR4 fvect1 = {28.0f, 29.0f, 30.0f, 31.0f};
     static const D3DXVECTOR4 fvect2 = {0.0f, 0.0f, 1.0f, 0.0f};
-    static const D3DXVECTOR4 fvect_empty = {-9999.0f, -9999.0f, -9999.0f, -9999.0f};
     static const int ivect_empty[4] = {-1, -1, -1, -1};
     HRESULT hr;
     ID3DXEffect *effect;
@@ -4097,7 +4159,7 @@ static void test_effect_preshader(IDirect3DDevice9 *device)
     unsigned int npasses;
     DWORD value;
     BOOL bval;
-    D3DXVECTOR4 fdata[TEST_EFFECT_PRES_NFLOATMAX];
+    D3DXVECTOR4 fdata[TEST_EFFECT_PRES_NFLOATP];
     int idata[TEST_EFFECT_PRES_NINT][4];
     BOOL bdata[TEST_EFFECT_PRES_NBOOL];
     IDirect3DVertexShader9 *vshader;
@@ -4117,11 +4179,8 @@ static void test_effect_preshader(IDirect3DDevice9 *device)
             NULL, NULL, 0, NULL, &effect, NULL);
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
 
-    for (i = 0; i < 256; ++i)
-    {
-        hr = IDirect3DDevice9_SetVertexShaderConstantF(device, i, &fvect_empty.x, 1);
-        ok(hr == D3D_OK, "Got result %#x.\n", hr);
-    }
+    test_effect_preshader_clear_vconsts(device);
+
     for (i = 0; i < 224; ++i)
     {
         hr = IDirect3DDevice9_SetPixelShaderConstantF(device, i, &fvect_empty.x, 1);
@@ -4157,17 +4216,8 @@ static void test_effect_preshader(IDirect3DDevice9 *device)
     hr = effect->lpVtbl->BeginPass(effect, 1);
     ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
 
-    hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, &fdata[0].x, TEST_EFFECT_PRES_NFLOATV);
-    ok(hr == D3D_OK, "Got result %#x.\n", hr);
-    ok(!memcmp(fdata, test_effect_preshader_fconstsv, sizeof(test_effect_preshader_fconstsv)),
-            "Vertex shader float constants do not match.\n");
-    for (i = TEST_EFFECT_PRES_NFLOATV; i < 256; ++i)
-    {
-        hr = IDirect3DDevice9_GetVertexShaderConstantF(device, i, &fdata[0].x, 1);
-        ok(hr == D3D_OK, "Got result %#x.\n", hr);
-        ok(!memcmp(fdata, &fvect_empty, sizeof(fvect_empty)),
-                "Vertex shader float constants do not match.\n");
-    }
+    test_effect_preshader_compare_vconsts(device, NULL, NULL);
+
     hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, &fdata[0].x, TEST_EFFECT_PRES_NFLOATP);
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
     ok(!memcmp(fdata, test_effect_preshader_fconstsp, sizeof(test_effect_preshader_fconstsp)),
-- 
2.9.3




More information about the wine-patches mailing list