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.
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 @@
/* 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 @@
{
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 @@
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 @@
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 @@
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 @@
/* 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;