[PATCH 6/9] d3d9: Fix query result data for not started queries.

Józef Kucia jkucia at codeweavers.com
Fri Feb 3 07:08:47 CST 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/d3d9/query.c        | 11 ++++++++++-
 dlls/d3d9/tests/device.c | 16 ++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/dlls/d3d9/query.c b/dlls/d3d9/query.c
index ba66058..e4f84c3 100644
--- a/dlls/d3d9/query.c
+++ b/dlls/d3d9/query.c
@@ -159,7 +159,8 @@ static HRESULT WINAPI d3d9_query_GetData(IDirect3DQuery9 *iface, void *data, DWO
             size = sizeof(data_disjoint.disjoint);
 
         hr = wined3d_query_get_data(query->wined3d_query, &data_disjoint, sizeof(data_disjoint), flags);
-        memcpy(data, &data_disjoint.disjoint, size);
+        if (SUCCEEDED(hr))
+            memcpy(data, &data_disjoint.disjoint, size);
     }
     else
     {
@@ -168,7 +169,15 @@ static HRESULT WINAPI d3d9_query_GetData(IDirect3DQuery9 *iface, void *data, DWO
     wined3d_mutex_unlock();
 
     if (hr == D3DERR_INVALIDCALL)
+    {
+        if (data)
+        {
+            DWORD data_size = d3d9_query_GetDataSize(iface);
+            memset(data, 0, size);
+            memset(data, 0xdd, min(size, data_size));
+        }
         return S_OK;
+    }
     return hr;
 }
 
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 28bc2ec..e776515 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -5598,7 +5598,7 @@ static void test_occlusion_query(void)
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    todo_wine ok(data.dword[0] == 0xdddddddd && data.dword[1] == 0xffffffff,
+    ok(data.dword[0] == 0xdddddddd && data.dword[1] == 0xffffffff,
             "Got unexpected query result 0x%08x%08x.\n", data.dword[1], data.dword[0]);
 
     hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
@@ -5810,7 +5810,7 @@ static void test_timestamp_query(void)
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDirect3DQuery9_GetData(freq_query, freq, sizeof(DWORD), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    todo_wine ok(freq[0] == 0xdddddddd && freq[1] == 0xffffffff,
+    ok(freq[0] == 0xdddddddd && freq[1] == 0xffffffff,
             "Got unexpected query result 0x%08x%08x.\n", freq[1], freq[0]);
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_TIMESTAMPDISJOINT, &disjoint_query);
@@ -5823,12 +5823,12 @@ static void test_timestamp_query(void)
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDirect3DQuery9_GetData(disjoint_query, &disjoint, sizeof(WORD), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    todo_wine ok(disjoint[0] == 0xdddd && disjoint[1] == 0xffff,
-            "Got unexpected query result 0x%08x%08x.\n", disjoint[1], disjoint[0]);
+    ok(disjoint[0] == 0xdddd && disjoint[1] == 0xffff,
+            "Got unexpected query result 0x%04x%04x.\n", disjoint[1], disjoint[0]);
     hr = IDirect3DQuery9_GetData(disjoint_query, &disjoint, sizeof(DWORD), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    todo_wine ok(disjoint[0] == 0xdddd && disjoint[1] == 0xdddd,
-            "Got unexpected query result 0x%08x%08x.\n", disjoint[1], disjoint[0]);
+    ok(disjoint[0] == 0xdddd && disjoint[1] == 0xdddd,
+            "Got unexpected query result 0x%04x%04x.\n", disjoint[1], disjoint[0]);
 
     hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_TIMESTAMP, &query);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -5860,11 +5860,11 @@ static void test_timestamp_query(void)
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(DWORD), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    todo_wine ok(timestamp[0] == 0xdddddddd && timestamp[1] == 0xffffffff,
+    ok(timestamp[0] == 0xdddddddd && timestamp[1] == 0xffffffff,
             "Got unexpected query result 0x%08x%08x.\n", timestamp[1], timestamp[0]);
     hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-    todo_wine ok(timestamp[0] == 0xdddddddd && timestamp[1] == 0xdddddddd,
+    ok(timestamp[0] == 0xdddddddd && timestamp[1] == 0xdddddddd,
             "Got unexpected query result 0x%08x%08x.\n", timestamp[1], timestamp[0]);
 
     hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_END);
-- 
2.10.2




More information about the wine-patches mailing list