wined3d: Use a single allocation for timestamp queries.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
51c7df4f37
commit
654e960e34
|
@ -47,6 +47,11 @@ static struct wined3d_occlusion_query *wined3d_occlusion_query_from_query(struct
|
|||
return CONTAINING_RECORD(query, struct wined3d_occlusion_query, query);
|
||||
}
|
||||
|
||||
static struct wined3d_timestamp_query *wined3d_timestamp_query_from_query(struct wined3d_query *query)
|
||||
{
|
||||
return CONTAINING_RECORD(query, struct wined3d_timestamp_query, query);
|
||||
}
|
||||
|
||||
BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info)
|
||||
{
|
||||
return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
|
||||
|
@ -279,11 +284,12 @@ static void wined3d_query_destroy_object(void *object)
|
|||
}
|
||||
else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP)
|
||||
{
|
||||
struct wined3d_timestamp_query *tq = query->extendedData;
|
||||
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
|
||||
|
||||
if (tq->context)
|
||||
context_free_timestamp_query(tq);
|
||||
HeapFree(GetProcessHeap(), 0, query->extendedData);
|
||||
HeapFree(GetProcessHeap(), 0, tq);
|
||||
return;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, query);
|
||||
|
@ -552,7 +558,7 @@ static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DW
|
|||
static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query,
|
||||
void *data, DWORD size, DWORD flags)
|
||||
{
|
||||
struct wined3d_timestamp_query *tq = query->extendedData;
|
||||
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
|
||||
struct wined3d_device *device = query->device;
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
struct wined3d_context *context;
|
||||
|
@ -611,7 +617,7 @@ static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query,
|
|||
|
||||
static HRESULT wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
|
||||
{
|
||||
struct wined3d_timestamp_query *tq = query->extendedData;
|
||||
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
|
||||
struct wined3d_device *device = query->device;
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
struct wined3d_context *context;
|
||||
|
@ -744,6 +750,31 @@ static const struct wined3d_query_ops timestamp_query_ops =
|
|||
wined3d_timestamp_query_ops_issue,
|
||||
};
|
||||
|
||||
static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device,
|
||||
enum wined3d_query_type type, void *parent, struct wined3d_query **query)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
struct wined3d_timestamp_query *object;
|
||||
|
||||
TRACE("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
|
||||
|
||||
if (!gl_info->supported[ARB_TIMER_QUERY])
|
||||
{
|
||||
WARN("Unsupported in local OpenGL implementation: ARB_TIMER_QUERY.\n");
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
}
|
||||
|
||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
wined3d_query_init(&object->query, device, type, sizeof(UINT64), ×tamp_query_ops, parent);
|
||||
|
||||
TRACE("Created query %p.\n", object);
|
||||
*query = &object->query;
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
static const struct wined3d_query_ops timestamp_disjoint_query_ops =
|
||||
{
|
||||
wined3d_timestamp_disjoint_query_ops_get_data,
|
||||
|
@ -759,24 +790,6 @@ static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *de
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case WINED3D_QUERY_TYPE_TIMESTAMP:
|
||||
TRACE("Timestamp query.\n");
|
||||
if (!gl_info->supported[ARB_TIMER_QUERY])
|
||||
{
|
||||
WARN("Unsupported in local OpenGL implementation: ARB_TIMER_QUERY.\n");
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
}
|
||||
query->query_ops = ×tamp_query_ops;
|
||||
query->data_size = sizeof(UINT64);
|
||||
query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_timestamp_query));
|
||||
if (!query->extendedData)
|
||||
{
|
||||
ERR("Failed to allocate timestamp query extended data.\n");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
((struct wined3d_timestamp_query *)query->extendedData)->context = NULL;
|
||||
break;
|
||||
|
||||
case WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT:
|
||||
case WINED3D_QUERY_TYPE_TIMESTAMP_FREQ:
|
||||
TRACE("TIMESTAMP_DISJOINT query.\n");
|
||||
|
@ -788,7 +801,6 @@ static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *de
|
|||
query->query_ops = ×tamp_disjoint_query_ops;
|
||||
query->data_size = type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT
|
||||
? sizeof(struct wined3d_query_data_timestamp_disjoint) : sizeof(UINT64);
|
||||
query->extendedData = NULL;
|
||||
break;
|
||||
|
||||
case WINED3D_QUERY_TYPE_VCACHE:
|
||||
|
@ -829,6 +841,9 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device,
|
|||
case WINED3D_QUERY_TYPE_OCCLUSION:
|
||||
return wined3d_occlusion_query_create(device, type, parent, query);
|
||||
|
||||
case WINED3D_QUERY_TYPE_TIMESTAMP:
|
||||
return wined3d_timestamp_query_create(device, type, parent, query);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1393,8 +1393,6 @@ struct wined3d_query
|
|||
enum wined3d_query_type type;
|
||||
DWORD data_size;
|
||||
const struct wined3d_query_ops *query_ops;
|
||||
|
||||
void *extendedData;
|
||||
};
|
||||
|
||||
union wined3d_gl_query_object
|
||||
|
@ -1438,6 +1436,8 @@ struct wined3d_occlusion_query
|
|||
|
||||
struct wined3d_timestamp_query
|
||||
{
|
||||
struct wined3d_query query;
|
||||
|
||||
struct list entry;
|
||||
GLuint id;
|
||||
struct wined3d_context *context;
|
||||
|
|
Loading…
Reference in New Issue