wined3d: Move PreLoad to avoid calling it with gl lock held.
authorAlexander Dorofeyev <alexd4@inbox.lv>
Sun, 6 Apr 2008 21:06:27 +0000 (00:06 +0300)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 7 Apr 2008 19:18:47 +0000 (21:18 +0200)
dlls/wined3d/surface.c

index 97f0438129d285a456e69bc690160778cf884374..733d0954ffe4d5570cc6e415c009f6425a74f4da 100644 (file)
@@ -2642,8 +2642,8 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
 
 
     ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
-    ENTER_GL();
     IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
+    ENTER_GL();
 
     /* TODO: Do we need GL_TEXTURE_2D enabled fpr copyteximage? */
     glEnable(This->glDescription.target);
@@ -2733,14 +2733,20 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
     UINT fbheight = Src->currentDesc.Height;
     GLenum drawBuffer = GL_BACK;
     GLenum texture_target;
+    BOOL noBackBufferBackup;
 
     TRACE("Using hwstretch blit\n");
     /* Activate the Proper context for reading from the source surface, set it up for blitting */
     ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
-    ENTER_GL();
-
     IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
 
+    noBackBufferBackup = !swapchain && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
+    if(!noBackBufferBackup && Src->glDescription.textureName == 0) {
+        /* Get it a description */
+        IWineD3DSurface_PreLoad(SrcSurface);
+    }
+    ENTER_GL();
+
     /* Try to use an aux buffer for drawing the rectangle. This way it doesn't need restoring.
      * This way we don't have to wait for the 2nd readback to finish to leave this function.
      */
@@ -2752,7 +2758,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
         drawBuffer = GL_AUX0;
     }
 
-    if(!swapchain && wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
+    if(noBackBufferBackup) {
         glGenTextures(1, &backup);
         checkGLcall("glGenTextures\n");
         glBindTexture(GL_TEXTURE_2D, backup);
@@ -2762,10 +2768,6 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
         /* Backup the back buffer and copy the source buffer into a texture to draw an upside down stretched quad. If
          * we are reading from the back buffer, the backup can be used as source texture
          */
-        if(Src->glDescription.textureName == 0) {
-            /* Get it a description */
-            IWineD3DSurface_PreLoad(SrcSurface);
-        }
         texture_target = Src->glDescription.target;
         glBindTexture(texture_target, Src->glDescription.textureName);
         checkGLcall("glBindTexture(texture_target, Src->glDescription.textureName)");