wined3d: Move the fence 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>
stable
Henri Verbeet 2019-05-14 15:26:19 +04:30 committed by Alexandre Julliard
parent 7dfc56937d
commit bc6667b0d0
3 changed files with 86 additions and 84 deletions

View File

@ -856,13 +856,13 @@ void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *que
}
/* Context activation is done by the caller. */
void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *fence)
void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl, struct wined3d_fence *fence)
{
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_fence_count)
if (context_gl->free_fence_count)
{
fence->object = context->free_fences[--context->free_fence_count];
fence->object = context_gl->free_fences[--context_gl->free_fence_count];
}
else
{
@ -870,21 +870,21 @@ void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *
{
/* Using ARB_sync, not much to do here. */
fence->object.sync = NULL;
TRACE("Allocated sync object in context %p.\n", context);
TRACE("Allocated sync object in context %p.\n", context_gl);
}
else if (gl_info->supported[APPLE_FENCE])
{
GL_EXTCALL(glGenFencesAPPLE(1, &fence->object.id));
checkGLcall("glGenFencesAPPLE");
TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
TRACE("Allocated fence %u in context %p.\n", fence->object.id, context_gl);
}
else if(gl_info->supported[NV_FENCE])
{
GL_EXTCALL(glGenFencesNV(1, &fence->object.id));
checkGLcall("glGenFencesNV");
TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
TRACE("Allocated fence %u in context %p.\n", fence->object.id, context_gl);
}
else
{
@ -893,26 +893,26 @@ void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *
}
}
fence->context = context;
list_add_head(&context->fences, &fence->entry);
fence->context_gl = context_gl;
list_add_head(&context_gl->fences, &fence->entry);
}
void context_free_fence(struct wined3d_fence *fence)
void wined3d_context_gl_free_fence(struct wined3d_fence *fence)
{
struct wined3d_context *context = fence->context;
struct wined3d_context_gl *context_gl = fence->context_gl;
list_remove(&fence->entry);
fence->context = NULL;
fence->context_gl = NULL;
if (!wined3d_array_reserve((void **)&context->free_fences,
&context->free_fence_size, context->free_fence_count + 1,
sizeof(*context->free_fences)))
if (!wined3d_array_reserve((void **)&context_gl->free_fences,
&context_gl->free_fence_size, context_gl->free_fence_count + 1,
sizeof(*context_gl->free_fences)))
{
ERR("Failed to grow free list, leaking fence %u in context %p.\n", fence->object.id, context);
ERR("Failed to grow free list, leaking fence %u in context %p.\n", fence->object.id, context_gl);
return;
}
context->free_fences[context->free_fence_count++] = fence->object;
context_gl->free_fences[context_gl->free_fence_count++] = fence->object;
}
/* Context activation is done by the caller. */
@ -1320,7 +1320,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
struct wined3d_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
struct fbo_entry *entry, *entry2;
struct wined3d_fence *fence;
HGLRC restore_ctx;
HDC restore_dc;
unsigned int i;
@ -1356,27 +1355,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
timestamp_query->context = NULL;
}
LIST_FOR_EACH_ENTRY(fence, &context->fences, struct wined3d_fence, entry)
{
if (context->valid)
{
if (gl_info->supported[ARB_SYNC])
{
if (fence->object.sync)
GL_EXTCALL(glDeleteSync(fence->object.sync));
}
else if (gl_info->supported[APPLE_FENCE])
{
GL_EXTCALL(glDeleteFencesAPPLE(1, &fence->object.id));
}
else if (gl_info->supported[NV_FENCE])
{
GL_EXTCALL(glDeleteFencesNV(1, &fence->object.id));
}
}
fence->context = NULL;
}
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
{
if (!context->valid) entry->id = 0;
@ -1412,35 +1390,12 @@ 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_SYNC])
{
for (i = 0; i < context->free_fence_count; ++i)
{
GL_EXTCALL(glDeleteSync(context->free_fences[i].sync));
}
}
else if (gl_info->supported[APPLE_FENCE])
{
for (i = 0; i < context->free_fence_count; ++i)
{
GL_EXTCALL(glDeleteFencesAPPLE(1, &context->free_fences[i].id));
}
}
else if (gl_info->supported[NV_FENCE])
{
for (i = 0; i < context->free_fence_count; ++i)
{
GL_EXTCALL(glDeleteFencesNV(1, &context->free_fences[i].id));
}
}
checkGLcall("context cleanup");
}
heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
heap_free(context->free_timestamp_queries);
heap_free(context->free_fences);
context_restore_pixel_format(context);
if (restore_ctx)
@ -1465,8 +1420,10 @@ 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;
struct wined3d_fence *fence;
HGLRC restore_ctx;
HDC restore_dc;
unsigned int i;
restore_ctx = wglGetCurrentContext();
restore_dc = wglGetCurrentDC();
@ -1484,13 +1441,57 @@ 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 (gl_info->supported[ARB_SYNC])
{
for (i = 0; i < context_gl->free_fence_count; ++i)
{
GL_EXTCALL(glDeleteSync(context_gl->free_fences[i].sync));
}
}
else if (gl_info->supported[APPLE_FENCE])
{
for (i = 0; i < context_gl->free_fence_count; ++i)
{
GL_EXTCALL(glDeleteFencesAPPLE(1, &context_gl->free_fences[i].id));
}
}
else if (gl_info->supported[NV_FENCE])
{
for (i = 0; i < context_gl->free_fence_count; ++i)
{
GL_EXTCALL(glDeleteFencesNV(1, &context_gl->free_fences[i].id));
}
}
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_fences);
heap_free(context_gl->free_occlusion_queries);
LIST_FOR_EACH_ENTRY(fence, &context_gl->fences, struct wined3d_fence, entry)
{
if (context_gl->c.valid)
{
if (gl_info->supported[ARB_SYNC])
{
if (fence->object.sync)
GL_EXTCALL(glDeleteSync(fence->object.sync));
}
else if (gl_info->supported[APPLE_FENCE])
{
GL_EXTCALL(glDeleteFencesAPPLE(1, &fence->object.id));
}
else if (gl_info->supported[NV_FENCE])
{
GL_EXTCALL(glDeleteFencesNV(1, &fence->object.id));
}
}
fence->context_gl = NULL;
}
LIST_FOR_EACH_ENTRY(occlusion_query, &context_gl->occlusion_queries, struct wined3d_occlusion_query, entry)
{
if (context_gl->c.valid)
@ -1915,7 +1916,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
DWORD state;
list_init(&context->timestamp_queries);
list_init(&context->fences);
list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
@ -1995,6 +1995,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
d3d_info = context->d3d_info;
list_init(&context_gl->occlusion_queries);
list_init(&context_gl->fences);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;

View File

@ -189,15 +189,15 @@ static enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *
TRACE("fence %p, device %p, flags %#x.\n", fence, device, flags);
if (!fence->context)
if (!fence->context_gl)
{
TRACE("Fence not issued.\n");
return WINED3D_FENCE_NOT_STARTED;
}
if (!(context = context_reacquire(device, fence->context)))
if (!(context = context_reacquire(device, &fence->context_gl->c)))
{
if (!fence->context->gl_info->supported[ARB_SYNC])
if (!fence->context_gl->c.gl_info->supported[ARB_SYNC])
{
WARN("Fence tested from wrong thread.\n");
return WINED3D_FENCE_WRONG_THREAD;
@ -266,14 +266,14 @@ enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
TRACE("fence %p, device %p.\n", fence, device);
if (!fence->context)
if (!fence->context_gl)
{
TRACE("Fence not issued.\n");
return WINED3D_FENCE_NOT_STARTED;
}
gl_info = fence->context->gl_info;
gl_info = fence->context_gl->c.gl_info;
if (!(context = context_reacquire(device, fence->context)))
if (!(context = context_reacquire(device, &fence->context_gl->c)))
{
/* A glFinish does not reliably wait for draws in other contexts. The caller has
* to find its own way to cope with the thread switch
@ -337,14 +337,14 @@ void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_devic
struct wined3d_context *context = NULL;
const struct wined3d_gl_info *gl_info;
if (fence->context && !(context = context_reacquire(device, fence->context))
&& !fence->context->gl_info->supported[ARB_SYNC])
context_free_fence(fence);
if (fence->context_gl && !(context = context_reacquire(device, &fence->context_gl->c))
&& !fence->context_gl->c.gl_info->supported[ARB_SYNC])
wined3d_context_gl_free_fence(fence);
if (!context)
context = context_acquire(device, NULL, 0);
gl_info = context->gl_info;
if (!fence->context)
context_alloc_fence(context, fence);
if (!fence->context_gl)
wined3d_context_gl_alloc_fence(wined3d_context_gl(context), fence);
if (gl_info->supported[ARB_SYNC])
{
@ -370,8 +370,8 @@ void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_devic
static void wined3d_fence_free(struct wined3d_fence *fence)
{
if (fence->context)
context_free_fence(fence);
if (fence->context_gl)
wined3d_context_gl_free_fence(fence);
}
void wined3d_fence_destroy(struct wined3d_fence *fence)

View File

@ -1726,7 +1726,7 @@ struct wined3d_fence
{
struct list entry;
union wined3d_gl_fence_object object;
struct wined3d_context *context;
struct wined3d_context_gl *context_gl;
};
HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
@ -1982,11 +1982,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */
union wined3d_gl_fence_object *free_fences;
SIZE_T free_fence_size;
unsigned int free_fence_count;
struct list fences;
GLuint *free_timestamp_queries;
SIZE_T free_timestamp_query_size;
unsigned int free_timestamp_query_count;
@ -2028,11 +2023,16 @@ struct wined3d_context_gl
/* Queries. */
struct list occlusion_queries;
struct list fences;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
unsigned int free_occlusion_query_count;
union wined3d_gl_fence_object *free_fences;
SIZE_T free_fence_size;
unsigned int free_fence_count;
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@ -2056,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_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_apply_blit_state(struct wined3d_context_gl *context_gl,
@ -2065,6 +2067,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_fence(struct wined3d_fence *fence) 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;
@ -2213,7 +2216,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;
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,
@ -2238,7 +2240,6 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_
enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
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;
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;