Commit be20ddc3 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Introduce query operation to destroy queries.

parent 0a923d52
......@@ -187,7 +187,8 @@ static void buffer_destroy_buffer_object(struct wined3d_buffer *buffer, struct w
if (buffer->query)
{
wined3d_event_query_destroy(buffer->query);
struct wined3d_query *query = &buffer->query->query;
query->query_ops->query_destroy(query);
buffer->query = NULL;
}
buffer->flags &= ~WINED3D_BUFFER_APPLESYNC;
......@@ -827,7 +828,7 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
return;
}
if(!This->query)
if (!This->query)
{
TRACE("Creating event query for buffer %p\n", This);
......@@ -850,7 +851,7 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
}
TRACE("Synchronizing buffer %p\n", This);
ret = wined3d_event_query_finish(This->query, This->resource.device);
switch(ret)
switch (ret)
{
case WINED3D_EVENT_QUERY_NOT_STARTED:
case WINED3D_EVENT_QUERY_OK:
......@@ -867,9 +868,10 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
}
drop_query:
if(This->query)
if (This->query)
{
wined3d_event_query_destroy(This->query);
struct wined3d_query *query = &This->query->query;
query->query_ops->query_destroy(query);
This->query = NULL;
}
......
......@@ -66,12 +66,6 @@ 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];
}
void wined3d_event_query_destroy(struct wined3d_event_query *query)
{
if (query->context) context_free_event_query(query);
HeapFree(GetProcessHeap(), 0, query);
}
static enum wined3d_event_query_result wined3d_event_query_test(const struct wined3d_event_query *query,
const struct wined3d_device *device, DWORD flags)
{
......@@ -274,45 +268,7 @@ static void wined3d_query_destroy_object(void *object)
* deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this
* context, and (still) leaking the actual query. */
if (query->type == WINED3D_QUERY_TYPE_EVENT)
{
wined3d_event_query_destroy(wined3d_event_query_from_query(query));
}
else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION)
{
struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
if (oq->context)
context_free_occlusion_query(oq);
HeapFree(GetProcessHeap(), 0, oq);
}
else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP)
{
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
if (tq->context)
context_free_timestamp_query(tq);
HeapFree(GetProcessHeap(), 0, tq);
}
else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT
|| query->type == WINED3D_QUERY_TYPE_TIMESTAMP_FREQ)
{
HeapFree(GetProcessHeap(), 0, query);
}
else if (query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0
|| query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM1
|| query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM2
|| query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3)
{
struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
if (pq->context)
context_free_so_statistics_query(pq);
HeapFree(GetProcessHeap(), 0, pq);
}
else
{
ERR("Query %p has invalid type %#x.\n", query, query->type);
}
query->query_ops->query_destroy(query);
}
ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
......@@ -773,10 +729,20 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
return poll;
}
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
if (event_query->context)
context_free_event_query(event_query);
HeapFree(GetProcessHeap(), 0, event_query);
}
static const struct wined3d_query_ops event_query_ops =
{
wined3d_event_query_ops_poll,
wined3d_event_query_ops_issue,
wined3d_event_query_ops_destroy,
};
static HRESULT wined3d_event_query_create(struct wined3d_device *device,
......@@ -807,10 +773,20 @@ static HRESULT wined3d_event_query_create(struct wined3d_device *device,
return WINED3D_OK;
}
static void wined3d_occlusion_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
if (oq->context)
context_free_occlusion_query(oq);
HeapFree(GetProcessHeap(), 0, oq);
}
static const struct wined3d_query_ops occlusion_query_ops =
{
wined3d_occlusion_query_ops_poll,
wined3d_occlusion_query_ops_issue,
wined3d_occlusion_query_ops_destroy,
};
static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device,
......@@ -841,10 +817,20 @@ static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device,
return WINED3D_OK;
}
static void wined3d_timestamp_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
if (tq->context)
context_free_timestamp_query(tq);
HeapFree(GetProcessHeap(), 0, tq);
}
static const struct wined3d_query_ops timestamp_query_ops =
{
wined3d_timestamp_query_ops_poll,
wined3d_timestamp_query_ops_issue,
wined3d_timestamp_query_ops_destroy,
};
static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device,
......@@ -875,10 +861,16 @@ static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device,
return WINED3D_OK;
}
static void wined3d_timestamp_disjoint_query_ops_destroy(struct wined3d_query *query)
{
HeapFree(GetProcessHeap(), 0, query);
}
static const struct wined3d_query_ops timestamp_disjoint_query_ops =
{
wined3d_timestamp_disjoint_query_ops_poll,
wined3d_timestamp_disjoint_query_ops_issue,
wined3d_timestamp_disjoint_query_ops_destroy,
};
static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *device,
......@@ -921,10 +913,20 @@ static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *de
return WINED3D_OK;
}
static void wined3d_so_statistics_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
if (pq->context)
context_free_so_statistics_query(pq);
HeapFree(GetProcessHeap(), 0, pq);
}
static const struct wined3d_query_ops so_statistics_query_ops =
{
wined3d_so_statistics_query_ops_poll,
wined3d_so_statistics_query_ops_issue,
wined3d_so_statistics_query_ops_destroy,
};
static HRESULT wined3d_so_statistics_query_create(struct wined3d_device *device,
......
......@@ -1621,6 +1621,7 @@ struct wined3d_query_ops
{
BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
void (*query_destroy)(struct wined3d_query *query);
};
struct wined3d_query
......@@ -1665,7 +1666,6 @@ enum wined3d_event_query_result
WINED3D_EVENT_QUERY_ERROR
};
void wined3d_event_query_destroy(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
enum wined3d_event_query_result wined3d_event_query_finish(const struct wined3d_event_query *query,
const struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_event_query_issue(struct wined3d_event_query *query, const struct wined3d_device *device) DECLSPEC_HIDDEN;
......
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