Allan Tong : wined3d: Call ActivateContext before any gl call in IWineD3DSurfaceImpl_Release.

Alexandre Julliard julliard at winehq.org
Fri Apr 4 06:21:50 CDT 2008


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

Author: Allan Tong <actong88 at gmail.com>
Date:   Thu Apr  3 21:06:48 2008 -0400

wined3d: Call ActivateContext before any gl call in IWineD3DSurfaceImpl_Release.

---

 dlls/wined3d/surface.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 641c249..ac4224e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -423,29 +423,31 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
         renderbuffer_entry_t *entry, *entry2;
         TRACE("(%p) : cleaning up\n", This);
 
-        if (This->glDescription.textureName != 0) { /* release the openGL texture.. */
-
-            /* 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, see above.
-             * When destroying the primary rt, Uninit3D will activate a context before doing anything
-             */
-            if(device->render_targets && device->render_targets[0]) {
-                ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
-            }
+        /* 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, see above.
+         * When destroying the primary rt, Uninit3D will activate a context before doing anything
+         */
+        if(device->render_targets && device->render_targets[0]) {
+            ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+        }
 
+        ENTER_GL();
+        if (This->glDescription.textureName != 0) { /* release the openGL texture.. */
             TRACE("Deleting texture %d\n", This->glDescription.textureName);
-            ENTER_GL();
             glDeleteTextures(1, &This->glDescription.textureName);
-            LEAVE_GL();
         }
 
         if(This->Flags & SFLAG_PBO) {
             /* Delete the PBO */
-            ENTER_GL();
             GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
-            LEAVE_GL();
         }
 
+        LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry) {
+            GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
+            HeapFree(GetProcessHeap(), 0, entry);
+        }
+        LEAVE_GL();
+
         if(This->Flags & SFLAG_DIBSECTION) {
             /* Release the DC */
             SelectObject(This->hDC, This->dib.holdbitmap);
@@ -463,13 +465,6 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
         if(iface == device->ddraw_primary)
             device->ddraw_primary = NULL;
 
-        ENTER_GL();
-        LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry) {
-            GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
-            HeapFree(GetProcessHeap(), 0, entry);
-        }
-        LEAVE_GL();
-
         TRACE("(%p) Released\n", This);
         HeapFree(GetProcessHeap(), 0, This);
 




More information about the wine-cvs mailing list