Stefan Dösinger : wined3d: Unload implicit depth stencil buffers correctly.

Alexandre Julliard julliard at winehq.org
Tue Feb 5 06:34:50 CST 2008


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

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Fri Jan 25 18:10:14 2008 +0100

wined3d: Unload implicit depth stencil buffers correctly.

We have to destroy potential fbo renderbuffers, and make sure the
texture is gone

---

 dlls/wined3d/surface.c |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index cfb47ca..44507e7 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -510,25 +510,43 @@ static void surface_remove_pbo(IWineD3DSurfaceImpl *This) {
 static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
     IWineD3DBaseTexture *texture = NULL;
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
+    renderbuffer_entry_t *entry, *entry2;
     TRACE("(%p)\n", iface);
 
-    /* Default pool resources are supposed to be destroyed before Reset is called.
-     * Implicit resources stay however. So this means we have an implicit render target
-     * or depth stencil, and the content isn't supposed to survive the reset anyway
-     */
     if(This->resource.pool == WINED3DPOOL_DEFAULT) {
-        TRACE("Default pool - nothing to do\n");
-        return;
+        /* Default pool resources are supposed to be destroyed before Reset is called.
+         * Implicit resources stay however. So this means we have an implicit render target
+         * or depth stencil. The content may be destroyed, but we still have to tear down
+         * opengl resources, so we cannot leave early.
+         */
+        IWineD3DSurface_ModifyLocation(iface, SFLAG_INSYSMEM, TRUE);
+    } else {
+        /* Load the surface into system memory */
+        IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
     }
-
-    /* Load the surface into system memory */
-    IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
+    IWineD3DSurface_ModifyLocation(iface, SFLAG_INTEXTURE, FALSE);
+    IWineD3DSurface_ModifyLocation(iface, SFLAG_INDRAWABLE, FALSE);
+    This->Flags &= ~SFLAG_ALLOCATED;
 
     /* Destroy PBOs, but load them into real sysmem before */
     if(This->Flags & SFLAG_PBO) {
         surface_remove_pbo(This);
     }
 
+    /* Destroy fbo render buffers. This is needed for implicit render targets, for
+     * all application-created targets the application has to release the surface
+     * before calling _Reset
+     */
+    LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry) {
+        ENTER_GL();
+        GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
+        LEAVE_GL();
+        list_remove(&entry->entry);
+        HeapFree(GetProcessHeap(), 0, entry);
+    }
+    list_init(&This->renderbuffers);
+    This->current_renderbuffer = NULL;
+
     /* If we're in a texture, the texture name belongs to the texture. Otherwise,
      * destroy it
      */




More information about the wine-cvs mailing list