summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/wgl/shared/stw_device.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-07-06 18:23:37 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-07-06 18:23:37 +0100
commit1068c15c61a6c76a2da04ed3ca136f0d49abed1d (patch)
treea06dec9defa063c5b39826e9769ed2ef408d20bf /src/gallium/state_trackers/wgl/shared/stw_device.c
parent6f4167c8a215b561e5ad6eb58a8d875a5b8d8d6a (diff)
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.
Diffstat (limited to 'src/gallium/state_trackers/wgl/shared/stw_device.c')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.c15
1 files changed, 7 insertions, 8 deletions
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);