[PATCH] Flush GL calls after drawing to the drawable. This fixes apps that use multiple GL contexts. An example of this is bug 9826.

Roderick Colenbrander thunderbird2k at gmx.net
Thu Nov 8 16:08:07 CST 2007


---
 dlls/wined3d/surface.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index d3cbc52..dadb7a0 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3131,6 +3131,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
             checkGLcall("glDisable(GL_ALPHA_TEST)");
         }
 
+        /* Flush in case the drawable is used by multiple GL contexts */
+        if(dstSwapchain && (dstSwapchain->num_contexts >= 2))
+            glFlush();
+
         /* Unbind the texture */
         glBindTexture(GL_TEXTURE_2D, 0);
         checkGLcall("glEnable glBindTexture");
@@ -3481,6 +3485,8 @@ struct coords {
 static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in) {
     struct coords coords[4];
     RECT rect;
+    IWineD3DSwapChain *swapchain = NULL;
+    HRESULT hr;
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
 
     if(rect_in) {
@@ -3602,6 +3608,15 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
         glDisable(GL_TEXTURE_CUBE_MAP_ARB);
         checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
     }
+
+    hr = IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain);
+    if(hr == WINED3D_OK && swapchain) {
+        /* Make sure to flush the buffers. This is needed in apps like Red Alert II and Tiberian SUN that use multiple WGL contexts. */
+        if(((IWineD3DSwapChainImpl*)swapchain)->num_contexts >= 2)
+            glFlush();
+
+        IWineD3DSwapChain_Release(swapchain);
+    }
     LEAVE_GL();
 }
 
-- 
1.5.2.4


--========GMX244481194620755793996--



More information about the wine-patches mailing list