wined3d: Move the timestamp query fields from struct wined3d_context to struct wined3d_context_gl.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-05-14 15:26:20 +04:30 committed by Alexandre Julliard
parent bc6667b0d0
commit f942b20a97
3 changed files with 44 additions and 43 deletions

View File

@ -916,42 +916,43 @@ void wined3d_context_gl_free_fence(struct wined3d_fence *fence)
}
/* Context activation is done by the caller. */
void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query)
void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
struct wined3d_timestamp_query *query)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
if (context->free_timestamp_query_count)
if (context_gl->free_timestamp_query_count)
{
query->id = context->free_timestamp_queries[--context->free_timestamp_query_count];
query->id = context_gl->free_timestamp_queries[--context_gl->free_timestamp_query_count];
}
else
{
GL_EXTCALL(glGenQueries(1, &query->id));
checkGLcall("glGenQueries");
TRACE("Allocated timestamp query %u in context %p.\n", query->id, context);
TRACE("Allocated timestamp query %u in context %p.\n", query->id, context_gl);
}
query->context = context;
list_add_head(&context->timestamp_queries, &query->entry);
query->context_gl = context_gl;
list_add_head(&context_gl->timestamp_queries, &query->entry);
}
void context_free_timestamp_query(struct wined3d_timestamp_query *query)
void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query)
{
struct wined3d_context *context = query->context;
struct wined3d_context_gl *context_gl = query->context_gl;
list_remove(&query->entry);
query->context = NULL;
query->context_gl = NULL;
if (!wined3d_array_reserve((void **)&context->free_timestamp_queries,
&context->free_timestamp_query_size, context->free_timestamp_query_count + 1,
sizeof(*context->free_timestamp_queries)))
if (!wined3d_array_reserve((void **)&context_gl->free_timestamp_queries,
&context_gl->free_timestamp_query_size, context_gl->free_timestamp_query_count + 1,
sizeof(*context_gl->free_timestamp_queries)))
{
ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context);
ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context_gl);
return;
}
context->free_timestamp_queries[context->free_timestamp_query_count++] = query->id;
context_gl->free_timestamp_queries[context_gl->free_timestamp_query_count++] = query->id;
}
void context_alloc_so_statistics_query(struct wined3d_context *context,
@ -1318,7 +1319,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
struct fbo_entry *entry, *entry2;
HGLRC restore_ctx;
HDC restore_dc;
@ -1348,13 +1348,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
pipeline_statistics_query->context = NULL;
}
LIST_FOR_EACH_ENTRY(timestamp_query, &context->timestamp_queries, struct wined3d_timestamp_query, entry)
{
if (context->valid)
GL_EXTCALL(glDeleteQueries(1, &timestamp_query->id));
timestamp_query->context = NULL;
}
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
{
if (!context->valid) entry->id = 0;
@ -1387,15 +1380,11 @@ void wined3d_context_cleanup(struct wined3d_context *context)
}
}
if (gl_info->supported[ARB_TIMER_QUERY])
GL_EXTCALL(glDeleteQueries(context->free_timestamp_query_count, context->free_timestamp_queries));
checkGLcall("context cleanup");
}
heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
heap_free(context->free_timestamp_queries);
context_restore_pixel_format(context);
if (restore_ctx)
@ -1419,6 +1408,7 @@ void wined3d_context_cleanup(struct wined3d_context *context)
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
{
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
struct wined3d_timestamp_query *timestamp_query;
struct wined3d_occlusion_query *occlusion_query;
struct wined3d_fence *fence;
HGLRC restore_ctx;
@ -1441,6 +1431,9 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
if (context_gl->blit_vbo)
GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
if (context_gl->free_timestamp_query_count)
GL_EXTCALL(glDeleteQueries(context_gl->free_timestamp_query_count, context_gl->free_timestamp_queries));
if (gl_info->supported[ARB_SYNC])
{
for (i = 0; i < context_gl->free_fence_count; ++i)
@ -1468,9 +1461,17 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
checkGLcall("context cleanup");
}
heap_free(context_gl->free_timestamp_queries);
heap_free(context_gl->free_fences);
heap_free(context_gl->free_occlusion_queries);
LIST_FOR_EACH_ENTRY(timestamp_query, &context_gl->timestamp_queries, struct wined3d_timestamp_query, entry)
{
if (context_gl->c.valid)
GL_EXTCALL(glDeleteQueries(1, &timestamp_query->id));
timestamp_query->context_gl = NULL;
}
LIST_FOR_EACH_ENTRY(fence, &context_gl->fences, struct wined3d_fence, entry)
{
if (context_gl->c.valid)
@ -1915,7 +1916,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
struct wined3d_device *device = swapchain->device;
DWORD state;
list_init(&context->timestamp_queries);
list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
@ -1996,6 +1996,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
list_init(&context_gl->occlusion_queries);
list_init(&context_gl->fences);
list_init(&context_gl->timestamp_queries);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;

View File

@ -710,7 +710,7 @@ static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD
TRACE("query %p, flags %#x.\n", query, flags);
if (!(context = context_reacquire(device, tq->context)))
if (!(context = context_reacquire(device, &tq->context_gl->c)))
{
FIXME("%p Wrong thread, returning 1.\n", query);
tq->timestamp = 1;
@ -749,11 +749,11 @@ static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD
}
if (flags & WINED3DISSUE_END)
{
if (tq->context)
context_free_timestamp_query(tq);
if (tq->context_gl)
wined3d_context_gl_free_timestamp_query(tq);
context = context_acquire(query->device, NULL, 0);
gl_info = context->gl_info;
context_alloc_timestamp_query(context, tq);
wined3d_context_gl_alloc_timestamp_query(wined3d_context_gl(context), tq);
GL_EXTCALL(glQueryCounter(tq->id, GL_TIMESTAMP));
checkGLcall("glQueryCounter()");
context_release(context);
@ -1141,8 +1141,8 @@ 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);
if (tq->context_gl)
wined3d_context_gl_free_timestamp_query(tq);
heap_free(tq);
}

View File

@ -1797,13 +1797,10 @@ struct wined3d_timestamp_query
struct list entry;
GLuint id;
struct wined3d_context *context;
struct wined3d_context_gl *context_gl;
UINT64 timestamp;
};
void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
void context_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
union wined3d_gl_so_statistics_query
{
GLuint id[2];
@ -1982,11 +1979,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */
GLuint *free_timestamp_queries;
SIZE_T free_timestamp_query_size;
unsigned int free_timestamp_query_count;
struct list timestamp_queries;
union wined3d_gl_so_statistics_query *free_so_statistics_queries;
SIZE_T free_so_statistics_query_size;
unsigned int free_so_statistics_query_count;
@ -2024,6 +2016,7 @@ struct wined3d_context_gl
/* Queries. */
struct list occlusion_queries;
struct list fences;
struct list timestamp_queries;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
@ -2033,6 +2026,10 @@ struct wined3d_context_gl
SIZE_T free_fence_size;
unsigned int free_fence_count;
GLuint *free_timestamp_queries;
SIZE_T free_timestamp_query_size;
unsigned int free_timestamp_query_count;
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@ -2060,6 +2057,8 @@ void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
const struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
@ -2069,6 +2068,7 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,