Third try, this time without the incomplete FBO error in the ddraw
tests.  With this set of patches, all D3D tests should pass with FBO
offscreen rendering.

 - Allan
From d8e8ac26c66f3c4b822604c2c634ad9f492da907 Mon Sep 17 00:00:00 2001
From: Allan Tong <[EMAIL PROTECTED]>
Date: Thu, 13 Dec 2007 22:54:40 -0500
Subject: wined3d: Activate GL context before making any GL calls in stretch_rect_fbo.

---
 dlls/wined3d/device.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5cf9cef..bdf290f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -6297,15 +6297,27 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
             break;
     }
 
-    /* Attach src surface to src fbo */
     src_swapchain = get_swapchain(src_surface);
+    dst_swapchain = get_swapchain(dst_surface);
+
+    /* Activate GL context for onscreen surface.  If there is no onscreen surface, then just make sure
+       there is a GL context. */
+    if (src_swapchain) {
+        ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD);
+    } else if (dst_swapchain) {
+        ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);
+    } else {
+        ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+    }
+
+    ENTER_GL();
+
+    /* Attach src surface to src fbo */
     if (src_swapchain) {
         GLenum buffer;
 
         TRACE("Source surface %p is onscreen\n", src_surface);
-        ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD);
 
-        ENTER_GL();
         GL_EXTCALL(glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0));
         buffer = surface_get_gl_buffer(src_surface, src_swapchain);
         glReadBuffer(buffer);
@@ -6315,23 +6327,19 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
         src_rect->y2 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y2;
     } else {
         TRACE("Source surface %p is offscreen\n", src_surface);
-        ENTER_GL();
+
         bind_fbo(iface, GL_READ_FRAMEBUFFER_EXT, &This->src_fbo);
         attach_surface_fbo(This, GL_READ_FRAMEBUFFER_EXT, 0, src_surface);
         glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
         checkGLcall("glReadBuffer()");
     }
-    LEAVE_GL();
 
     /* Attach dst surface to dst fbo */
-    dst_swapchain = get_swapchain(dst_surface);
     if (dst_swapchain) {
         GLenum buffer;
 
         TRACE("Destination surface %p is onscreen\n", dst_surface);
-        ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);
 
-        ENTER_GL();
         GL_EXTCALL(glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0));
         buffer = surface_get_gl_buffer(dst_surface, dst_swapchain);
         glDrawBuffer(buffer);
@@ -6342,12 +6350,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
     } 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);
-        }
-
-        ENTER_GL();
         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);
-- 
1.5.2.5



Reply via email to