return bo;
}
-void radeon_bo_unref(struct radeon_bo *bo)
-{
- struct drm_gem_close args = {};
-
- if (!p_atomic_dec_zero(&bo->ref_count))
- return;
-
- if (bo->name) {
- pipe_mutex_lock(bo->mgr->bo_handles_mutex);
- util_hash_table_remove(bo->mgr->bo_handles,
- (void*)(uintptr_t)bo->name);
- pipe_mutex_unlock(bo->mgr->bo_handles_mutex);
- }
- if (bo->ptr)
- munmap(bo->ptr, bo->size);
-
- /* Close object. */
- args.handle = bo->handle;
- drmIoctl(bo->rws->fd, DRM_IOCTL_GEM_CLOSE, &args);
- pipe_mutex_destroy(bo->map_mutex);
- FREE(bo);
-}
static void radeon_bo_wait(struct r300_winsys_bo *_buf)
{
static void radeon_bo_destroy(struct pb_buffer *_buf)
{
struct radeon_bo *bo = radeon_bo(_buf);
+ struct drm_gem_close args = {};
+
+ if (bo->name) {
+ pipe_mutex_lock(bo->mgr->bo_handles_mutex);
+ util_hash_table_remove(bo->mgr->bo_handles,
+ (void*)(uintptr_t)bo->name);
+ pipe_mutex_unlock(bo->mgr->bo_handles_mutex);
+ }
- radeon_bo_unref(bo);
+ if (bo->ptr)
+ munmap(bo->ptr, bo->size);
+
+ /* Close object. */
+ args.handle = bo->handle;
+ drmIoctl(bo->rws->fd, DRM_IOCTL_GEM_CLOSE, &args);
+ pipe_mutex_destroy(bo->map_mutex);
+ FREE(bo);
}
static unsigned get_pb_usage_from_transfer_flags(enum pipe_transfer_usage usage)
bo->size = size;
pipe_mutex_init(bo->map_mutex);
- radeon_bo_ref(bo);
return &bo->base;
}
bo->handle = open_arg.handle;
bo->size = open_arg.size;
bo->name = whandle->handle;
- radeon_bo_ref(bo);
/* Initialize it. */
pipe_reference_init(&bo->base.base.reference, 1);
uint32_t handle;
uint32_t name;
- int ref_count;
-
/* how many command streams is this bo referenced in? */
int num_cs_references;
struct pb_manager *radeon_bomgr_create(struct radeon_drm_winsys *rws);
void radeon_bomgr_init_functions(struct radeon_drm_winsys *ws);
-void radeon_bo_unref(struct radeon_bo *buf);
-
-
-static INLINE void radeon_bo_ref(struct radeon_bo *bo)
+static INLINE
+void radeon_bo_reference(struct radeon_bo **dst, struct radeon_bo *src)
{
- p_atomic_inc(&bo->ref_count);
+ pb_reference((struct pb_buffer**)dst, (struct pb_buffer*)src);
}
static INLINE struct pb_buffer *
for (i = 0; i < csc->crelocs; i++) {
p_atomic_dec(&csc->relocs_bo[i]->num_cs_references);
- radeon_bo_unref(csc->relocs_bo[i]);
- csc->relocs_bo[i] = NULL;
+ radeon_bo_reference(&csc->relocs_bo[i], NULL);
}
csc->crelocs = 0;
}
/* Initialize the new relocation. */
- radeon_bo_ref(bo);
p_atomic_inc(&bo->num_cs_references);
- csc->relocs_bo[csc->crelocs] = bo;
+ radeon_bo_reference(&csc->relocs_bo[csc->crelocs], bo);
reloc = &csc->relocs[csc->crelocs];
reloc->handle = bo->handle;
reloc->read_domains = rd;