Henri Verbeet : d3d10core: Implement d3d10_query_GetDevice().
Alexandre Julliard
julliard at winehq.org
Mon Feb 17 13:45:15 CST 2014
Module: wine
Branch: master
Commit: f38b36ee33c693cfa3dec3d0ec70d0a6f14105f0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f38b36ee33c693cfa3dec3d0ec70d0a6f14105f0
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Feb 17 11:24:33 2014 +0100
d3d10core: Implement d3d10_query_GetDevice().
---
dlls/d3d10core/async.c | 12 ++++++++++--
dlls/d3d10core/d3d10core_private.h | 3 ++-
dlls/d3d10core/device.c | 9 +++++----
dlls/d3d10core/tests/device.c | 14 ++++++++++++--
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d10core/async.c b/dlls/d3d10core/async.c
index d5de9a9..6d3442b 100644
--- a/dlls/d3d10core/async.c
+++ b/dlls/d3d10core/async.c
@@ -73,6 +73,7 @@ static ULONG STDMETHODCALLTYPE d3d10_query_Release(ID3D10Query *iface)
if (!refcount)
{
+ ID3D10Device1_Release(This->device);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -83,7 +84,12 @@ static ULONG STDMETHODCALLTYPE d3d10_query_Release(ID3D10Query *iface)
static void STDMETHODCALLTYPE d3d10_query_GetDevice(ID3D10Query *iface, ID3D10Device **device)
{
- FIXME("iface %p, device %p stub!\n", iface, device);
+ struct d3d10_query *query = impl_from_ID3D10Query(iface);
+
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (ID3D10Device *)query->device;
+ ID3D10Device_AddRef(*device);
}
static HRESULT STDMETHODCALLTYPE d3d10_query_GetPrivateData(ID3D10Query *iface,
@@ -165,11 +171,13 @@ static const struct ID3D10QueryVtbl d3d10_query_vtbl =
d3d10_query_GetDesc,
};
-HRESULT d3d10_query_init(struct d3d10_query *query, BOOL predicate)
+HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device, BOOL predicate)
{
query->ID3D10Query_iface.lpVtbl = &d3d10_query_vtbl;
query->refcount = 1;
query->predicate = predicate;
+ query->device = &device->ID3D10Device1_iface;
+ ID3D10Device1_AddRef(query->device);
return S_OK;
}
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index f08dc65..9241312 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -289,9 +289,10 @@ struct d3d10_query
LONG refcount;
BOOL predicate;
+ ID3D10Device1 *device;
};
-HRESULT d3d10_query_init(struct d3d10_query *query, BOOL predicate) DECLSPEC_HIDDEN;
+HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device, BOOL predicate) DECLSPEC_HIDDEN;
/* IDirect3D10Device1 */
struct d3d10_device
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 0bd9883..1aa5e8b 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -1527,16 +1527,16 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
const D3D10_QUERY_DESC *desc, ID3D10Query **query)
{
+ struct d3d10_device *device = impl_from_ID3D10Device(iface);
struct d3d10_query *object;
HRESULT hr;
TRACE("iface %p, desc %p, query %p.\n", iface, desc, query);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = d3d10_query_init(object, FALSE)))
+ if (FAILED(hr = d3d10_query_init(object, device, FALSE)))
{
WARN("Failed to initialize query, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
@@ -1552,6 +1552,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *iface,
const D3D10_QUERY_DESC *desc, ID3D10Predicate **predicate)
{
+ struct d3d10_device *device = impl_from_ID3D10Device(iface);
struct d3d10_query *object;
HRESULT hr;
@@ -1569,7 +1570,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, TRUE)))
+ if (FAILED(hr = d3d10_query_init(object, device, 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 48fc3f6..8fb62a0 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -836,10 +836,10 @@ static void test_create_rasterizer_state(void)
static void test_create_predicate(void)
{
+ ULONG refcount, expected_refcount;
D3D10_QUERY_DESC query_desc;
ID3D10Predicate *predicate;
- ID3D10Device *device;
- ULONG refcount;
+ ID3D10Device *device, *tmp;
HRESULT hr;
if (!(device = create_device()))
@@ -857,8 +857,18 @@ static void test_create_predicate(void)
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
query_desc.Query = D3D10_QUERY_OCCLUSION_PREDICATE;
+ expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device_CreatePredicate(device, &query_desc, &predicate);
ok(SUCCEEDED(hr), "Failed to create predicate, hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)device);
+ ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
+ tmp = NULL;
+ expected_refcount = refcount + 1;
+ ID3D10Predicate_GetDevice(predicate, &tmp);
+ ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
+ refcount = get_refcount((IUnknown *)device);
+ ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+ ID3D10Device_Release(tmp);
ID3D10Predicate_Release(predicate);
query_desc.Query = D3D10_QUERY_SO_OVERFLOW_PREDICATE;
More information about the wine-cvs
mailing list