http://bugs.winehq.org/show_bug.cgi?id=23621
Summary: DDraw surface reference counting doesn't match Windows (causes Recoil to fail) Product: Wine Version: unspecified Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: directx-ddraw AssignedTo: wine-bugs@winehq.org ReportedBy: kazade@gmail.com
I just realized there is no bug report covering this issue.
DirectDraw surfaces (and other COM interfaces) maintain a reference count so that they are destroyed when they are no longer in use. The refcount is returned by the IUnknown_Release function. Unfortunately some games base logic on the value returned by IDirectDrawSurface_Release. Specifically they sometimes (wrongly) expect the return to be zero.
Something like:
if(IDirectDrawSurface_Release(surf)) { //Bail out }
We can test this by forcing DDS_Release to return zero. One game that is affected is Recoil which complains about not being to set the video mode.
The difference between Wine's implementation and the Windows implementation is Windows maintains a refcount for each surface interface version (1, 2, 3, 4 and 7) whereas Wine has one reference count across all versions. There are tests in dlls/ddraw/dsurface.c that confirm the Windows behaviour. To fix this issue the reference counting needs to be split, which requires a lot of changes (as versions 1, 2 and 3 all share the same thunks).
http://bugs.winehq.org/show_bug.cgi?id=23621
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.2-rc7
--- Comment #1 from Dmitry Timoshkov dmitry@codeweavers.com 2010-07-12 04:49:42 --- Do you have a test case?
http://bugs.winehq.org/show_bug.cgi?id=23621
--- Comment #2 from Luke Benstead kazade@gmail.com 2010-08-11 03:56:52 --- Sorry Dmitry I missed your comment. My tests were committed to Wine some time ago. They exist in /dlls/ddraw/tests/dsurface.c
http://bugs.winehq.org/show_bug.cgi?id=23621
Benjamin Debski benjamin.debski@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |benjamin.debski@gmail.com
--- Comment #3 from Benjamin Debski benjamin.debski@gmail.com 2011-01-14 18:09:11 CST --- Present in Wine 1.3.11
http://bugs.winehq.org/show_bug.cgi?id=23621
Ričardas Barkauskas miegalius@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |miegalius@gmail.com
--- Comment #4 from Ričardas Barkauskas miegalius@gmail.com 2011-06-30 14:31:25 CDT --- This should be fixed in latest git and I can run Recoil demo just fine. Please test if it works for you.
http://bugs.winehq.org/show_bug.cgi?id=23621
Luke Benstead kazade@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #5 from Luke Benstead kazade@gmail.com 2011-08-05 09:07:58 CDT --- Yep, all fixed. Nice work! Thanks to whoever took over from my failed attempt over a year ago :)
http://bugs.winehq.org/show_bug.cgi?id=23621
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #6 from Alexandre Julliard julliard@winehq.org 2011-08-05 12:39:19 CDT --- Closing bugs fixed in 1.3.26.
http://bugs.winehq.org/show_bug.cgi?id=23621
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|directx-ddraw |directx-d3d