[Mesa-dev] d3d1x: attempt to fix refcounting of GalliumD3D11DeviceChild objects

Christoph Bumiller e0425955 at student.tuwien.ac.at
Mon Sep 19 02:39:41 PDT 2011

Hi Luca, I've been toying with the d3d1x state tracker lately in order
to make it work properly with the nv50/nvc0 gallium drivers.

I've taken a bit of a shortcut and made it feed SM4 directly to the
driver (I didn't have the nerve to extend TGSI), and got as far as
having your spikysphere demo working (maybe the lighting's still a bit
off though).

When trying to run some native Win32 applications with wine I was
running into random crashes and it turned out that the
GalliumD3D11Screen was being destroyed out of the blue because of a
refcounting problem of the Device.

What's happening is that functions like GetShaderResources only
increased the reference count through the Context's refcnt_ptr but not
the reference count of the device, whereas the Release called by the
application does decrease it each time.

I attached my attempt at fixing this but I'm not sure it's the correct
way to do it, I'd be thankful if you took a look at it.

I needed to add the virtual destructor because if there are no more
external references but still internal ones (like the bound rasterizer
state), unbinding them would only decrease refcnt_ptr's refcount and
destroy the object without releasing the device.

Best regards, Christoph

More information about the mesa-dev mailing list