From 686546b6d3d07902f6159f49f69a28b315c92054 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 19 Sep 2014 10:41:45 +0200 Subject: [PATCH] d3d10core: Create wined3d queries for queries. --- dlls/d3d10core/async.c | 34 +++++++++++++++++++++++++++++- dlls/d3d10core/d3d10core_private.h | 4 +++- dlls/d3d10core/device.c | 4 ++-- dlls/d3d10core/tests/device.c | 5 +++-- include/wine/wined3d.h | 3 +++ 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/dlls/d3d10core/async.c b/dlls/d3d10core/async.c index 6d3442baf80..f41369bd2c0 100644 --- a/dlls/d3d10core/async.c +++ b/dlls/d3d10core/async.c @@ -171,10 +171,42 @@ static const struct ID3D10QueryVtbl d3d10_query_vtbl = d3d10_query_GetDesc, }; -HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device, BOOL predicate) +HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device, + const D3D10_QUERY_DESC *desc, BOOL predicate) { + HRESULT hr; + + static const enum wined3d_query_type query_type_map[] = + { + /* D3D10_QUERY_EVENT */ WINED3D_QUERY_TYPE_EVENT, + /* D3D10_QUERY_OCCLUSION */ WINED3D_QUERY_TYPE_OCCLUSION, + /* D3D10_QUERY_TIMESTAMP */ WINED3D_QUERY_TYPE_TIMESTAMP, + /* D3D10_QUERY_TIMESTAMP_DISJOINT */ WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT, + /* D3D10_QUERY_PIPELINE_STATISTICS */ WINED3D_QUERY_TYPE_PIPELINE_STATISTICS, + /* D3D10_QUERY_OCCLUSION_PREDICATE */ WINED3D_QUERY_TYPE_OCCLUSION, + /* D3D10_QUERY_SO_STATISTICS */ WINED3D_QUERY_TYPE_SO_STATISTICS, + /* D3D10_QUERY_SO_OVERFLOW_PREDICATE */ WINED3D_QUERY_TYPE_SO_OVERFLOW, + }; + + if (desc->Query > sizeof(query_type_map) / sizeof(*query_type_map)) + { + FIXME("Unhandled query type %#x.\n", desc->Query); + return E_INVALIDARG; + } + + if (desc->MiscFlags) + FIXME("Ignoring MiscFlags %#x.\n", desc->MiscFlags); + query->ID3D10Query_iface.lpVtbl = &d3d10_query_vtbl; query->refcount = 1; + + if (FAILED(hr = wined3d_query_create(device->wined3d_device, + query_type_map[desc->Query], &query->wined3d_query))) + { + WARN("Failed to create wined3d query, hr %#x.\n", hr); + return hr; + } + query->predicate = predicate; query->device = &device->ID3D10Device1_iface; ID3D10Device1_AddRef(query->device); diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 0e0fdfd5dc1..0891ae095a8 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -297,11 +297,13 @@ struct d3d10_query ID3D10Query ID3D10Query_iface; LONG refcount; + struct wined3d_query *wined3d_query; BOOL predicate; ID3D10Device1 *device; }; -HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device, BOOL predicate) DECLSPEC_HIDDEN; +HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device, + const D3D10_QUERY_DESC *desc, BOOL predicate) DECLSPEC_HIDDEN; /* IDirect3D10Device1 */ struct d3d10_device diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 5bdb8afef7b..a5d806afb3b 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -1722,7 +1722,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface, if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; - if (FAILED(hr = d3d10_query_init(object, device, FALSE))) + if (FAILED(hr = d3d10_query_init(object, device, desc, FALSE))) { WARN("Failed to initialize query, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); @@ -1756,7 +1756,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *ifa if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; - if (FAILED(hr = d3d10_query_init(object, device, TRUE))) + if (FAILED(hr = d3d10_query_init(object, device, desc, TRUE))) { WARN("Failed to initialize predicate, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 67398fa8945..4b3a3254111 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -961,8 +961,9 @@ static void test_create_predicate(void) query_desc.Query = D3D10_QUERY_SO_OVERFLOW_PREDICATE; hr = ID3D10Device_CreatePredicate(device, &query_desc, &predicate); - ok(SUCCEEDED(hr), "Failed to create predicate, hr %#x.\n", hr); - ID3D10Predicate_Release(predicate); + todo_wine ok(SUCCEEDED(hr), "Failed to create predicate, hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D10Predicate_Release(predicate); refcount = ID3D10Device_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 741e503b67a..fdbd65b611a 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -694,6 +694,9 @@ enum wined3d_pool enum wined3d_query_type { + WINED3D_QUERY_TYPE_PIPELINE_STATISTICS = 1, + WINED3D_QUERY_TYPE_SO_STATISTICS = 2, + WINED3D_QUERY_TYPE_SO_OVERFLOW = 3, WINED3D_QUERY_TYPE_VCACHE = 4, WINED3D_QUERY_TYPE_RESOURCE_MANAGER = 5, WINED3D_QUERY_TYPE_VERTEX_STATS = 6,