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
>From c7f38f3a09f457e26736c79bcdf62050226987ce Mon Sep 17 00:00:00 2001 From: Christoph Bumiller <e0425...@student.tuwien.ac.at> Date: Mon, 19 Sep 2011 11:21:38 +0200 Subject: [PATCH] d3d1x: fix refcounting of GalliumD3D11DeviceChild objects --- .../state_trackers/d3d1x/gd3d11/d3d11_objects.h | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h index 7c97632..7b9ee8e 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h @@ -42,6 +42,12 @@ struct GalliumD3D11DeviceChild : public GalliumPrivateDataComObject<Base, dual_r device->AddRef(); } + virtual ~GalliumD3D11DeviceChild() + { + if (device) + device->Release(); + } + /* The purpose of this is to avoid cyclic garbage, since this won't hold * a pointer to the device if it is only held by a pipeline binding in the immediate context * @@ -50,13 +56,11 @@ struct GalliumD3D11DeviceChild : public GalliumPrivateDataComObject<Base, dual_r */ inline ULONG add_ref() { - device->AddRef(); return GalliumPrivateDataComObject<Base, dual_refcnt_t>::add_ref(); } inline ULONG release() { - device->Release(); return GalliumPrivateDataComObject<Base, dual_refcnt_t>::release(); } -- 1.7.3.4
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev