Henri Verbeet : wined3d: Destroy FBO entries from the context that created them.

Alexandre Julliard julliard at winehq.org
Tue Oct 20 10:33:37 CDT 2009


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Oct 20 11:05:06 2009 +0200

wined3d: Destroy FBO entries from the context that created them.

EXT_framebuffer_object doesn't specify if FBOs are shareable between GL
contexts, but ARB_framebuffer_object explicitly prohibits it.

---

 dlls/wined3d/context.c         |   38 +++++++++++++++++++++++++-------------
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index a96dea4..53997c8 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -440,6 +440,13 @@ static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_
 /* GL locking is done by the caller */
 static void context_apply_fbo_state(struct wined3d_context *context)
 {
+    struct fbo_entry *entry, *entry2;
+
+    LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
+    {
+        context_destroy_fbo_entry(context, entry);
+    }
+
     if (context->render_offscreen)
     {
         context->current_fbo = context_find_fbo_entry(context);
@@ -586,8 +593,6 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource
     {
         case WINED3DRTYPE_SURFACE:
         {
-            ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
-
             for (i = 0; i < This->numContexts; ++i)
             {
                 struct wined3d_context *context = This->contexts[i];
@@ -596,27 +601,27 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource
 
                 if (context->current_rt == (IWineD3DSurface *)resource) context->current_rt = NULL;
 
-                ENTER_GL();
-
                 LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry)
                 {
-                    BOOL destroyed = FALSE;
                     UINT j;
 
-                    for (j = 0; !destroyed && j < GL_LIMITS(buffers); ++j)
+                    if (entry->depth_stencil == (IWineD3DSurface *)resource)
+                    {
+                        list_remove(&entry->entry);
+                        list_add_head(&context->fbo_destroy_list, &entry->entry);
+                        continue;
+                    }
+
+                    for (j = 0; j < GL_LIMITS(buffers); ++j)
                     {
                         if (entry->render_targets[j] == (IWineD3DSurface *)resource)
                         {
-                            context_destroy_fbo_entry(context, entry);
-                            destroyed = TRUE;
+                            list_remove(&entry->entry);
+                            list_add_head(&context->fbo_destroy_list, &entry->entry);
+                            break;
                         }
                     }
-
-                    if (!destroyed && entry->depth_stencil == (IWineD3DSurface *)resource)
-                        context_destroy_fbo_entry(context, entry);
                 }
-
-                LEAVE_GL();
             }
 
             break;
@@ -653,6 +658,12 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
         event_query->context = NULL;
     }
 
+    LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
+    {
+        if (!context->valid) entry->id = 0;
+        context_destroy_fbo_entry(context, entry);
+    }
+
     LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry)
     {
         if (!context->valid) entry->id = 0;
@@ -1292,6 +1303,7 @@ struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceI
     TRACE("Successfully created new context %p\n", ret);
 
     list_init(&ret->fbo_list);
+    list_init(&ret->fbo_destroy_list);
 
     /* Set up the context defaults */
     if (!context_set_current(ret))
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9c4bd5e..a87d755 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1076,6 +1076,7 @@ struct wined3d_context
     /* FBOs */
     UINT                    fbo_entry_count;
     struct list             fbo_list;
+    struct list             fbo_destroy_list;
     struct fbo_entry        *current_fbo;
     GLuint                  src_fbo;
     GLuint                  dst_fbo;




More information about the wine-cvs mailing list