Commit ce1c0ff1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent de16768d
......@@ -808,13 +808,14 @@ void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target
}
/* Context activation is done by the caller. */
void context_alloc_occlusion_query(struct wined3d_context *context, struct wined3d_occlusion_query *query)
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_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_occlusion_query_count)
if (context_gl->free_occlusion_query_count)
{
query->id = context->free_occlusion_queries[--context->free_occlusion_query_count];
query->id = context_gl->free_occlusion_queries[--context_gl->free_occlusion_query_count];
}
else
{
......@@ -823,7 +824,7 @@ void context_alloc_occlusion_query(struct wined3d_context *context, struct wined
GL_EXTCALL(glGenQueries(1, &query->id));
checkGLcall("glGenQueries");
TRACE("Allocated occlusion query %u in context %p.\n", query->id, context);
TRACE("Allocated occlusion query %u in context %p.\n", query->id, context_gl);
}
else
{
......@@ -832,26 +833,26 @@ void context_alloc_occlusion_query(struct wined3d_context *context, struct wined
}
}
query->context = context;
list_add_head(&context->occlusion_queries, &query->entry);
query->context_gl = context_gl;
list_add_head(&context_gl->occlusion_queries, &query->entry);
}
void context_free_occlusion_query(struct wined3d_occlusion_query *query)
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_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_occlusion_queries,
&context->free_occlusion_query_size, context->free_occlusion_query_count + 1,
sizeof(*context->free_occlusion_queries)))
if (!wined3d_array_reserve((void **)&context_gl->free_occlusion_queries,
&context_gl->free_occlusion_query_size, context_gl->free_occlusion_query_count + 1,
sizeof(*context_gl->free_occlusion_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_occlusion_queries[context->free_occlusion_query_count++] = query->id;
context_gl->free_occlusion_queries[context_gl->free_occlusion_query_count++] = query->id;
}
/* Context activation is done by the caller. */
......@@ -1318,7 +1319,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
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 wined3d_occlusion_query *occlusion_query;
struct fbo_entry *entry, *entry2;
struct wined3d_fence *fence;
HGLRC restore_ctx;
......@@ -1356,13 +1356,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
timestamp_query->context = NULL;
}
LIST_FOR_EACH_ENTRY(occlusion_query, &context->occlusion_queries, struct wined3d_occlusion_query, entry)
{
if (context->valid && gl_info->supported[ARB_OCCLUSION_QUERY])
GL_EXTCALL(glDeleteQueries(1, &occlusion_query->id));
occlusion_query->context = NULL;
}
LIST_FOR_EACH_ENTRY(fence, &context->fences, struct wined3d_fence, entry)
{
if (context->valid)
......@@ -1419,9 +1412,6 @@ 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));
if (gl_info->supported[ARB_OCCLUSION_QUERY])
GL_EXTCALL(glDeleteQueries(context->free_occlusion_query_count, context->free_occlusion_queries));
if (gl_info->supported[ARB_SYNC])
{
for (i = 0; i < context->free_fence_count; ++i)
......@@ -1450,7 +1440,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
heap_free(context->free_timestamp_queries);
heap_free(context->free_occlusion_queries);
heap_free(context->free_fences);
context_restore_pixel_format(context);
......@@ -1475,6 +1464,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_occlusion_query *occlusion_query;
HGLRC restore_ctx;
HDC restore_dc;
......@@ -1494,8 +1484,19 @@ 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_occlusion_query_count)
GL_EXTCALL(glDeleteQueries(context_gl->free_occlusion_query_count, context_gl->free_occlusion_queries));
checkGLcall("context cleanup");
}
heap_free(context_gl->free_occlusion_queries);
LIST_FOR_EACH_ENTRY(occlusion_query, &context_gl->occlusion_queries, struct wined3d_occlusion_query, entry)
{
if (context_gl->c.valid)
GL_EXTCALL(glDeleteQueries(1, &occlusion_query->id));
occlusion_query->context_gl = NULL;
}
heap_free(context_gl->texture_type);
......@@ -1914,7 +1915,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
DWORD state;
list_init(&context->timestamp_queries);
list_init(&context->occlusion_queries);
list_init(&context->fences);
list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
......@@ -1994,6 +1994,8 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
gl_info = context->gl_info;
d3d_info = context->d3d_info;
list_init(&context_gl->occlusion_queries);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
for (i = 0; i < ARRAY_SIZE(context_gl->rev_tex_unit_map); ++i)
......
......@@ -538,7 +538,7 @@ static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query, DWORD
TRACE("query %p, flags %#x.\n", query, flags);
if (!(context = context_reacquire(device, oq->context)))
if (!(context = context_reacquire(device, &oq->context_gl->c)))
{
FIXME("%p Wrong thread, returning 1.\n", query);
oq->samples = 1;
......@@ -642,7 +642,7 @@ static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
{
if (oq->started)
{
if ((context = context_reacquire(device, oq->context)))
if ((context = context_reacquire(device, &oq->context_gl->c)))
{
gl_info = context->gl_info;
GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
......@@ -651,17 +651,17 @@ static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
else
{
FIXME("Wrong thread, can't restart query.\n");
context_free_occlusion_query(oq);
wined3d_context_gl_free_occlusion_query(oq);
context = context_acquire(device, NULL, 0);
context_alloc_occlusion_query(context, oq);
wined3d_context_gl_alloc_occlusion_query(wined3d_context_gl(context), oq);
}
}
else
{
if (oq->context)
context_free_occlusion_query(oq);
if (oq->context_gl)
wined3d_context_gl_free_occlusion_query(oq);
context = context_acquire(device, NULL, 0);
context_alloc_occlusion_query(context, oq);
wined3d_context_gl_alloc_occlusion_query(wined3d_context_gl(context), oq);
}
gl_info = context->gl_info;
......@@ -678,7 +678,7 @@ static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
* so avoid generating an error. */
if (oq->started)
{
if ((context = context_reacquire(device, oq->context)))
if ((context = context_reacquire(device, &oq->context_gl->c)))
{
gl_info = context->gl_info;
GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
......@@ -1097,8 +1097,8 @@ 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);
if (oq->context_gl)
wined3d_context_gl_free_occlusion_query(oq);
heap_free(oq);
}
......
......@@ -1786,7 +1786,7 @@ struct wined3d_occlusion_query
struct list entry;
GLuint id;
struct wined3d_context *context;
struct wined3d_context_gl *context_gl;
UINT64 samples;
BOOL started;
};
......@@ -1982,11 +1982,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
unsigned int free_occlusion_query_count;
struct list occlusion_queries;
union wined3d_gl_fence_object *free_fences;
SIZE_T free_fence_size;
unsigned int free_fence_count;
......@@ -2031,6 +2026,13 @@ struct wined3d_context_gl
GLenum *texture_type;
/* Queries. */
struct list occlusion_queries;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
unsigned int free_occlusion_query_count;
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
......@@ -2054,6 +2056,8 @@ static inline const struct wined3d_context_gl *wined3d_context_gl_const(const st
return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
}
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_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,
......@@ -2061,6 +2065,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
GLenum target, GLuint name) DECLSPEC_HIDDEN;
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_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,
......@@ -2209,8 +2214,6 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSP
struct wined3d_context *context_acquire(const struct wined3d_device *device,
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void context_alloc_occlusion_query(struct wined3d_context *context,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state,
UINT rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
......@@ -2236,7 +2239,6 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_
void context_enable_clip_distances(struct wined3d_context *context, unsigned int mask) DECLSPEC_HIDDEN;
void context_end_transform_feedback(struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context) DECLSPEC_HIDDEN;
DWORD context_get_tls_idx(void) 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