summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2014-07-08 14:03:17 +0800
committerChia-I Wu <[email protected]>2014-07-08 15:00:36 +0800
commit8ff16111eee309652b5409890c42d042e33770e2 (patch)
tree012b146ef746dd30b9917941415470ad185b9b61 /src/gallium/drivers/ilo
parentbbefb15e01e1c16af69646898918982ae00f8c92 (diff)
ilo: fix fence reference counting
The old code was complicated, and was wrong when *ptr is NULL.
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r--src/gallium/drivers/ilo/ilo_screen.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
index a7eaa1b3157..4e4739c4504 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -529,26 +529,23 @@ ilo_fence_reference(struct pipe_screen *screen,
struct pipe_fence_handle **p,
struct pipe_fence_handle *f)
{
- struct ilo_fence **ptr = (struct ilo_fence **) p;
struct ilo_fence *fence = ilo_fence(f);
+ struct ilo_fence *old;
- if (!ptr) {
- /* still need to reference fence */
- if (fence)
- pipe_reference(NULL, &fence->reference);
- return;
+ if (likely(p)) {
+ old = ilo_fence(*p);
+ *p = f;
+ }
+ else {
+ old = NULL;
}
- /* reference fence and dereference the one pointed to by ptr */
- if (*ptr && pipe_reference(&(*ptr)->reference, &fence->reference)) {
- struct ilo_fence *old = *ptr;
-
+ STATIC_ASSERT(&((struct ilo_fence *) NULL)->reference == NULL);
+ if (pipe_reference(&old->reference, &fence->reference)) {
if (old->bo)
intel_bo_unreference(old->bo);
FREE(old);
}
-
- *ptr = fence;
}
static boolean