diff options
author | Axel Davy <[email protected]> | 2016-12-03 19:37:06 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2016-12-20 23:47:08 +0100 |
commit | 2fc8ef1401d455e3861bb233f09de4158d56a6be (patch) | |
tree | 9675afa035dd36c08b4279b60eb8b560c2522fac /src/gallium/state_trackers | |
parent | 098ba64c4c2e15defb469b791fb3e88f89ae8759 (diff) |
st/nine: Comment and simplify iunknown
The behaviour is a bit less obscure now.
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/nine/iunknown.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/iunknown.h | 30 |
2 files changed, 18 insertions, 21 deletions
diff --git a/src/gallium/state_trackers/nine/iunknown.c b/src/gallium/state_trackers/nine/iunknown.c index 28e475659f4..eae4997aa1c 100644 --- a/src/gallium/state_trackers/nine/iunknown.c +++ b/src/gallium/state_trackers/nine/iunknown.c @@ -110,9 +110,6 @@ NineUnknown_AddRef( struct NineUnknown *This ) if (r == 1) { if (This->device) NineUnknown_AddRef(NineUnknown(This->device)); - /* This shouldn't be necessary: - if (This->container) - NineUnknown_Bind(NineUnknown(This->container)); */ } return r; } @@ -130,10 +127,8 @@ NineUnknown_Release( struct NineUnknown *This ) if (NineUnknown_Release(NineUnknown(This->device)) == 0) return r; /* everything's gone */ } - if (This->container) { - /* NineUnknown_Unbind(NineUnknown(This->container)); */ - } else - if (This->bind == 0) { + /* Containers (here with !forward) take care of item destruction */ + if (!This->container && This->bind == 0) { This->dtor(This); } } diff --git a/src/gallium/state_trackers/nine/iunknown.h b/src/gallium/state_trackers/nine/iunknown.h index dd1dab9ab95..f827b138b52 100644 --- a/src/gallium/state_trackers/nine/iunknown.h +++ b/src/gallium/state_trackers/nine/iunknown.h @@ -49,7 +49,12 @@ struct NineUnknown int32_t bind; /* internal bind count */ boolean forward; /* whether to forward references to the container */ - struct NineUnknown *container; /* referenced if (refs | bind) */ + /* container: for surfaces and volumes only. + * Can be a texture, a volume texture or a swapchain. + * forward is set to false for the swapchain case. + * Refs are passed to the container if forward is set. + * The container has bind increased if the object has non null bind. */ + struct NineUnknown *container; struct NineDevice9 *device; /* referenced if (refs) */ const GUID **guids; /* for QueryInterface */ @@ -130,10 +135,10 @@ NineUnknown_Bind( struct NineUnknown *This ) { UINT b = p_atomic_inc_return(&This->bind); assert(b); - if (b == 1 && This->container) { - if (This->container != NineUnknown(This->device)) - NineUnknown_Bind(This->container); - } + + if (b == 1 && This->container) + NineUnknown_Bind(This->container); + return b; } @@ -141,15 +146,12 @@ static inline UINT NineUnknown_Unbind( struct NineUnknown *This ) { UINT b = p_atomic_dec_return(&This->bind); - if (!b) { - if (This->container) { - if (This->container != NineUnknown(This->device)) - NineUnknown_Unbind(This->container); - } else - if (This->refs == 0) { - This->dtor(This); - } - } + + if (b == 0 && This->container) + NineUnknown_Unbind(This->container); + else if (b == 0 && This->refs == 0) + This->dtor(This); + return b; } |