Roderick Colenbrander : wined3d: Flush GL calls after drawing to the drawable. This fixes apps that use multiple GL contexts.

Alexandre Julliard julliard at winehq.org
Tue Nov 13 08:34:38 CST 2007


Module: wine
Branch: master
Commit: 9b0d661e43fdbd2ba08523ea46c9b889e54678f2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9b0d661e43fdbd2ba08523ea46c9b889e54678f2

Author: Roderick Colenbrander <thunderbird2k at gmx.net>
Date:   Thu Nov  8 23:08:07 2007 +0100

wined3d: Flush GL calls after drawing to the drawable. This fixes apps that use multiple GL contexts.

---

 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();
 }
 




More information about the wine-cvs mailing list