From 1068c15c61a6c76a2da04ed3ca136f0d49abed1d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 6 Jul 2009 18:23:37 +0100 Subject: wgl: Make the stw_framebuffer destructions threadsafe. Ensure no other thread is accessing a framebuffer when it is being destroyed by acquiring both the global and per-framebuffer mutexes. Normal access only needs the global lock to walk the linked list and acquire the per-framebuffer mutex. --- src/gallium/state_trackers/wgl/shared/stw_device.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/gallium/state_trackers/wgl/shared/stw_device.c') diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index ce46624146..0b6954915a 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -69,8 +69,6 @@ stw_flush_frontbuffer(struct pipe_screen *screen, fb = stw_framebuffer_from_hdc( hdc ); /* fb can be NULL if window was destroyed already */ if (fb) { - pipe_mutex_lock( fb->mutex ); - #if DEBUG { struct pipe_surface *surface2; @@ -94,8 +92,7 @@ stw_flush_frontbuffer(struct pipe_screen *screen, if(fb) { stw_framebuffer_update(fb); - - pipe_mutex_unlock( fb->mutex ); + stw_framebuffer_release(fb); } } @@ -138,7 +135,8 @@ stw_init(const struct stw_winsys *stw_winsys) stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer; - pipe_mutex_init( stw_dev->mutex ); + pipe_mutex_init( stw_dev->ctx_mutex ); + pipe_mutex_init( stw_dev->fb_mutex ); stw_dev->ctx_table = handle_table_create(); if (!stw_dev->ctx_table) { @@ -179,7 +177,7 @@ stw_cleanup(void) if (!stw_dev) return; - pipe_mutex_lock( stw_dev->mutex ); + pipe_mutex_lock( stw_dev->ctx_mutex ); { /* Ensure all contexts are destroyed */ i = handle_table_get_first_handle(stw_dev->ctx_table); @@ -189,11 +187,12 @@ stw_cleanup(void) } handle_table_destroy(stw_dev->ctx_table); } - pipe_mutex_unlock( stw_dev->mutex ); + pipe_mutex_unlock( stw_dev->ctx_mutex ); stw_framebuffer_cleanup(); - pipe_mutex_destroy( stw_dev->mutex ); + pipe_mutex_destroy( stw_dev->fb_mutex ); + pipe_mutex_destroy( stw_dev->ctx_mutex ); stw_dev->screen->destroy(stw_dev->screen); -- cgit v1.2.3