Commit f38b36ee authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Implement d3d10_query_GetDevice().

parent 569a2e75
......@@ -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;
}
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment