Made ENTER_GL() - LEAVE_GL() free X11 lock on exception inside opengl, code

Massimo Del Fedele max at veneto.com
Sat Jun 28 09:51:53 CDT 2008


Roderick Colenbrander ha scritto:
> Hi,
> 
> I don't think we want to go this way. First of all we want to emulate win32 opengl. If windows does this we MIGHT have to do something like this.
Well, I've never seen windows hang for an opengl call exception... But I 
   can be wrong. IMHO the exception should be catched and/or propagated, 
not allowed to block the whole app.....
Here the problem is that an exception thrown by gl code skips the 
wine_tsx11_unlock() call, blocking all following X11 code.

> Second all opengl calls hit ENTER_GL / LEAVE_GL and these few extra calls affect performance.
>
which extra calls ? That's just a __FINAL stuff to be sure the lock is 
freed, which is so on normal code flow with no exception....

> Personally I think that when you are hitting such an X11 lock exception that there is just a bug somewhere in wine. E.g. in case of a Direct3D app a piece of wined3d not doing proper locking. The same can be the case for plain opengl apps where a call might not have called wine_tsx11_unlock.
> 
Nope, this case is the same case as Louis patch of opengl for autocad 
installer. The ENTER_GL() macro gets executed, the opengl call starts, 
throws an exception and the LEAVE_GL() macro never gets executed, so the 
lock stays there.
There's no lock BEFORE the call, and the lock is there AFTER it.

I don't think that all opengl calls should be exception-free... not in 
wine, nor in windows. In windows I think we've not the stale lock 
problem, here we have it.


Regards

Max

> Regards,
> Roderick Colenbrander
> 
>>  From 31327546fc30520c80433fc964d7bd3ba4f80fa9 Mon Sep 17 00:00:00 2001
>> From: Massimo Del Fedele <max at veneto.com>
>> Date: Sat, 28 Jun 2008 12:00:17 +0200
>> Subject: Made ENTER_GL() - LEAVE_GL() free X11 lock on exception inside 
>> opengl
>>    code
>>
>> ---
>>   dlls/opengl32/opengl_ext.h |    8 ++++++--
>>   dlls/opengl32/wgl.c        |    6 ++++++
>>   2 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/dlls/opengl32/opengl_ext.h b/dlls/opengl32/opengl_ext.h
>> index 8ae7c2f..9892351 100644
>> --- a/dlls/opengl32/opengl_ext.h
>> +++ b/dlls/opengl32/opengl_ext.h
>> @@ -40,6 +40,9 @@
>>   #define WINAPI      __stdcall
>>   #define APIENTRY    WINAPI
>>
>> +#include "wine/library.h"
>> +#include "wine/exception.h"
>> +
>>   /* X11 locking */
>>
>>   extern void (*wine_tsx11_lock_ptr)(void);
>> @@ -47,8 +50,9 @@ extern void (*wine_tsx11_unlock_ptr)(void);
>>
>>   /* As GLX relies on X, this is needed */
>>   void enter_gl(void);
>> -#define ENTER_GL() enter_gl()
>> -#define LEAVE_GL() wine_tsx11_unlock_ptr()
>> +void CALLBACK leave_gl(BOOL);
>> +#define ENTER_GL() enter_gl(); __TRY {
>> +#define LEAVE_GL() } __FINALLY(leave_gl)
>>
>>
>>   typedef struct {
>> diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
>> index 6fbdeb4..7e31e20 100644
>> --- a/dlls/opengl32/wgl.c
>> +++ b/dlls/opengl32/wgl.c
>> @@ -114,6 +114,12 @@ void enter_gl(void)
>>       return;
>>   }
>>
>> +void CALLBACK leave_gl(BOOL dummy)
>> +{
>> +    wine_tsx11_unlock_ptr();
>> +    return;
>> +}
>> +
>>   const GLubyte * WINAPI wine_glGetString( GLenum name );
>>
>>   /***********************************************************************
>> -- 
>> 1.5.4.3
>>
>>
>>
> 




More information about the wine-patches mailing list