[PATCH 1/6] d3d9/tests: Test GetData behavior with various size values.

Matteo Bruni mbruni at codeweavers.com
Thu May 1 11:37:36 CDT 2014


---
 dlls/d3d9/tests/device.c | 72 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 60 insertions(+), 12 deletions(-)

diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 4dd7a6a..f695cc2 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3782,7 +3782,8 @@ static void test_occlusion_query_states(void)
     ULONG refcount;
     HWND window;
     HRESULT hr;
-    BYTE *data;
+    DWORD data;
+    UINT64 data64;
 
     window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
             0, 0, 640, 480, 0, 0, 0, 0);
@@ -3808,11 +3809,11 @@ static void test_occlusion_query_states(void)
     }
 
     data_size = IDirect3DQuery9_GetDataSize(query);
-    data = HeapAlloc(GetProcessHeap(), 0, data_size);
+    ok(data_size == sizeof(DWORD), "Unexpected data size %u.\n", data_size);
 
     hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    hr = IDirect3DQuery9_GetData(query, data, data_size, D3DGETDATA_FLUSH);
+    hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
@@ -3822,13 +3823,13 @@ static void test_occlusion_query_states(void)
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
-    *((DWORD *)data) = 0x12345678;
+    data = 0x12345678;
     hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH);
     ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    hr = IDirect3DQuery9_GetData(query, data, data_size, D3DGETDATA_FLUSH);
+    hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
     ok(hr == S_FALSE || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
     if (hr == D3D_OK)
-        ok(!*(DWORD *)data, "Got unexpected query result %u.\n", *(DWORD *)data);
+        ok(!data, "Got unexpected query result %u.\n", data);
 
     hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
     ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
@@ -3849,10 +3850,41 @@ static void test_occlusion_query_states(void)
     }
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
 
-    hr = IDirect3DQuery9_GetData(query, data, data_size, D3DGETDATA_FLUSH);
+    memset(&data, 0xff, sizeof(data));
+    hr = IDirect3DQuery9_GetData(query, &data, sizeof(WORD), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    hr = IDirect3DQuery9_GetData(query, data, data_size, D3DGETDATA_FLUSH);
+    ok(*(WORD *)&data == 1, "Occlusion query returned an unexpected result (0x%.8x).\n", data);
+    todo_wine ok(*((WORD *)&data + 1) == 0xffff,
+            "data was modified outside of the expected size (0x%.8x).\n", data);
+    hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(data == 1, "Occlusion query returned an unexpected result (0x%.8x).\n", data);
+
+    memset(&data64, 0xf0, sizeof(data64));
+    hr = IDirect3DQuery9_GetData(query, &data64, sizeof(data64), D3DGETDATA_FLUSH);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(*(DWORD *)&data64 == 1, "Occlusion query returned an unexpected result (0x%.8x).\n",
+            *(DWORD *)&data64);
+    /* Different drivers seem to return different data in those high bytes on Windows, but they all
+       write something there and the extra data is consistent (I've seen 0x00000000 and 0xdddddddd
+       on AMD and Nvidia respectively). */
+    if (0)
+    {
+        ok(*((DWORD *)&data64 + 1) != 0xf0f0f0f0, "high bytes of data64 were not modified (0x%.8x).\n",
+                *((DWORD *)&data64 + 1));
+    }
+
+    memset(&data, 0xff, sizeof(data));
+    hr = IDirect3DQuery9_GetData(query, &data, 0, D3DGETDATA_FLUSH);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(data == 0xffffffff, "Occlusion query returned an unexpected result (0x%.8x).\n", data);
+
+    /* This crashes on Windows. */
+    if (0)
+    {
+        hr = IDirect3DQuery9_GetData(query, NULL, data_size, D3DGETDATA_FLUSH);
+        ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    }
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -3861,7 +3893,6 @@ static void test_occlusion_query_states(void)
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
-    HeapFree(GetProcessHeap(), 0, data);
     IDirect3DQuery9_Release(query);
     refcount = IDirect3DDevice9_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
@@ -3926,8 +3957,16 @@ static void test_timestamp_query(void)
         Sleep(10);
     }
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    memset(&freq, 0xff, sizeof(freq));
+    hr = IDirect3DQuery9_GetData(freq_query, &freq, sizeof(DWORD), D3DGETDATA_FLUSH);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(*((DWORD *)&freq + 1) == 0xffffffff,
+            "freq was modified outside of the expected size (0x%.8x).\n", *((DWORD *)&freq + 1));
     hr = IDirect3DQuery9_GetData(freq_query, &freq, sizeof(freq), D3DGETDATA_FLUSH);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(*((DWORD *)&freq + 1) != 0xffffffff, "high bytes of freq were not modified (0x%.8x).\n",
+            *((DWORD *)&freq + 1));
 
     hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -3963,10 +4002,12 @@ static void test_timestamp_query(void)
     }
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
 
-    hr = IDirect3DQuery9_GetData(query, &timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    hr = IDirect3DQuery9_GetData(query, &timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
+    memset(&timestamp, 0xff, sizeof(timestamp));
+    hr = IDirect3DQuery9_GetData(query, &timestamp, sizeof(DWORD), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(*((DWORD *)&timestamp + 1) == 0xffffffff,
+            "timestamp was modified outside of the expected size (0x%.8x).\n",
+            *((DWORD *)&timestamp + 1));
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_BEGIN);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -3984,8 +4025,15 @@ static void test_timestamp_query(void)
         Sleep(10);
     }
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+    memset(&disjoint, 0xff, sizeof(disjoint));
+    hr = IDirect3DQuery9_GetData(disjoint_query, &disjoint, sizeof(WORD), D3DGETDATA_FLUSH);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(*((WORD *)&disjoint + 1) == 0xffff,
+            "disjoint was modified outside of the expected size (0x%.8x).\n", disjoint);
     hr = IDirect3DQuery9_GetData(disjoint_query, &disjoint, sizeof(disjoint), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(*((WORD *)&disjoint + 1) != 0xffff, "high bytes of disjoint were not modified (0x%.8x).\n", disjoint);
 
     /* It's not strictly necessary for the TIMESTAMP query to be inside
      * a TIMESTAMP_DISJOINT query. */
-- 
1.8.3.2




More information about the wine-patches mailing list