d3d8/wined3d [5]: Create implicit surfaces with refcount 0.

Stefan Dösinger stefandoesinger at gmx.at
Wed Nov 15 16:57:33 CST 2006


Am Mittwoch 15 November 2006 23:35 schrieb Markus Amsler:
> Depends on [1].
> This fixes all d3d8 implicit surface refcount problems.

> if (This->parentDevice && ref == 1) {
>     if (implicit) {
>         IUnknown_AddRef(This->parentDevice);
>     } else {
>         /* This can only happen on device/swapchain destruction.
>          * It avoids destructing the device again on release. */
>         This->parentDevice = NULL;
>     }


I do not like the extra if(implicit here). An incorrect test shows that an 
AddRef on any object with refcount == 0 increases the device's refcount, no 
matter if its implicit or not:

CreateTexture(device.., &texture); /* increases device refcount */
AddRef(texture); /* no change in dev refcount*/
Release(texture);
Release(texture); /* device refcount decremented */
AddRef(texture); /* device refcount incremented */
Release(texture); /* decremented again */

Currently our CreateTexture(surface, vertexbuffer, ...) increases the device 
refcount and initializes the refcount to 1. In my eyes it would be cleaner to 
init the refcount of everything to 0, and if the interface is not implicit 
AddRef it(from 0 to 1) in Create*. In AddRef, when increasing the refcount 
from to to 1, AddRef the device.

>     } else {
> 	    /* This can only happen on device/swapchain destruction.
>            * It avoids destructing the device again on release. */
>           This->parentDevice = NULL;
>     }
> }
This looks like pretty obscure magic in AddRef to me :-/ . Wouldn't it be 
cleaner to unset the parent device in d3d8device8::Release?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20061115/09fb88b9/attachment.pgp


More information about the wine-devel mailing list