[PATCH 3/8] wined3d: Move the stream-output statitics query fields from struct wined3d_context to struct wined3d_context_gl.
Henri Verbeet
hverbeet at codeweavers.com
Tue May 14 05:56:21 CDT 2019
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/context.c | 67 ++++++++++++++++++++----------------------
dlls/wined3d/query.c | 20 ++++++-------
dlls/wined3d/wined3d_private.h | 19 ++++++------
3 files changed, 51 insertions(+), 55 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e7b8fcc569e..e74963bace5 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -955,14 +955,14 @@ void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *que
context_gl->free_timestamp_queries[context_gl->free_timestamp_query_count++] = query->id;
}
-void context_alloc_so_statistics_query(struct wined3d_context *context,
+void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
struct wined3d_so_statistics_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_so_statistics_query_count)
+ if (context_gl->free_so_statistics_query_count)
{
- query->u = context->free_so_statistics_queries[--context->free_so_statistics_query_count];
+ query->u = context_gl->free_so_statistics_queries[--context_gl->free_so_statistics_query_count];
}
else
{
@@ -970,30 +970,30 @@ void context_alloc_so_statistics_query(struct wined3d_context *context,
checkGLcall("glGenQueries");
TRACE("Allocated SO statistics queries %u, %u in context %p.\n",
- query->u.id[0], query->u.id[1], context);
+ query->u.id[0], query->u.id[1], context_gl);
}
- query->context = context;
- list_add_head(&context->so_statistics_queries, &query->entry);
+ query->context_gl = context_gl;
+ list_add_head(&context_gl->so_statistics_queries, &query->entry);
}
-void context_free_so_statistics_query(struct wined3d_so_statistics_query *query)
+void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_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_so_statistics_queries,
- &context->free_so_statistics_query_size, context->free_so_statistics_query_count + 1,
- sizeof(*context->free_so_statistics_queries)))
+ if (!wined3d_array_reserve((void **)&context_gl->free_so_statistics_queries,
+ &context_gl->free_so_statistics_query_size, context_gl->free_so_statistics_query_count + 1,
+ sizeof(*context_gl->free_so_statistics_queries)))
{
ERR("Failed to grow free list, leaking GL queries %u, %u in context %p.\n",
- query->u.id[0], query->u.id[1], context);
+ query->u.id[0], query->u.id[1], context_gl);
return;
}
- context->free_so_statistics_queries[context->free_so_statistics_query_count++] = query->u;
+ context_gl->free_so_statistics_queries[context_gl->free_so_statistics_query_count++] = query->u;
}
void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
@@ -1318,7 +1318,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 fbo_entry *entry, *entry2;
HGLRC restore_ctx;
HDC restore_dc;
@@ -1332,14 +1331,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
else if (context->valid)
context_set_gl_context(context);
- LIST_FOR_EACH_ENTRY(so_statistics_query, &context->so_statistics_queries,
- struct wined3d_so_statistics_query, entry)
- {
- if (context->valid)
- GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(so_statistics_query->u.id), so_statistics_query->u.id));
- so_statistics_query->context = NULL;
- }
-
LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context->pipeline_statistics_queries,
struct wined3d_pipeline_statistics_query, entry)
{
@@ -1362,15 +1353,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
if (context->valid)
{
- if (gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY])
- {
- for (i = 0; i < context->free_so_statistics_query_count; ++i)
- {
- union wined3d_gl_so_statistics_query *q = &context->free_so_statistics_queries[i];
- GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
- }
- }
-
if (gl_info->supported[ARB_PIPELINE_STATISTICS_QUERY])
{
for (i = 0; i < context->free_pipeline_statistics_query_count; ++i)
@@ -1383,7 +1365,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
checkGLcall("context cleanup");
}
- heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
context_restore_pixel_format(context);
@@ -1408,6 +1389,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_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
struct wined3d_occlusion_query *occlusion_query;
struct wined3d_fence *fence;
@@ -1431,6 +1413,12 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
if (context_gl->blit_vbo)
GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
+ for (i = 0; i < context_gl->free_so_statistics_query_count; ++i)
+ {
+ union wined3d_gl_so_statistics_query *q = &context_gl->free_so_statistics_queries[i];
+ GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
+ }
+
if (context_gl->free_timestamp_query_count)
GL_EXTCALL(glDeleteQueries(context_gl->free_timestamp_query_count, context_gl->free_timestamp_queries));
@@ -1461,10 +1449,19 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
checkGLcall("context cleanup");
}
+ heap_free(context_gl->free_so_statistics_queries);
heap_free(context_gl->free_timestamp_queries);
heap_free(context_gl->free_fences);
heap_free(context_gl->free_occlusion_queries);
+ LIST_FOR_EACH_ENTRY(so_statistics_query, &context_gl->so_statistics_queries,
+ struct wined3d_so_statistics_query, entry)
+ {
+ if (context_gl->c.valid)
+ GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(so_statistics_query->u.id), so_statistics_query->u.id));
+ so_statistics_query->context_gl = NULL;
+ }
+
LIST_FOR_EACH_ENTRY(timestamp_query, &context_gl->timestamp_queries, struct wined3d_timestamp_query, entry)
{
if (context_gl->c.valid)
@@ -1916,7 +1913,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
struct wined3d_device *device = swapchain->device;
DWORD state;
- list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
list_init(&context->fbo_list);
@@ -1997,6 +1993,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);
+ list_init(&context_gl->so_statistics_queries);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 3fe7784e0f8..ff13c34059c 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -788,7 +788,7 @@ static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DW
TRACE("query %p, flags %#x.\n", query, flags);
- if (!(context = context_reacquire(device, pq->context)))
+ if (!(context = context_reacquire(device, &pq->context_gl->c)))
{
FIXME("%p Wrong thread, returning 0 primitives.\n", query);
memset(&pq->statistics, 0, sizeof(pq->statistics));
@@ -849,24 +849,24 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
{
if (pq->started)
{
- if ((context = context_reacquire(device, pq->context)))
+ if ((context = context_reacquire(device, &pq->context_gl->c)))
{
wined3d_so_statistics_query_end(pq, context);
}
else
{
FIXME("Wrong thread, can't restart query.\n");
- context_free_so_statistics_query(pq);
+ wined3d_context_gl_free_so_statistics_query(pq);
context = context_acquire(device, NULL, 0);
- context_alloc_so_statistics_query(context, pq);
+ wined3d_context_gl_alloc_so_statistics_query(wined3d_context_gl(context), pq);
}
}
else
{
- if (pq->context)
- context_free_so_statistics_query(pq);
+ if (pq->context_gl)
+ wined3d_context_gl_free_so_statistics_query(pq);
context = context_acquire(device, NULL, 0);
- context_alloc_so_statistics_query(context, pq);
+ wined3d_context_gl_alloc_so_statistics_query(wined3d_context_gl(context), pq);
}
gl_info = context->gl_info;
@@ -893,7 +893,7 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
{
if (pq->started)
{
- if ((context = context_reacquire(device, pq->context)))
+ if ((context = context_reacquire(device, &pq->context_gl->c)))
{
wined3d_so_statistics_query_end(pq, context);
@@ -1237,8 +1237,8 @@ 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);
+ if (pq->context_gl)
+ wined3d_context_gl_free_so_statistics_query(pq);
heap_free(pq);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 91eefc43761..da3aca18bd9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1817,16 +1817,12 @@ struct wined3d_so_statistics_query
struct list entry;
union wined3d_gl_so_statistics_query u;
- struct wined3d_context *context;
+ struct wined3d_context_gl *context_gl;
unsigned int stream_idx;
struct wined3d_query_data_so_statistics statistics;
BOOL started;
};
-void context_alloc_so_statistics_query(struct wined3d_context *context,
- struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
-void context_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
-
union wined3d_gl_pipeline_statistics_query
{
GLuint id[11];
@@ -1979,11 +1975,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* 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;
- struct list so_statistics_queries;
-
union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
SIZE_T free_pipeline_statistics_query_size;
unsigned int free_pipeline_statistics_query_count;
@@ -2017,6 +2008,7 @@ struct wined3d_context_gl
struct list occlusion_queries;
struct list fences;
struct list timestamp_queries;
+ struct list so_statistics_queries;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
@@ -2030,6 +2022,10 @@ struct wined3d_context_gl
SIZE_T free_timestamp_query_size;
unsigned int free_timestamp_query_count;
+ union wined3d_gl_so_statistics_query *free_so_statistics_queries;
+ SIZE_T free_so_statistics_query_size;
+ unsigned int free_so_statistics_query_count;
+
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@@ -2057,6 +2053,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_so_statistics_query(struct wined3d_context_gl *context_gl,
+ struct wined3d_so_statistics_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,
@@ -2068,6 +2066,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_so_statistics_query(struct wined3d_so_statistics_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;
--
2.11.0
More information about the wine-devel
mailing list