Commit 9d95bd5f4b54a392d97f0b58db8f78d675495544 (which introduced multiple d3d devices per ddraw support) regressed Master Magistrate. The game tries to create a separate d3d device for its popup dialog windows. Previously when it was failing it worked with some fallback path. Now when that succeeds one of the issues that it hits is that while drawing on the child window updating popup dialog it does the draw only once something changed and doesn't present repeatedly. That is done by blitting to primary surface in ddraw, ddraw / wined3d update GL frontbuffer in that case and call glFlush(). The image gets blitted from offscreen client window before the actual image gets there.
Why is the correct solution to modify wglFlush()/wglFinish(), rather than modifying ddraw to do a full present?
GLX_OML_sync_control which is used in wglSwapBuffers is not that useful here because it only allows to wait for swap happen and not for onscreen present resulting from glFinish() or Flush (it allows to wait for the next monitor refresh but it doesn't guarantee that the image is actually presented). Besides, GLX_OML_sync_control is not available on Nvidia. XFlush( gdi_display ) is the fallback path already used in wglSwapBuffers when GLX_OML_sync_control is not available. Besides, we need glFinish() to wait for GL operation complete before blitting in wglFinish().
Why do we need the full glFinish()? glXWaitForSbcOML() is in theory enough—we don't actually need to wait for the whole present to be done; we just need to wait for X11 to be aware of it, so that the following blit works, which is what I understand that our usage of glXWaitForSbcOML() does. I don't have a perfect grasp on this code, but it seems suspicious that we need the full glFinish() in wglFlush() and wglFinish() but not in wglSwapBuffers()—why can't we use the same logic as we use in the latter?