Re: DDraw: Split up the ddraw refcount
Am Montag 10 Juli 2006 10:47 schrieb Stefan Dösinger: > Here is a patch with the improvement suggestions from AJ. The changes to > the older versions are: > > * Use the counter from InterlockedDecrement to check if the object has to > be destroyed > * Get rid of IDirectDrawImpl::DoNotDestroy > * Minor spelling fixes in the added comments :-) > > The aim of this is to fix the startup Star Wars Episode 1 racer and most > likely Star Wars Jedi Knight 1(Not tested, I do not have this game), and > fix the shutdown of C&C Red Alert. The 2 star wars games depend on the > individual refcounts of the interface versions, while Red Alert depends on > the different palette refcounting behavior in older interface versions. > > This patch also requires the palette refcounting fix for older interfaces > which I will resend too. > > ChangeLog: > Stefan Dösinger: Split up the ddraw refcount Grrr. Got to send another updated patch :-( I accidentally renamed Thunk_IDirect3D_3_Release to Thunk_IDirect3D_1_Release, so the older patch didn't even compile. I wonder how I could run the regression tests and my games with it. The attached patch corrects this wrong numer. 0005-DDraw-Split-the-ddraw-refcount.txt.bz2 Description: BZip2 compressed data pgp5NjjQKmKSW.pgp Description: PGP signature
Re: DDraw: Split up the ddraw refcount
Stefan Dösinger <[EMAIL PROTECTED]> writes: > +if(ref == 0) InterlockedDecrement(&This->numIfaces); > > -/* This is for the dll cleanup code in DllMain() */ > -if(!This->DoNotDestroy) > -IDirectDrawImpl_Destroy(This); > -} > +/* Checks the refcount before actually destroying the object */ > +IDirectDrawImpl_Destroy(This); This isn't thread safe, you should only call Destroy when the InterlockedDecrement returns 0, otherwise there's no point in using interlocked functions at all. Also you should get rid of the DoNotDestroy flag and use the refcount for that. -- Alexandre Julliard [EMAIL PROTECTED]
Re: DDraw: Split up the ddraw refcount
Am Mittwoch 05 Juli 2006 18:27 schrieb Stefan Dösinger: > Am Mittwoch 05 Juli 2006 02:27 schrieb Stefan Dösinger: > > The DirectDraw reference counting is a bit more complex than it seemed at > > first. The unit test in that patch shows that the IDirectDraw, > > IDirectDraw2, IDirectDraw4 and IDirectDraw7 interfaces of one object have > > their own reference count. The object is the same, the test with > > SetCooperativeLevel shows this(Setting a focus window returns an error in > > exclusive mode). Interestingly the IDirect3DX interfaces do not have > > their own refcount, instead they are linked to a DirectDraw interface > > refcount. > > > > This patch splits up the IDirectDrawImpl::ref member in ref7, ref4, ref2 > > and ref1 and changes the AddRef and Release methods accordingly. Of > > course a number of tests to show this behavior are included :-) > > > > I will also send a patch which fixes some reference counting issues with > > Palettes, and both patches depend on each other. So please apply either > > both patches or none of them if one is wrong. > > > > ChangeLog: > > Stefan Dösinger: Split the ddraw refcount > > Here is an updated patch, it implements the destroy condition as suggested > by Rob and adds the accidentally dropped SetCooperativeLevel(NULL, > DDSCL_NORMAL) cooplevel and screen mode restoring call. Oh wait, this is not necessarilly correct. Considered that Direct3D came with DirectX 3.0 (I think) IDirect3D(1) isn't necessarily linked to IDirectDraw(1). I will add some more tests to check for that, do not apply this patch for now pgpiFO78bK8Lm.pgp Description: PGP signature