[dx9-12] Major change to desgin

Alexandre Julliard julliard at winehq.org
Fri Oct 22 17:47:52 CDT 2004

"Ann and Jason Edmeades" <us at the-edmeades.demon.co.uk> writes:

> Ok, so if I put back the IUnknowns, are you happy if the AddRefs in the d3dx
> calls AddRef on the WineD3D version?

I don't really understand why you'd need that.

> The problem I was trying to avoid was someone doing an addref for the
> wined3d object, but not the d3dx equivalent, as there really is a strict
> mapping between instances. If I put back the IUnknown, then addref/release
> in wined3d should NEVER be called from within wined3d - Does this make
> sense?

Well, you have to follow the rules: when a pointer to the interface is
returned you AddRef it, and when you no longer need the pointer you
Release it. If all you ever do is store the pointer in the d3d
interface and release it when the d3d interface is freed, then you'll
never have other AddRef/Release calls. Just don't try to invent new
rules, that won't work right.

> I may have misunderstood what you mean by this paragraph and I think I am
> getting confused. The wined3d layer needs a way of passing back the d3dx
> equivalent, and therefore it needs to store it in the _impl structure. Here,
> I dont care what it is called, but since internally to wined3d it only ever
> needs the IUnknown methods, that does make sense. However, it needs to
> expose it somehow, which is why I added a GetParent call to each of the
> interfaces. I *think* you mean I could define a wined3d interface with just
> that method in, and then have IWineD3D inherit from IWineD3DGetParent
> inherit from IUnknown. If this is right, for a single method is it worth it?

No, it's not IWineD3D that inherits from it, it's the users, so in
this case the d3d8 and d3d9 interfaces. So IWineD3D::CreateDevice will
take a IWineD3DParent* pointer, and IWineD3DDevice::GetParent will
return the same IWineD3DParent*, and the interface that d3d8/d3d9 are
passing as parent needs to implement IWineD3DParent.

If you are sure you'll never want to do anything with the parent other
than AddRef/Release then it can be an IUnknown* instead, but defining
a separate interface lets you add methods later on that will allow
wined3d to call functions in d3d8/d3d9 without having to know about
these dlls.

Alexandre Julliard
julliard at winehq.org

More information about the wine-devel mailing list