d3d11: Implement d3d11_device_CreatePredicate().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2015-10-27 03:02:30 +01:00 committed by Alexandre Julliard
parent d86ee74b80
commit e958d49b06
3 changed files with 62 additions and 31 deletions

View File

@ -304,20 +304,20 @@ struct d3d_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface)
}
HRESULT d3d_query_init(struct d3d_query *query, struct d3d_device *device,
const D3D10_QUERY_DESC *desc, BOOL predicate)
const D3D11_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,
/* D3D11_QUERY_EVENT */ WINED3D_QUERY_TYPE_EVENT,
/* D3D11_QUERY_OCCLUSION */ WINED3D_QUERY_TYPE_OCCLUSION,
/* D3D11_QUERY_TIMESTAMP */ WINED3D_QUERY_TYPE_TIMESTAMP,
/* D3D11_QUERY_TIMESTAMP_DISJOINT */ WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT,
/* D3D11_QUERY_PIPELINE_STATISTICS */ WINED3D_QUERY_TYPE_PIPELINE_STATISTICS,
/* D3D11_QUERY_OCCLUSION_PREDICATE */ WINED3D_QUERY_TYPE_OCCLUSION,
/* D3D11_QUERY_SO_STATISTICS */ WINED3D_QUERY_TYPE_SO_STATISTICS,
/* D3D11_QUERY_SO_OVERFLOW_PREDICATE */ WINED3D_QUERY_TYPE_SO_OVERFLOW,
};
if (desc->Query >= sizeof(query_type_map) / sizeof(*query_type_map))
@ -351,3 +351,40 @@ HRESULT d3d_query_init(struct d3d_query *query, struct d3d_device *device,
return S_OK;
}
HRESULT d3d_query_create(struct d3d_device *device, const D3D11_QUERY_DESC *desc, BOOL predicate,
struct d3d_query **query)
{
struct d3d_query *object;
HRESULT hr;
if (!desc)
return E_INVALIDARG;
if (predicate
&& desc->Query != D3D11_QUERY_OCCLUSION_PREDICATE
&& desc->Query != D3D11_QUERY_SO_OVERFLOW_PREDICATE
&& desc->Query != D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0
&& desc->Query != D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1
&& desc->Query != D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2
&& desc->Query != D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3)
{
WARN("Query type %u 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 = d3d_query_init(object, device, desc, predicate)))
{
WARN("Failed to initialize predicate, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created predicate %p.\n", object);
*query = object;
return S_OK;
}

View File

@ -364,7 +364,9 @@ struct d3d_query
};
HRESULT d3d_query_init(struct d3d_query *query, struct d3d_device *device,
const D3D10_QUERY_DESC *desc, BOOL predicate) DECLSPEC_HIDDEN;
const D3D11_QUERY_DESC *desc, BOOL predicate) DECLSPEC_HIDDEN;
HRESULT d3d_query_create(struct d3d_device *device, const D3D11_QUERY_DESC *desc, BOOL predicate,
struct d3d_query **query) DECLSPEC_HIDDEN;
struct d3d_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface) DECLSPEC_HIDDEN;
/* ID3D11DeviceContext - immediate context */

View File

@ -1593,9 +1593,18 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc,
ID3D11Predicate **predicate)
{
FIXME("iface %p, desc %p, predicate %p stub!\n", iface, desc, predicate);
struct d3d_device *device = impl_from_ID3D11Device(iface);
struct d3d_query *object;
HRESULT hr;
return E_NOTIMPL;
TRACE("iface %p, desc %p, predicate %p.\n", iface, desc, predicate);
if (FAILED(hr = d3d_query_create(device, desc, TRUE, &object)))
return hr;
*predicate = (ID3D11Predicate *)&object->ID3D11Query_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc,
@ -3720,7 +3729,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d_query_init(object, device, desc, FALSE)))
if (FAILED(hr = d3d_query_init(object, device, (const D3D11_QUERY_DESC *)desc, FALSE)))
{
WARN("Failed to initialize query, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
@ -3742,26 +3751,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePredicate(ID3D10Device1 *ifa
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 = d3d_query_init(object, device, desc, TRUE)))
{
WARN("Failed to initialize predicate, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
if (FAILED(hr = d3d_query_create(device, (const D3D11_QUERY_DESC *)desc, TRUE, &object)))
return hr;
}
TRACE("Created predicate %p.\n", object);
*predicate = (ID3D10Predicate *)&object->ID3D10Query_iface;
return S_OK;