Re : [DDRAW] Only detach surfaces when releasing a non-texture surface attached to a complex root.

Elie Morisse lachienne at wanadoo.fr
Mon Aug 28 04:04:22 CDT 2006


Le 27.08.2006 21:55:29, Stefan Dösinger a écrit :
> Just asking, does this game hit the This->first_attached != This case? This 
> shouldn't happen, I suspect that the refcounting issue is somewhere else. 
> Also the This->first_complex == This check should always return true in 
> theory.
> 
> Can you send me a +ddraw,+d3d7 trace of the game, with and without your
patch?
> 
> 

The patch is 2 week-old, but now I remember, look :-o :

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 587a3e9..764621c 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -300,7 +300,19 @@ IDirectDrawSurfaceImpl_Release(IDirectDr
          */
         if( (This->first_complex != This) &&
!(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
         {
+            static BOOL ADDREF = TRUE;
             FIXME("(%p) Destroying a surface which is a attached to a complex
root %p\n", This, This->first_complex);
+            if (ADDREF) {
+                ADDREF = FALSE;
+                IDirectDrawSurface_AddRef(iface);
+                IDirectDrawSurface_AddRef(iface);
+                IDirectDrawSurface_AddRef(iface);
+                IDirectDrawSurface_AddRef(iface);
+                IDirectDrawSurface_AddRef(iface);
+                IDirectDrawSurface_AddRef(iface);
+                IDirectDrawSurface_AddRef(iface);
+                return This->ref;
+            }
         }
         ddraw = This->ddraw;

With this hack I get :

trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 2
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 1
fixme:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) Destroying a surface
which is a attached to a complex root 0x158170
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 0
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 1
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 2
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 3
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 4
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 5
trace:ddraw:IDirectDrawSurfaceImpl_AddRef (0x1ab828) : AddRef increasing from 6
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 7
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 6
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 5
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 4
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 3
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 2
trace:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) : Releasing from 1
fixme:ddraw:IDirectDrawSurfaceImpl_Release (0x1ab828) Destroying a surface
which is a attached to a complex root 0x158170

0x1ab828 is the backbuffer, and the Release calls are externals :

Backtrace:
=>1 0x7ea29a2e IDirectDrawSurfaceImpl_Release+0x9e(iface=0x1ab828)
[/home/elie/Projets/wine/wine-git/dlls/ddraw/surface.c:401] in ddraw
(0x7ea29a2e)
  2 0x00432881 in runtime (+0x32881) (0x00432881)
  3 0x00410b38 in runtime (+0x10b38) (0x00410b38)

This is indeed a weird behaviour but afaiu we should not destroy the backbuffer
( or at least detach it from the complex root, but I don't think this is
necessary )



More information about the wine-devel mailing list