[PATCH 4/5] wined3d: Only try to acquire a context in surface_cleanup() if there are GL resources to be destroyed.
Henri Verbeet
hverbeet at codeweavers.com
Wed Aug 4 04:10:26 CDT 2010
The reason we're in surface_cleanup() might for example be that context
creation failed.
---
dlls/wined3d/surface.c | 60 ++++++++++++++++++++++-------------------------
1 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 47282b0..101c8c2 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -36,44 +36,42 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d);
static void surface_cleanup(IWineD3DSurfaceImpl *This)
{
- IWineD3DDeviceImpl *device = This->resource.device;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
- struct wined3d_context *context = NULL;
- renderbuffer_entry_t *entry, *entry2;
-
TRACE("(%p) : Cleaning up.\n", This);
- /* Need a context to destroy the texture. Use the currently active render
- * target, but only if the primary render target exists. Otherwise
- * lastActiveRenderTarget is garbage. When destroying the primary render
- * target, Uninit3D() will activate a context before doing anything. */
- if (device->render_targets && device->render_targets[0])
+ if (This->texture_name || (This->Flags & SFLAG_PBO) || !list_empty(&This->renderbuffers))
{
- context = context_acquire(device, NULL);
- }
+ const struct wined3d_gl_info *gl_info;
+ renderbuffer_entry_t *entry, *entry2;
+ struct wined3d_context *context;
- ENTER_GL();
+ context = context_acquire(This->resource.device, NULL);
+ gl_info = context->gl_info;
- if (This->texture_name)
- {
- /* Release the OpenGL texture. */
- TRACE("Deleting texture %u.\n", This->texture_name);
- glDeleteTextures(1, &This->texture_name);
- }
+ ENTER_GL();
- if (This->Flags & SFLAG_PBO)
- {
- /* Delete the PBO. */
- GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
- }
+ if (This->texture_name)
+ {
+ TRACE("Deleting texture %u.\n", This->texture_name);
+ glDeleteTextures(1, &This->texture_name);
+ }
- LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry)
- {
- gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
- HeapFree(GetProcessHeap(), 0, entry);
- }
+ if (This->Flags & SFLAG_PBO)
+ {
+ TRACE("Deleting PBO %u.\n", This->pbo);
+ GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
+ }
- LEAVE_GL();
+ LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry)
+ {
+ TRACE("Deleting renderbuffer %u.\n", entry->id);
+ gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
+ HeapFree(GetProcessHeap(), 0, entry);
+ }
+
+ LEAVE_GL();
+
+ context_release(context);
+ }
if (This->Flags & SFLAG_DIBSECTION)
{
@@ -92,8 +90,6 @@ static void surface_cleanup(IWineD3DSurfaceImpl *This)
HeapFree(GetProcessHeap(), 0, This->palette9);
resource_cleanup((IWineD3DResource *)This);
-
- if (context) context_release(context);
}
UINT surface_calculate_size(const struct wined3d_format_desc *format_desc, UINT alignment, UINT width, UINT height)
--
1.7.1
More information about the wine-patches
mailing list