wined3d: Use a single allocation for event queries.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
be2908ed07
commit
fac012f2e1
|
@ -25,6 +25,23 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
||||||
|
|
||||||
|
static void wined3d_query_init(struct wined3d_query *query, struct wined3d_device *device,
|
||||||
|
enum wined3d_query_type type, DWORD data_size, const struct wined3d_query_ops *query_ops, void *parent)
|
||||||
|
{
|
||||||
|
query->ref = 1;
|
||||||
|
query->parent = parent;
|
||||||
|
query->device = device;
|
||||||
|
query->state = QUERY_CREATED;
|
||||||
|
query->type = type;
|
||||||
|
query->data_size = data_size;
|
||||||
|
query->query_ops = query_ops;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct wined3d_event_query *wined3d_event_query_from_query(struct wined3d_query *query)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(query, struct wined3d_event_query, query);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info)
|
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];
|
return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
|
||||||
|
@ -243,8 +260,8 @@ static void wined3d_query_destroy_object(void *object)
|
||||||
* context, and (still) leaking the actual query. */
|
* context, and (still) leaking the actual query. */
|
||||||
if (query->type == WINED3D_QUERY_TYPE_EVENT)
|
if (query->type == WINED3D_QUERY_TYPE_EVENT)
|
||||||
{
|
{
|
||||||
struct wined3d_event_query *event_query = query->extendedData;
|
wined3d_event_query_destroy(wined3d_event_query_from_query(query));
|
||||||
wined3d_event_query_destroy(event_query);
|
return;
|
||||||
}
|
}
|
||||||
else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION)
|
else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION)
|
||||||
{
|
{
|
||||||
|
@ -375,9 +392,9 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query,
|
||||||
static HRESULT wined3d_event_query_ops_get_data(struct wined3d_query *query,
|
static HRESULT wined3d_event_query_ops_get_data(struct wined3d_query *query,
|
||||||
void *data, DWORD size, DWORD flags)
|
void *data, DWORD size, DWORD flags)
|
||||||
{
|
{
|
||||||
struct wined3d_event_query *event_query = query->extendedData;
|
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
|
||||||
BOOL signaled;
|
|
||||||
enum wined3d_event_query_result ret;
|
enum wined3d_event_query_result ret;
|
||||||
|
BOOL signaled;
|
||||||
|
|
||||||
TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags);
|
TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags);
|
||||||
|
|
||||||
|
@ -430,16 +447,15 @@ static HRESULT wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD
|
||||||
{
|
{
|
||||||
TRACE("query %p, flags %#x.\n", query, flags);
|
TRACE("query %p, flags %#x.\n", query, flags);
|
||||||
|
|
||||||
TRACE("(%p) : flags %#x, type D3DQUERY_EVENT\n", query, flags);
|
|
||||||
if (flags & WINED3DISSUE_END)
|
if (flags & WINED3DISSUE_END)
|
||||||
{
|
{
|
||||||
struct wined3d_event_query *event_query = query->extendedData;
|
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
|
||||||
|
|
||||||
wined3d_event_query_issue(event_query, query->device);
|
wined3d_event_query_issue(event_query, query->device);
|
||||||
}
|
}
|
||||||
else if (flags & WINED3DISSUE_BEGIN)
|
else if (flags & WINED3DISSUE_BEGIN)
|
||||||
{
|
{
|
||||||
/* Started implicitly at device creation */
|
/* Started implicitly at query creation. */
|
||||||
ERR("Event query issued with START flag - what to do?\n");
|
ERR("Event query issued with START flag - what to do?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,6 +675,31 @@ static const struct wined3d_query_ops event_query_ops =
|
||||||
wined3d_event_query_ops_issue,
|
wined3d_event_query_ops_issue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static HRESULT wined3d_event_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_event_query *object;
|
||||||
|
|
||||||
|
TRACE("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
|
||||||
|
|
||||||
|
if (!wined3d_event_query_supported(gl_info))
|
||||||
|
{
|
||||||
|
WARN("Event queries not supported.\n");
|
||||||
|
return WINED3DERR_NOTAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
wined3d_query_init(&object->query, device, type, sizeof(BOOL), &event_query_ops, parent);
|
||||||
|
|
||||||
|
TRACE("Created query %p.\n", object);
|
||||||
|
*query = &object->query;
|
||||||
|
|
||||||
|
return WINED3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct wined3d_query_ops occlusion_query_ops =
|
static const struct wined3d_query_ops occlusion_query_ops =
|
||||||
{
|
{
|
||||||
wined3d_occlusion_query_ops_get_data,
|
wined3d_occlusion_query_ops_get_data,
|
||||||
|
@ -704,23 +745,6 @@ static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *de
|
||||||
((struct wined3d_occlusion_query *)query->extendedData)->context = NULL;
|
((struct wined3d_occlusion_query *)query->extendedData)->context = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3D_QUERY_TYPE_EVENT:
|
|
||||||
TRACE("Event query.\n");
|
|
||||||
if (!wined3d_event_query_supported(gl_info))
|
|
||||||
{
|
|
||||||
WARN("Event queries not supported.\n");
|
|
||||||
return WINED3DERR_NOTAVAILABLE;
|
|
||||||
}
|
|
||||||
query->query_ops = &event_query_ops;
|
|
||||||
query->data_size = sizeof(BOOL);
|
|
||||||
query->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct wined3d_event_query));
|
|
||||||
if (!query->extendedData)
|
|
||||||
{
|
|
||||||
ERR("Failed to allocate event query memory.\n");
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WINED3D_QUERY_TYPE_TIMESTAMP:
|
case WINED3D_QUERY_TYPE_TIMESTAMP:
|
||||||
TRACE("Timestamp query.\n");
|
TRACE("Timestamp query.\n");
|
||||||
if (!gl_info->supported[ARB_TIMER_QUERY])
|
if (!gl_info->supported[ARB_TIMER_QUERY])
|
||||||
|
@ -783,6 +807,15 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device,
|
||||||
|
|
||||||
TRACE("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
|
TRACE("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case WINED3D_QUERY_TYPE_EVENT:
|
||||||
|
return wined3d_event_query_create(device, type, parent, query);
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||||
if (!object)
|
if (!object)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
|
@ -1367,6 +1367,36 @@ enum fogsource {
|
||||||
FOGSOURCE_COORD,
|
FOGSOURCE_COORD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Direct3D terminology with little modifications. We do not have an issued
|
||||||
|
* state because only the driver knows about it, but we have a created state
|
||||||
|
* because D3D allows GetData() on a created query, but OpenGL doesn't. */
|
||||||
|
enum wined3d_query_state
|
||||||
|
{
|
||||||
|
QUERY_CREATED,
|
||||||
|
QUERY_SIGNALLED,
|
||||||
|
QUERY_BUILDING
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wined3d_query_ops
|
||||||
|
{
|
||||||
|
HRESULT (*query_get_data)(struct wined3d_query *query, void *data, DWORD data_size, DWORD flags);
|
||||||
|
HRESULT (*query_issue)(struct wined3d_query *query, DWORD flags);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wined3d_query
|
||||||
|
{
|
||||||
|
LONG ref;
|
||||||
|
|
||||||
|
void *parent;
|
||||||
|
struct wined3d_device *device;
|
||||||
|
enum wined3d_query_state state;
|
||||||
|
enum wined3d_query_type type;
|
||||||
|
DWORD data_size;
|
||||||
|
const struct wined3d_query_ops *query_ops;
|
||||||
|
|
||||||
|
void *extendedData;
|
||||||
|
};
|
||||||
|
|
||||||
struct wined3d_occlusion_query
|
struct wined3d_occlusion_query
|
||||||
{
|
{
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
@ -1382,6 +1412,8 @@ union wined3d_gl_query_object
|
||||||
|
|
||||||
struct wined3d_event_query
|
struct wined3d_event_query
|
||||||
{
|
{
|
||||||
|
struct wined3d_query query;
|
||||||
|
|
||||||
struct list entry;
|
struct list entry;
|
||||||
union wined3d_gl_query_object object;
|
union wined3d_gl_query_object object;
|
||||||
struct wined3d_context *context;
|
struct wined3d_context *context;
|
||||||
|
@ -3051,35 +3083,6 @@ static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d
|
||||||
cs->ops->push_constants(cs, p, start_idx, count, constants);
|
cs->ops->push_constants(cs, p, start_idx, count, constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Direct3D terminology with little modifications. We do not have an issued state
|
|
||||||
* because only the driver knows about it, but we have a created state because d3d
|
|
||||||
* allows GetData on a created issue, but opengl doesn't
|
|
||||||
*/
|
|
||||||
enum query_state {
|
|
||||||
QUERY_CREATED,
|
|
||||||
QUERY_SIGNALLED,
|
|
||||||
QUERY_BUILDING
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wined3d_query_ops
|
|
||||||
{
|
|
||||||
HRESULT (*query_get_data)(struct wined3d_query *query, void *data, DWORD data_size, DWORD flags);
|
|
||||||
HRESULT (*query_issue)(struct wined3d_query *query, DWORD flags);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wined3d_query
|
|
||||||
{
|
|
||||||
LONG ref;
|
|
||||||
|
|
||||||
void *parent;
|
|
||||||
const struct wined3d_query_ops *query_ops;
|
|
||||||
struct wined3d_device *device;
|
|
||||||
enum query_state state;
|
|
||||||
enum wined3d_query_type type;
|
|
||||||
DWORD data_size;
|
|
||||||
void *extendedData;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
|
/* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
|
||||||
* fixed function semantics as D3DCOLOR or FLOAT16 */
|
* fixed function semantics as D3DCOLOR or FLOAT16 */
|
||||||
enum wined3d_buffer_conversion_type
|
enum wined3d_buffer_conversion_type
|
||||||
|
|
Loading…
Reference in New Issue