d3d1x: fix refcounting of GalliumD3D11DeviceChild objects
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 12 Oct 2011 19:08:40 +0000 (21:08 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 21 Oct 2011 21:00:37 +0000 (23:00 +0200)
An external Release would have lowered the device reference count,
but an internal reference in the context does not raise it (by
design).

src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h

index 488539f1bbe2524ee90dab06fae8628b32c7a151..7e4ea1385bc268b1e8920b0fcf8686e3110a0b73 100644 (file)
@@ -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();
        }