Am Montag, 10. Dezember 2007 18:39:49 schrieb Alexander Dorofeyev:
Hello.
I was recently experimenting with a fix that involved ActivateContext and needed to figure out whether it is ok if ActivateContext is called inside ENTER_GL()... LEAVE_GL() (also if recursive ENTER_GL is ok). At first I tried to look for example code in wined3d/surface.c, which seemed to indicate this is ok, because it obviously seems to happen in one or few places. Then I found this
ActivateContext inside ENTER_GL() and LEAVE_GL() is *not* ok, but it happens in quite a few places unfortunately. The problem this causes is stated in this bugreport. ActivateContext can call GDI calls, and they can deadlock if called between ENTER_GL and LEAVE_GL.
The example with BindTexture you gave is the main problem indeed, patches like that are a way forward. However, instead of just adding a LEAVE_GL() and ENTER_GL() it should be checked if this can be avoided by moving code around a bit. Be warned that there are a few other troubles with ActivateContext and gl calls as well, for example fbo setup vs ActivateContext