Commit 1174c894 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Make the adapter responsible for query creation and destruction.

parent 5356292e
...@@ -5069,6 +5069,42 @@ static void adapter_gl_destroy_sampler(struct wined3d_sampler *sampler) ...@@ -5069,6 +5069,42 @@ static void adapter_gl_destroy_sampler(struct wined3d_sampler *sampler)
wined3d_cs_destroy_object(sampler->device->cs, wined3d_sampler_gl_destroy_object, sampler_gl); wined3d_cs_destroy_object(sampler->device->cs, wined3d_sampler_gl_destroy_object, sampler_gl);
} }
static HRESULT adapter_gl_create_query(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
device, type, parent, parent_ops, query);
return wined3d_query_gl_create(device, type, parent, parent_ops, query);
}
static void wined3d_query_gl_destroy_object(void *object)
{
struct wined3d_query *query = object;
if (query->buffer_object)
{
struct wined3d_context *context;
context = context_acquire(query->device, NULL, 0);
wined3d_query_gl_destroy_buffer_object(wined3d_context_gl(context), query);
context_release(context);
}
/* Queries are specific to the GL context that created them. Not
* 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. */
query->query_ops->query_destroy(query);
}
static void adapter_gl_destroy_query(struct wined3d_query *query)
{
TRACE("query %p.\n", query);
wined3d_cs_destroy_object(query->device->cs, wined3d_query_gl_destroy_object, query);
}
static const struct wined3d_adapter_ops wined3d_adapter_gl_ops = static const struct wined3d_adapter_ops wined3d_adapter_gl_ops =
{ {
adapter_gl_destroy, adapter_gl_destroy,
...@@ -5094,6 +5130,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_gl_ops = ...@@ -5094,6 +5130,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_gl_ops =
adapter_gl_destroy_unordered_access_view, adapter_gl_destroy_unordered_access_view,
adapter_gl_create_sampler, adapter_gl_create_sampler,
adapter_gl_destroy_sampler, adapter_gl_destroy_sampler,
adapter_gl_create_query,
adapter_gl_destroy_query,
}; };
static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl, static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl,
......
...@@ -759,6 +759,20 @@ static void adapter_vk_destroy_sampler(struct wined3d_sampler *sampler) ...@@ -759,6 +759,20 @@ static void adapter_vk_destroy_sampler(struct wined3d_sampler *sampler)
wined3d_cs_destroy_object(sampler->device->cs, heap_free, sampler); wined3d_cs_destroy_object(sampler->device->cs, heap_free, sampler);
} }
static HRESULT adapter_vk_create_query(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
device, type, parent, parent_ops, query);
return WINED3DERR_NOTAVAILABLE;
}
static void adapter_vk_destroy_query(struct wined3d_query *query)
{
TRACE("query %p.\n", query);
}
static const struct wined3d_adapter_ops wined3d_adapter_vk_ops = static const struct wined3d_adapter_ops wined3d_adapter_vk_ops =
{ {
adapter_vk_destroy, adapter_vk_destroy,
...@@ -784,6 +798,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_vk_ops = ...@@ -784,6 +798,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_vk_ops =
adapter_vk_destroy_unordered_access_view, adapter_vk_destroy_unordered_access_view,
adapter_vk_create_sampler, adapter_vk_create_sampler,
adapter_vk_destroy_sampler, adapter_vk_destroy_sampler,
adapter_vk_create_query,
adapter_vk_destroy_query,
}; };
static unsigned int wined3d_get_wine_vk_version(void) static unsigned int wined3d_get_wine_vk_version(void)
......
...@@ -2568,6 +2568,20 @@ static void adapter_no3d_destroy_sampler(struct wined3d_sampler *sampler) ...@@ -2568,6 +2568,20 @@ static void adapter_no3d_destroy_sampler(struct wined3d_sampler *sampler)
TRACE("sampler %p.\n", sampler); TRACE("sampler %p.\n", sampler);
} }
static HRESULT adapter_no3d_create_query(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
device, type, parent, parent_ops, query);
return WINED3DERR_NOTAVAILABLE;
}
static void adapter_no3d_destroy_query(struct wined3d_query *query)
{
TRACE("query %p.\n", query);
}
static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops = static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
{ {
adapter_no3d_destroy, adapter_no3d_destroy,
...@@ -2593,6 +2607,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops = ...@@ -2593,6 +2607,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
adapter_no3d_destroy_unordered_access_view, adapter_no3d_destroy_unordered_access_view,
adapter_no3d_create_sampler, adapter_no3d_create_sampler,
adapter_no3d_destroy_sampler, adapter_no3d_destroy_sampler,
adapter_no3d_create_query,
adapter_no3d_destroy_query,
}; };
static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter *adapter, unsigned int wined3d_creation_flags) static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter *adapter, unsigned int wined3d_creation_flags)
......
...@@ -54,7 +54,7 @@ static void wined3d_query_create_buffer_object(struct wined3d_context_gl *contex ...@@ -54,7 +54,7 @@ static void wined3d_query_create_buffer_object(struct wined3d_context_gl *contex
query->buffer_object = buffer_object; query->buffer_object = buffer_object;
} }
static void wined3d_query_destroy_buffer_object(struct wined3d_context_gl *context_gl, struct wined3d_query *query) void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl, struct wined3d_query *query)
{ {
const struct wined3d_gl_info *gl_info = context_gl->gl_info; const struct wined3d_gl_info *gl_info = context_gl->gl_info;
...@@ -93,7 +93,7 @@ static BOOL wined3d_query_buffer_queue_result(struct wined3d_context_gl *context ...@@ -93,7 +93,7 @@ static BOOL wined3d_query_buffer_queue_result(struct wined3d_context_gl *context
if (wined3d_query_buffer_is_valid(query)) if (wined3d_query_buffer_is_valid(query))
wined3d_query_buffer_invalidate(query); wined3d_query_buffer_invalidate(query);
else else
wined3d_query_destroy_buffer_object(context_gl, query); wined3d_query_gl_destroy_buffer_object(context_gl, query);
} }
if (!query->buffer_object) if (!query->buffer_object)
...@@ -430,21 +430,6 @@ static void wined3d_query_destroy_object(void *object) ...@@ -430,21 +430,6 @@ static void wined3d_query_destroy_object(void *object)
if (!list_empty(&query->poll_list_entry)) if (!list_empty(&query->poll_list_entry))
list_remove(&query->poll_list_entry); list_remove(&query->poll_list_entry);
if (query->buffer_object)
{
struct wined3d_context *context;
context = context_acquire(query->device, NULL, 0);
wined3d_query_destroy_buffer_object(wined3d_context_gl(context), query);
context_release(context);
}
/* Queries are specific to the GL context that created them. Not
* 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. */
query->query_ops->query_destroy(query);
} }
ULONG CDECL wined3d_query_decref(struct wined3d_query *query) ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
...@@ -455,8 +440,11 @@ ULONG CDECL wined3d_query_decref(struct wined3d_query *query) ...@@ -455,8 +440,11 @@ ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
if (!refcount) if (!refcount)
{ {
struct wined3d_device *device = query->device;
query->parent_ops->wined3d_object_destroyed(query->parent); query->parent_ops->wined3d_object_destroyed(query->parent);
wined3d_cs_destroy_object(query->device->cs, wined3d_query_destroy_object, query); wined3d_cs_destroy_object(device->cs, wined3d_query_destroy_object, query);
device->adapter->adapter_ops->adapter_destroy_query(query);
} }
return refcount; return refcount;
...@@ -1332,7 +1320,7 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device, ...@@ -1332,7 +1320,7 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type, HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{ {
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n", TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
...@@ -1368,3 +1356,12 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q ...@@ -1368,3 +1356,12 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q
return WINED3DERR_NOTAVAILABLE; return WINED3DERR_NOTAVAILABLE;
} }
} }
HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
device, type, parent, parent_ops, query);
return device->adapter->adapter_ops->adapter_create_query(device, type, parent, parent_ops, query);
}
...@@ -1785,6 +1785,11 @@ struct wined3d_query ...@@ -1785,6 +1785,11 @@ struct wined3d_query
UINT64 *map_ptr; UINT64 *map_ptr;
}; };
HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl,
struct wined3d_query *query) DECLSPEC_HIDDEN;
struct wined3d_event_query struct wined3d_event_query
{ {
struct wined3d_query query; struct wined3d_query query;
...@@ -2808,6 +2813,9 @@ struct wined3d_adapter_ops ...@@ -2808,6 +2813,9 @@ struct wined3d_adapter_ops
HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler); void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler); void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
void (*adapter_destroy_query)(struct wined3d_query *query);
}; };
/* The adapter structure */ /* The adapter structure */
......
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