DDRAW: Releasing attached surfaces

Krzysztof Benkowski toth at smk.gda.pl
Thu Jun 29 09:43:04 CDT 2006


Hello,
In the latest version of wine (0.9.16) there is a regression which makes 
Dune 2000 crash.
After some debugging i found that the problem lays in 
IDirectDrawSurfaceImpl_Release method.
The game (Dune 2000) shows that the assumption that all attached 
surfaces should be destroyed
regardless of their refcount is wrong.

What causes the crash in few words:
- first Dune 2000 creates a surface with a backbuffer
- then it gets the backbuffer interface by GetAttachedSurface method 
(refcount for the backbuffer is incremented)
- it releases the frontbuffer (the backbuffer is destroyed even though 
its refcount is higher than frontbuffer's)
- creates new frontbuffer and an offscreen plain
- when one starts a mission the game tries to use the old backbuffer 
(which is then destroyed) and causes a
page fault

So my fix is rather quick and thus i'm not quite sure if it's correct. 
That's because the game works with it
but when it quits it leaves the backbuffer not released. I don't know if 
it's the game's fault or the fix has to be
done some other way. I've done it this way:

--- surface.c   26 Jun 2006 12:15:20 -0000      1.6
+++ surface.c   29 Jun 2006 14:09:59 -0000
@@ -377,7 +377,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDr
         while( (surf = This->next_complex) )
         {
             This->next_complex = surf->next_complex;  /* Unchain it 
from the complex listing */
-            IDirectDrawSurfaceImpl_Destroy(surf);     /* Destroy it */
+            IDirectDrawSurfaceImpl_Release(surf);     /* Release it */
         }

If you (Stefan probably) need more info about the bug i can provide some 
logs

Krzysiek




More information about the wine-devel mailing list