Stefan Dösinger : wined3d: Some render target-> texture blit context handling.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 11 08:46:27 CDT 2007


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

Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date:   Sat Jun  9 14:59:15 2007 +0200

wined3d: Some render target->texture blit context handling.

---

 dlls/wined3d/device.c  |   15 ++++++++++++---
 dlls/wined3d/surface.c |   14 ++++----------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 96186d5..f3bf509 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5553,9 +5553,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
     TRACE("src_rect [%u, %u]->[%u, %u]\n", src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2);
     TRACE("dst_rect [%u, %u]->[%u, %u]\n", dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2);
 
-    glDisable(GL_SCISSOR_TEST);
-    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
-
     switch (filter) {
         case WINED3DTEXF_LINEAR:
             gl_filter = GL_LINEAR;
@@ -5571,10 +5568,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
 
     /* Attach src surface to src fbo */
     src_swapchain = get_swapchain(src_surface);
+    ENTER_GL();
     if (src_swapchain) {
         GLenum buffer;
 
         TRACE("Source surface %p is onscreen\n", src_surface);
+        ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD);
 
         GL_EXTCALL(glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0));
         buffer = surface_get_gl_buffer(src_surface, src_swapchain);
@@ -5597,6 +5596,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
         GLenum buffer;
 
         TRACE("Destination surface %p is onscreen\n", dst_surface);
+        ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);
 
         GL_EXTCALL(glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0));
         buffer = surface_get_gl_buffer(dst_surface, dst_swapchain);
@@ -5607,11 +5607,19 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
         dst_rect->y2 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y2;
     } else {
         TRACE("Destination surface %p is offscreen\n", dst_surface);
+
+        /* No src or dst swapchain? Make sure some context is active(multithreading) */
+        if(!src_swapchain) {
+            ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+        }
+
         bind_fbo(iface, GL_DRAW_FRAMEBUFFER_EXT, &This->dst_fbo);
         attach_surface_fbo(This, GL_DRAW_FRAMEBUFFER_EXT, 0, dst_surface);
         glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
         checkGLcall("glDrawBuffer()");
     }
+    glDisable(GL_SCISSOR_TEST);
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
 
     if (flip) {
         GL_EXTCALL(glBlitFramebufferEXT(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
@@ -5636,6 +5644,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
         glDrawBuffer(GL_BACK);
         checkGLcall("glDrawBuffer()");
     }
+    LEAVE_GL();
 }
 
 static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget) {
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 2d3b925..587f41e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2385,6 +2385,7 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
     ENTER_GL();
 
     ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
+    IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
 
     /* Bind the target texture */
     glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName);
@@ -2470,6 +2471,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
     /* Activate the Proper context for reading from the source surface, set it up for blitting */
     ENTER_GL();
     ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
+    IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
 
     /* 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.
@@ -2802,17 +2804,9 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
             /* Destination color key is checked above */
         }
 
-        /* Call preload for the surface to make sure it isn't dirty */
-        if (GL_SUPPORT(ARB_MULTITEXTURE)) {
-            GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
-            checkGLcall("glActiveTextureARB");
-        }
-        IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(0));
-        IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
-
         /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
-            * glCopyTexSubImage is a bit picky about the parameters we pass to it
-            */
+         * glCopyTexSubImage is a bit picky about the parameters we pass to it
+         */
         if(SrcRect) {
             if(SrcRect->top < SrcRect->bottom) {
                 srect.y1 = SrcRect->top;




More information about the wine-cvs mailing list