On 19 February 2014 19:25, Ken Thomases ken@codeweavers.com wrote:
I think that mostly works, but you'll probably want to clear needs_set in context_set_gl_context() instead of in context_release().
Hmm. The old logic had context_acquire() doing context_set_gl_context() each time if context_enter() had set restore_ctx at the outmost level. I didn't want to change that because I wasn't confident it was superfluous.
If you only clear it in the outer context_release(), inner context_acquire() calls will call context_set_gl_context() without needing to.
I think there's also an argument somewhere that context_update_window() should set needs_set instead of calling context_set_pixel_format() and context_set_gl_context().
Yeah, it could do that. Actually, looking at the current code, context_acquire() calls context_update_window() before context_enter(). Couldn't that screw up context_enter()'s ability to a) notice that it needs to restore the context, or b) record the proper context to restore?
Yeah, I think so.
I have to say that my approach would be to record the state to restore at exactly the place where it is changed. So, the old WGL context and DC would be remembered at the call to wglMakeCurrent() or wglMakeContextCurrentARB(). In my pixel format patch, the old pixel format is remembered at the call to SetPixelFormat(). Etc.
It's conceptually not that different, context_acquire() / context_enter() is the wined3d equivalent of wglMakeCurrent(). The split between context_acquire() and context_enter() may have room for improvement. Also note that some parts are just left over from back when we still had ActivateContext().