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;
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 */
}
if (!new_ptr) {
- intel_bo_unreference(new_bo);
+ intel_bo_unref(new_bo);
return false;
}
else if (!preserve)
FREE(writer->ptr);
- intel_bo_unreference(writer->bo);
+ intel_bo_unref(writer->bo);
writer->size = new_size;
writer->bo = new_bo;
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);
{
struct ilo_query *q = ilo_query(query);
- if (q->bo)
- intel_bo_unreference(q->bo);
-
+ intel_bo_unref(q->bo);
FREE(q);
}
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);
}
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;
}
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;
}
}
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);
static void
buf_destroy(struct ilo_buffer *buf)
{
- intel_bo_unreference(buf->bo);
+ intel_bo_unref(buf->bo);
FREE(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 {
return false;
if (tex_create_bo(tex)) {
- intel_bo_unreference(old_bo);
+ intel_bo_unref(old_bo);
return true;
}
else {
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);
}
}
/* 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;
}
return false;
/* mark signalled */
- intel_bo_unreference(fence->bo);
+ intel_bo_unref(fence->bo);
fence->bo = NULL;
return true;
pipe_reference_init(&fence->reference, 1);
- if (bo)
- intel_bo_reference(bo);
- fence->bo = bo;
+ fence->bo = intel_bo_ref(bo);
return fence;
}
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.
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