From 7b84e3234b5b079c04374e3a2070ef84e9f4efb7 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 30 May 2013 22:34:16 +0200 Subject: [PATCH] d3d10core: Implement d3d10_device_CreatePredicate(). --- dlls/d3d10core/async.c | 8 ++++++-- dlls/d3d10core/d3d10core_private.h | 4 +++- dlls/d3d10core/device.c | 32 ++++++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/dlls/d3d10core/async.c b/dlls/d3d10core/async.c index 3f869a51c8b..d5de9a9410c 100644 --- a/dlls/d3d10core/async.c +++ b/dlls/d3d10core/async.c @@ -33,9 +33,12 @@ static inline struct d3d10_query *impl_from_ID3D10Query(ID3D10Query *iface) static HRESULT STDMETHODCALLTYPE d3d10_query_QueryInterface(ID3D10Query *iface, REFIID riid, void **object) { + struct d3d10_query *query = impl_from_ID3D10Query(iface); + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); - if (IsEqualGUID(riid, &IID_ID3D10Query) + if ((IsEqualGUID(riid, &IID_ID3D10Predicate) && query->predicate) + || IsEqualGUID(riid, &IID_ID3D10Query) || IsEqualGUID(riid, &IID_ID3D10Asynchronous) || IsEqualGUID(riid, &IID_ID3D10DeviceChild) || IsEqualGUID(riid, &IID_IUnknown)) @@ -162,10 +165,11 @@ static const struct ID3D10QueryVtbl d3d10_query_vtbl = d3d10_query_GetDesc, }; -HRESULT d3d10_query_init(struct d3d10_query *query) +HRESULT d3d10_query_init(struct d3d10_query *query, BOOL predicate) { query->ID3D10Query_iface.lpVtbl = &d3d10_query_vtbl; query->refcount = 1; + query->predicate = predicate; return S_OK; } diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index a859642a945..9916d631ba8 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -278,9 +278,11 @@ struct d3d10_query { ID3D10Query ID3D10Query_iface; LONG refcount; + + BOOL predicate; }; -HRESULT d3d10_query_init(struct d3d10_query *query) DECLSPEC_HIDDEN; +HRESULT d3d10_query_init(struct d3d10_query *query, BOOL predicate) DECLSPEC_HIDDEN; /* IDirect3D10Device */ struct d3d10_device diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index f7b906d0f94..0e7fc9596e4 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -1532,8 +1532,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface, if (!object) return E_OUTOFMEMORY; - hr = d3d10_query_init(object); - if (FAILED(hr)) + if (FAILED(hr = d3d10_query_init(object, FALSE))) { WARN("Failed to initialize query, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); @@ -1549,9 +1548,34 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device *iface, static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device *iface, const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate) { - FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate); + struct d3d10_query *object; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate); + + if (!desc) + return E_INVALIDARG; + + if (desc->Query != D3D10_QUERY_OCCLUSION_PREDICATE && desc->Query != D3D10_QUERY_SO_OVERFLOW_PREDICATE) + { + WARN("Query type %#x is not a predicate.\n", desc->Query); + return E_INVALIDARG; + } + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + if (FAILED(hr = d3d10_query_init(object, TRUE))) + { + WARN("Failed to initialize predicate, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created predicate %p.\n", object); + *predicate = (ID3D10Predicate *)&object->ID3D10Query_iface; + + return S_OK; } static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device *iface, -- 2.11.4.GIT