st/nine: Add parameter to start with bind
authorAxel Davy <davyaxel0@gmail.com>
Sun, 9 Sep 2018 10:36:28 +0000 (12:36 +0200)
committerAxel Davy <davyaxel0@gmail.com>
Tue, 25 Sep 2018 20:05:24 +0000 (22:05 +0200)
Add a parameter to start new object with a bind
instead of a refcount.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
src/gallium/state_trackers/nine/iunknown.c
src/gallium/state_trackers/nine/iunknown.h
src/gallium/state_trackers/nine/nine_helpers.h

index d76d64478969d025a707d635f20bb22c847a90aa..3835651f5367ab5b224580eafc91e86ef35854af 100644 (file)
@@ -34,9 +34,21 @@ HRESULT
 NineUnknown_ctor( struct NineUnknown *This,
                   struct NineUnknownParams *pParams )
 {
-    This->refs = pParams->container ? 0 : 1;
-    This->bind = 0;
-    This->forward = !This->refs;
+    if (pParams->container) {
+        This->refs = 0;
+        This->forward = true;
+        This->bind = 0;
+        assert(!pParams->start_with_bind_not_ref);
+    } else if (pParams->start_with_bind_not_ref) {
+        This->refs = 0;
+        This->forward = false;
+        This->bind = 1;
+    } else {
+        This->refs = 1;
+        This->forward = false;
+        This->bind = 0;
+    }
+
     This->container = pParams->container;
     This->device = pParams->device;
     if (This->refs && This->device)
index f9ce7b50c977e74314b8aa21d07a1381ae7262a4..2f7582ae4774fcb568f29cda72a75a247b5c6f93 100644 (file)
@@ -78,6 +78,7 @@ struct NineUnknownParams
     void (*dtor)(void *data);
     struct NineUnknown *container;
     struct NineDevice9 *device;
+    bool start_with_bind_not_ref;
 };
 
 HRESULT
index b382c5b72b3c8dc86d47f56f7760fe0ae4b5fb06..a0c55bd9eed1ac752fe4b4e497ab85865826b445 100644 (file)
@@ -86,6 +86,7 @@ static inline void _nine_bind(void **dst, void *obj)
         __params.dtor = (void *)Nine##nine##_dtor; \
         __params.container = NULL; \
         __params.device = dev; \
+        __params.start_with_bind_not_ref = false; \
         { \
             HRESULT __hr = Nine##nine##_ctor(__data, &__params, ## __VA_ARGS__); \
             if (FAILED(__hr)) { \
@@ -111,6 +112,7 @@ static inline void _nine_bind(void **dst, void *obj)
         __params.dtor = (void *)Nine##nine##_dtor; \
         __params.container = NULL; \
         __params.device = NULL; \
+        __params.start_with_bind_not_ref = false; \
         { \
             HRESULT __hr = Nine##nine##_ctor(__data, &__params, ## __VA_ARGS__); \
             if (FAILED(__hr)) { \