WineD3D refcounting fun part II :)

H. Verbeet hverbeet at
Fri Feb 24 06:47:57 CST 2006

On 24/02/06, Robert Shearman <rob at> wrote:
> I am not at all familiar with the wined3d code, but from what I've seen
> discussed here it would seem that wined3d shouldn't keep references to
> any objects. Instead the other objects should release the corresponding
> wined3d object when they are destroyed.

I don't think it does, generally. d3d8/9 objects usually contain a
wined3d object that they wrap, and when the reference count of the
d3d8/9 object reaches 0 it releases its wined3d object. That works
fine as long as the is no relation between the wined3d objects. The
moment a wined3d object keeps a reference to another wined3d object
there is a problem though, because the d3d8/9 object that wraps that
object can be released while there are wined3d objects that still keep
a reference to that wined3d object.

What I mentioned to Roderick on IRC was not really doing refcounts on
wined3d objects, but on the wrapper objects instead. Essentially
calling AddRef on a wined3d surface would just increase the reference
count on the d3d8/9 surface. When the d3d8/9 object's refcount reaches
0 it just calls the wined3d object's cleanup function directly instead
of the release.

>From Roderick's post I don't get the impression that that particular
issue is the problem here though.

More information about the wine-devel mailing list