ilo: add more convenient intel_bo_{ref,unref}()
They both check for NULL and intel_bo_ref() returns the referenced bo. They replace intel_bo_{reference,unreference}().
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user