[5/7] d3dx9/tests: Add tests for ID3DXConstantTable::SetValue.

Józef Kucia joseph.kucia at gmail.com
Thu Aug 16 10:21:21 CDT 2012


---
 dlls/d3dx9_36/tests/shader.c |  175 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 175 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx9_36/tests/shader.c b/dlls/d3dx9_36/tests/shader.c
index 22dc098..a371642 100644
--- a/dlls/d3dx9_36/tests/shader.c
+++ b/dlls/d3dx9_36/tests/shader.c
@@ -960,6 +960,180 @@ static void test_SetDefaults(IDirect3DDevice9 *device)
     ID3DXConstantTable_Release(ctable);
 }
 
+static void test_SetValue(IDirect3DDevice9 *device)
+{
+    static const D3DXMATRIX mvp = {{{
+        0.51f, 0.62f, 0.80f, 0.78f,
+        0.23f, 0.95f, 0.37f, 0.48f,
+        0.10f, 0.58f, 0.90f, 0.25f,
+        0.89f, 0.41f, 0.93f, 0.27f}}};
+    static const D3DXVECTOR4 f4 = {0.2f, 0.4f, 0.8f, 1.2f};
+    static const FLOAT arr[] = {0.33f, 0.55f, 0.96f, 1.00f,
+                                1.00f, 1.00f, 1.00f, 1.00f,
+                                1.00f, 1.00f, 1.00f, 1.00f};
+    static int imatrix[] = {1, 2, 3, 4, 5, 6};
+    static float fmatrix[] = {1.1f, 2.2f, 3.3f, 4.4f};
+    static BOOL barray[] = {TRUE, FALSE};
+    static float fvecarray[] = {9.1f, 9.2f, 9.3f, 9.4f, 9.5f, 9.6f, 9.7f, 9.8f};
+    static float farray[] = {2.2f, 3.3f};
+
+    static const float def[16] = {5.5f, 5.5f, 5.5f, 5.5f,
+                                  5.5f, 5.5f, 5.5f, 5.5f,
+                                  5.5f, 5.5f, 5.5f, 5.5f,
+                                  5.5f, 5.5f, 5.5f, 5.5f};
+    float out[16];
+
+    HRESULT res;
+    ID3DXConstantTable *ctable;
+
+    res = D3DXGetShaderConstantTable(ctab_basic, &ctable);
+    ok(res == D3D_OK, "D3DXGetShaderConstantTable failed: got %08x\n", res);
+
+    IDirect3DDevice9_SetVertexShaderConstantF(device, 7, def, 1);
+
+    /* SetValue called with 0 bytes size doesn't change value */
+    res = ID3DXConstantTable_SetValue(ctable, device, "f4", &f4, 0);
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 1);
+    ok(memcmp(out, def, sizeof(f4)) == 0,
+            "The variable f4 was not set correctly, out={%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[0], out[1], out[2], out[3], def[0], def[1], def[2], def[3]);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "f4", &f4, sizeof(f4));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 1);
+    ok(memcmp(out, &f4, sizeof(f4)) == 0,
+            "The variable f4 was not set correctly, out={%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[0], out[1], out[2], out[3], f4.x, f4.y, f4.z, f4.w);
+
+    IDirect3DDevice9_SetVertexShaderConstantF(device, 0, def, 4);
+
+    /* SetValue called with size smaller than constant size doesn't change value */
+    res = ID3DXConstantTable_SetValue(ctable, device, "mvp", &mvp, sizeof(mvp) / 2);
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue returned %08x\n", res);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 0, out, 4);
+    ok(memcmp(out, def, sizeof(def)) == 0,
+            "The variable mvp was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, "
+            "should be {%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}\n",
+            out[0], out[4], out[ 8], out[12],
+            out[1], out[5], out[ 9], out[13],
+            out[2], out[6], out[10], out[14],
+            out[3], out[7], out[11], out[15],
+            def[0], def[4], def[ 8], def[12],
+            def[1], def[5], def[ 9], def[13],
+            def[2], def[6], def[10], def[14],
+            def[3], def[7], def[11], def[15]);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "mvp", &mvp, sizeof(mvp));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 0, out, 4);
+    ok(out[0] == S(U(mvp))._11 && out[4] == S(U(mvp))._12 && out[8] == S(U(mvp))._13 && out[12] == S(U(mvp))._14,
+            "The first row of mvp was not set correctly, got {%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[0], out[4], out[8], out[12], S(U(mvp))._11, S(U(mvp))._12, S(U(mvp))._13, S(U(mvp))._14);
+    ok(out[1] == S(U(mvp))._21 && out[5] == S(U(mvp))._22 && out[9] == S(U(mvp))._23 && out[13] == S(U(mvp))._24,
+            "The second row of mvp was not set correctly, got {%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[1], out[5], out[9], out[13], S(U(mvp))._21, S(U(mvp))._22, S(U(mvp))._23, S(U(mvp))._24);
+    ok(out[2] == S(U(mvp))._31 && out[6] == S(U(mvp))._32 && out[10] == S(U(mvp))._33 && out[14] == S(U(mvp))._34,
+            "The third row of mvp was not set correctly, got {%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[2], out[6], out[10], out[14], S(U(mvp))._31, S(U(mvp))._32, S(U(mvp))._33, S(U(mvp))._34);
+    ok(out[3] == S(U(mvp))._41 && out[7] == S(U(mvp))._42 && out[11] == S(U(mvp))._43 && out[15] == S(U(mvp))._44,
+            "The fourth row of mvp was not set correctly, got {%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[3], out[7], out[11], out[15], S(U(mvp))._41, S(U(mvp))._42, S(U(mvp))._43, S(U(mvp))._44);
+
+    ID3DXConstantTable_Release(ctable);
+
+    res = D3DXGetShaderConstantTable(ctab_with_default_values, &ctable);
+    ok(res == D3D_OK, "D3DXGetShaderConstantTable failed: got %08x\n", res);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "arr", arr, sizeof(arr));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 8, out, 3);
+    ok(out[0] == arr[0] && out[4] == arr[1] && out[8] == arr[2]
+            && out[1] == 0 &&  out[2] == 0 && out[3] == 0 && out[5] == 0 && out[6] == 0 && out[7] == 0
+            && out[9] == 0 && out[10] == 0 && out[11] == 0,
+            "The variable arr was not set correctly, out={%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f}, "
+            "should be {0.33, 0, 0, 0, 0.55, 0, 0, 0, 0.96, 0, 0, 0}\n",
+            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], out[9], out[10], out[11]);
+
+    ID3DXConstantTable_Release(ctable);
+
+    res = D3DXGetShaderConstantTable(ctab_matrices, &ctable);
+    ok(res == D3D_OK, "D3DXGetShaderConstantTable failed: got %08x\n", res);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "fmatrix3x1", fmatrix, sizeof(fmatrix));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "imatrix2x3", imatrix, sizeof(imatrix));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 4, out, 2);
+    ok(out[0] == imatrix[0] && out[1] == imatrix[1] && out[2] == imatrix[2] && out[3] == 0.0f
+            && out[4] == imatrix[3] && out[5] == imatrix[4] && out[6] == imatrix[5] && out[7] == 0.0f,
+            "The variable imatrix2x3 was not set correctly, out={%f, %f, %f, %f, %f, %f, %f, %f}, "
+            "should be {%d, %d, %d, 0, %d, %d, %d, 0}\n",
+            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+            imatrix[0], imatrix[1], imatrix[2], imatrix[3], imatrix[4], imatrix[5]);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 2);
+    ok(out[0] == fmatrix[0] && out[1] == fmatrix[1] && out[2] == fmatrix[2] && out[3] == 0.0f,
+            "The variable fmatrix3x1 was not set correctly, out={%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
+            out[0], out[1] ,out[2], out[4],
+            fmatrix[0], fmatrix[1], fmatrix[2], 0.0f);
+
+    ID3DXConstantTable_Release(ctable);
+
+    res = D3DXGetShaderConstantTable(ctab_arrays, &ctable);
+    ok(res == D3D_OK, "D3DXGetShaderConstantTable failed: got %08x\n", res);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "barray", barray, sizeof(barray));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    res = ID3DXConstantTable_SetValue(ctable, device, "fvecarray", fvecarray, sizeof(fvecarray));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    IDirect3DDevice9_SetVertexShaderConstantF(device, 8, def, 4);
+    res = ID3DXConstantTable_SetValue(ctable, device, "farray", farray, sizeof(farray));
+    ok(res == D3D_OK, "ID3DXConstantTable_SetValue failed: got %08x\n", res);
+
+    /* 2 elements of farray were set */
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 8, out, 4);
+    ok(out[0] == farray[0] && out[1] == 0.0f && out[2] == 0.0f && out[3] == 0.0f
+            && out[4] == farray[1] && out[5] == 0.0f && out[6] == 0.0f && out[7] == 0.0f
+            && out[8] == def[8] && out[9] == def[9] && out[10] == def[10] && out[11] == def[11]
+            && out[12] == def[12] && out[13] == def[13] && out[14] == def[14] && out[15] == def[15],
+            "The variable farray was not set correctly, should be {%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, "
+            "should be {%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}\n",
+            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+            out[8], out[9], out[10], out[11], out[12], out[13], out[14], out[15],
+            farray[0], 0.0f, 0.0f, 0.0f,
+            farray[1], 0.0f, 0.0f, 0.0f,
+            def[8], def[9], def[10], def[11],
+            def[12], def[13], def[14], def[15]);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 12, out, 2);
+    ok(out[0] == fvecarray[0] && out[1] == fvecarray[1] && out[2] == fvecarray[2] && out[3] == fvecarray[3]
+            && out[4] == fvecarray[4] && out[5] == fvecarray[5] && out[6] == fvecarray[6] && out[7] == fvecarray[7],
+            "The variable fvecarray was not set correctly, out ={%f, %f, %f, %f, %f, %f, %f, %f}, "
+            "should be {%f, %f, %f, %f, %f, %f, %f, %f}\n",
+            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+            fvecarray[0], fvecarray[1], fvecarray[2], fvecarray[3], fvecarray[4], fvecarray[5], fvecarray[6], fvecarray[7]);
+
+    IDirect3DDevice9_GetVertexShaderConstantF(device, 14, out, 2);
+    ok(out[0] == 1.0f && out[1] == 0.0f && out[2] == 0.0f && out[3] == 0.0f
+            && out[4] == 0.0f && out[5] == 0.0f && out[6] == 0.0f && out[7] == 0.0f,
+            "The variable barray was not set correctly, out={%f, %f, %f, %f, %f, %f, %f, %f}, "
+            "should be {%f, %f, %f, %f, %f, %f, %f, %f}\n",
+            out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
+            1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
+
+    ID3DXConstantTable_Release(ctable);
+}
+
 static void test_setting_constants(void)
 {
     HWND wnd;
@@ -1000,6 +1174,7 @@ static void test_setting_constants(void)
     test_setting_matrices_table(device);
     test_setting_arrays_table(device);
     test_SetDefaults(device);
+    test_SetValue(device);
 
     /* Release resources */
     refcnt = IDirect3DDevice9_Release(device);
-- 
1.7.8.6




More information about the wine-patches mailing list