Jan Zerebecki : wined3d: Make CreateFakeGLContext thread safe.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Feb 23 05:28:17 CST 2007
Module: wine
Branch: master
Commit: 706bc26a69e122deeaa22b4677df60a8eaac1b50
URL: http://source.winehq.org/git/wine.git/?a=commit;h=706bc26a69e122deeaa22b4677df60a8eaac1b50
Author: Jan Zerebecki <jan.wine at zerebecki.de>
Date: Fri Feb 23 09:24:45 2007 +0100
wined3d: Make CreateFakeGLContext thread safe.
---
dlls/wined3d/directx.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 841e16f..653c183 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -78,11 +78,24 @@ static BOOL wined3d_fake_gl_context_foreign;
static BOOL wined3d_fake_gl_context_available = FALSE;
static Display* wined3d_fake_gl_context_display = NULL;
+static CRITICAL_SECTION wined3d_fake_gl_context_cs;
+static CRITICAL_SECTION_DEBUG wined3d_fake_gl_context_cs_debug =
+{
+ 0, 0, &wined3d_fake_gl_context_cs,
+ { &wined3d_fake_gl_context_cs_debug.ProcessLocksList,
+ &wined3d_fake_gl_context_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": wined3d_fake_gl_context_cs") }
+};
+static CRITICAL_SECTION wined3d_fake_gl_context_cs = { &wined3d_fake_gl_context_cs_debug, -1, 0, 0, 0, 0 };
+
static void WineD3D_ReleaseFakeGLContext(void) {
GLXContext glCtx;
+ EnterCriticalSection(&wined3d_fake_gl_context_cs);
+
if(!wined3d_fake_gl_context_available) {
TRACE_(d3d_caps)("context not available\n");
+ LeaveCriticalSection(&wined3d_fake_gl_context_cs);
return;
}
@@ -95,17 +108,21 @@ static void WineD3D_ReleaseFakeGLContext(void) {
glXMakeCurrent(wined3d_fake_gl_context_display, None, NULL);
glXDestroyContext(wined3d_fake_gl_context_display, glCtx);
}
- LEAVE_GL();
wined3d_fake_gl_context_available = FALSE;
}
assert(wined3d_fake_gl_context_ref >= 0);
+ LeaveCriticalSection(&wined3d_fake_gl_context_cs);
+ LEAVE_GL();
}
static BOOL WineD3D_CreateFakeGLContext(void) {
XVisualInfo* visInfo;
GLXContext glCtx;
+ ENTER_GL();
+ EnterCriticalSection(&wined3d_fake_gl_context_cs);
+
TRACE_(d3d_caps)("getting context...\n");
if(wined3d_fake_gl_context_ref > 0) goto ret;
assert(0 == wined3d_fake_gl_context_ref);
@@ -119,8 +136,6 @@ static BOOL WineD3D_CreateFakeGLContext(void) {
ReleaseDC(0, device_context);
}
- ENTER_GL();
-
visInfo = NULL;
glCtx = glXGetCurrentContext();
@@ -170,10 +185,12 @@ static BOOL WineD3D_CreateFakeGLContext(void) {
TRACE_(d3d_caps)("incrementing ref from %i\n", wined3d_fake_gl_context_ref);
wined3d_fake_gl_context_ref++;
wined3d_fake_gl_context_available = TRUE;
+ LeaveCriticalSection(&wined3d_fake_gl_context_cs);
return TRUE;
fail:
if(visInfo) XFree(visInfo);
if(glCtx) glXDestroyContext(wined3d_fake_gl_context_display, glCtx);
+ LeaveCriticalSection(&wined3d_fake_gl_context_cs);
LEAVE_GL();
return FALSE;
}
More information about the wine-cvs
mailing list