summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/ilo/ilo_builder.c13
-rw-r--r--src/gallium/drivers/ilo/ilo_cp.c6
-rw-r--r--src/gallium/drivers/ilo/ilo_query.c4
-rw-r--r--src/gallium/drivers/ilo/ilo_render.c4
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.c17
-rw-r--r--src/gallium/drivers/ilo/ilo_screen.c14
-rw-r--r--src/gallium/drivers/ilo/intel_winsys.h10
-rw-r--r--src/gallium/winsys/intel/drm/intel_drm_winsys.c14
8 files changed, 35 insertions, 47 deletions
diff --git a/src/gallium/drivers/ilo/ilo_builder.c b/src/gallium/drivers/ilo/ilo_builder.c
index 52c4b218435..56920e5bfb6 100644
--- a/src/gallium/drivers/ilo/ilo_builder.c
+++ b/src/gallium/drivers/ilo/ilo_builder.c
@@ -99,10 +99,8 @@ ilo_builder_writer_reset(struct ilo_builder *builder,
writer->ptr = NULL;
}
- if (writer->bo) {
- intel_bo_unreference(writer->bo);
- writer->bo = NULL;
- }
+ intel_bo_unref(writer->bo);
+ writer->bo = NULL;
writer->used = 0;
writer->stolen = 0;
@@ -168,8 +166,7 @@ ilo_builder_writer_alloc_and_map(struct ilo_builder *builder,
bo = alloc_writer_bo(builder->winsys, which, writer->size);
if (bo) {
- if (writer->bo)
- intel_bo_unreference(writer->bo);
+ intel_bo_unref(writer->bo);
writer->bo = bo;
} else if (writer->bo) {
/* reuse the old bo */
@@ -273,7 +270,7 @@ ilo_builder_writer_grow(struct ilo_builder *builder,
}
if (!new_ptr) {
- intel_bo_unreference(new_bo);
+ intel_bo_unref(new_bo);
return false;
}
@@ -282,7 +279,7 @@ ilo_builder_writer_grow(struct ilo_builder *builder,
else if (!preserve)
FREE(writer->ptr);
- intel_bo_unreference(writer->bo);
+ intel_bo_unref(writer->bo);
writer->size = new_size;
writer->bo = new_bo;
diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c
index f78fd1f62f9..9d2dffd5e16 100644
--- a/src/gallium/drivers/ilo/ilo_cp.c
+++ b/src/gallium/drivers/ilo/ilo_cp.c
@@ -163,10 +163,8 @@ ilo_cp_submit_internal(struct ilo_cp *cp)
if (!err) {
bool guilty;
- if (cp->last_submitted_bo)
- intel_bo_unreference(cp->last_submitted_bo);
- cp->last_submitted_bo = bo;
- intel_bo_reference(cp->last_submitted_bo);
+ intel_bo_unref(cp->last_submitted_bo);
+ cp->last_submitted_bo = intel_bo_ref(bo);
guilty = ilo_cp_detect_hang(cp);
diff --git a/src/gallium/drivers/ilo/ilo_query.c b/src/gallium/drivers/ilo/ilo_query.c
index 942df2d683d..7a2e5030e00 100644
--- a/src/gallium/drivers/ilo/ilo_query.c
+++ b/src/gallium/drivers/ilo/ilo_query.c
@@ -107,9 +107,7 @@ ilo_destroy_query(struct pipe_context *pipe, struct pipe_query *query)
{
struct ilo_query *q = ilo_query(query);
- if (q->bo)
- intel_bo_unreference(q->bo);
-
+ intel_bo_unref(q->bo);
FREE(q);
}
diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c
index c5492562de0..a6614f1508a 100644
--- a/src/gallium/drivers/ilo/ilo_render.c
+++ b/src/gallium/drivers/ilo/ilo_render.c
@@ -154,9 +154,7 @@ ilo_render_create(struct ilo_builder *builder)
void
ilo_render_destroy(struct ilo_render *render)
{
- if (render->workaround_bo)
- intel_bo_unreference(render->workaround_bo);
-
+ intel_bo_unref(render->workaround_bo);
FREE(render);
}
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 9f4ee4012c1..7815354be01 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -171,7 +171,7 @@ tex_import_handle(struct ilo_texture *tex,
if (!ilo_layout_update_for_imported_bo(&tex->layout,
winsys_to_surface_tiling(tiling), pitch)) {
ilo_err("imported handle has incompatible tiling/pitch\n");
- intel_bo_unreference(tex->bo);
+ intel_bo_unref(tex->bo);
tex->bo = NULL;
return false;
}
@@ -197,7 +197,7 @@ tex_create_bo(struct ilo_texture *tex)
surface_to_winsys_tiling(tex->layout.tiling);
if (intel_bo_set_tiling(bo, tiling, tex->layout.bo_stride)) {
- intel_bo_unreference(bo);
+ intel_bo_unref(bo);
bo = NULL;
}
}
@@ -278,14 +278,11 @@ tex_create_mcs(struct ilo_texture *tex)
static void
tex_destroy(struct ilo_texture *tex)
{
- if (tex->aux_bo)
- intel_bo_unreference(tex->aux_bo);
-
if (tex->separate_s8)
tex_destroy(tex->separate_s8);
- if (tex->bo)
- intel_bo_unreference(tex->bo);
+ intel_bo_unref(tex->aux_bo);
+ intel_bo_unref(tex->bo);
tex_free_slices(tex);
FREE(tex);
@@ -418,7 +415,7 @@ buf_create_bo(struct ilo_buffer *buf)
static void
buf_destroy(struct ilo_buffer *buf)
{
- intel_bo_unreference(buf->bo);
+ intel_bo_unref(buf->bo);
FREE(buf);
}
@@ -554,7 +551,7 @@ ilo_buffer_rename_bo(struct ilo_buffer *buf)
struct intel_bo *old_bo = buf->bo;
if (buf_create_bo(buf)) {
- intel_bo_unreference(old_bo);
+ intel_bo_unref(old_bo);
return true;
}
else {
@@ -573,7 +570,7 @@ ilo_texture_rename_bo(struct ilo_texture *tex)
return false;
if (tex_create_bo(tex)) {
- intel_bo_unreference(old_bo);
+ intel_bo_unref(old_bo);
return true;
}
else {
diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
index c9577c8be41..bf0a84a44eb 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -600,15 +600,13 @@ ilo_fence_reference(struct pipe_screen *screen,
if (likely(p)) {
old = ilo_fence(*p);
*p = f;
- }
- else {
+ } else {
old = NULL;
}
STATIC_ASSERT(&((struct ilo_fence *) NULL)->reference == NULL);
if (pipe_reference(&old->reference, &fence->reference)) {
- if (old->bo)
- intel_bo_unreference(old->bo);
+ intel_bo_unref(old->bo);
FREE(old);
}
}
@@ -621,7 +619,7 @@ ilo_fence_signalled(struct pipe_screen *screen,
/* mark signalled if the bo is idle */
if (fence->bo && !intel_bo_is_busy(fence->bo)) {
- intel_bo_unreference(fence->bo);
+ intel_bo_unref(fence->bo);
fence->bo = NULL;
}
@@ -645,7 +643,7 @@ ilo_fence_finish(struct pipe_screen *screen,
return false;
/* mark signalled */
- intel_bo_unreference(fence->bo);
+ intel_bo_unref(fence->bo);
fence->bo = NULL;
return true;
@@ -666,9 +664,7 @@ ilo_fence_create(struct pipe_screen *screen, struct intel_bo *bo)
pipe_reference_init(&fence->reference, 1);
- if (bo)
- intel_bo_reference(bo);
- fence->bo = bo;
+ fence->bo = intel_bo_ref(bo);
return fence;
}
diff --git a/src/gallium/drivers/ilo/intel_winsys.h b/src/gallium/drivers/ilo/intel_winsys.h
index 77eb030efad..afd038c45f3 100644
--- a/src/gallium/drivers/ilo/intel_winsys.h
+++ b/src/gallium/drivers/ilo/intel_winsys.h
@@ -203,17 +203,17 @@ intel_winsys_decode_bo(struct intel_winsys *winsys,
struct intel_bo *bo, int used);
/**
- * Increase the reference count of \p bo.
+ * Increase the reference count of \p bo. No-op when \p bo is NULL.
*/
-void
-intel_bo_reference(struct intel_bo *bo);
+struct intel_bo *
+intel_bo_ref(struct intel_bo *bo);
/**
* Decrease the reference count of \p bo. When the reference count reaches
- * zero, \p bo is destroyed.
+ * zero, \p bo is destroyed. No-op when \p bo is NULL.
*/
void
-intel_bo_unreference(struct intel_bo *bo);
+intel_bo_unref(struct intel_bo *bo);
/**
* Set the tiling of \p bo. The info is used by GTT mapping and bo export.
diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
index d05e0362a6c..b5ffceb7e65 100644
--- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c
+++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
@@ -464,16 +464,20 @@ intel_winsys_decode_bo(struct intel_winsys *winsys,
intel_bo_unmap(bo);
}
-void
-intel_bo_reference(struct intel_bo *bo)
+struct intel_bo *
+intel_bo_ref(struct intel_bo *bo)
{
- drm_intel_bo_reference(gem_bo(bo));
+ if (bo)
+ drm_intel_bo_reference(gem_bo(bo));
+
+ return bo;
}
void
-intel_bo_unreference(struct intel_bo *bo)
+intel_bo_unref(struct intel_bo *bo)
{
- drm_intel_bo_unreference(gem_bo(bo));
+ if (bo)
+ drm_intel_bo_unreference(gem_bo(bo));
}
int