diff --git a/src/broadcom/vulkan/v3dv_bo.c b/src/broadcom/vulkan/v3dv_bo.c index f3c819fffc4..c51b1924560 100644 --- a/src/broadcom/vulkan/v3dv_bo.c +++ b/src/broadcom/vulkan/v3dv_bo.c @@ -142,15 +142,17 @@ bo_free(struct v3dv_device *device, if (ret != 0) fprintf(stderr, "close object %d: %s\n", bo->handle, strerror(errno)); - device->bo_count--; - device->bo_size -= bo->size; + if (!bo->is_import) { + device->bo_count--; + device->bo_size -= bo->size; - if (dump_stats) { - fprintf(stderr, "Freed %s%s%dkb:\n", - bo->name ? bo->name : "", - bo->name ? " " : "", - bo->size / 1024); - bo_dump_stats(device); + if (dump_stats) { + fprintf(stderr, "Freed %s%s%dkb:\n", + bo->name ? bo->name : "", + bo->name ? " " : "", + bo->size / 1024); + bo_dump_stats(device); + } } /* Our BO structs are stored in a sparse array in the physical device, @@ -198,9 +200,21 @@ v3dv_bo_init(struct v3dv_bo *bo, bo->name = name; bo->private = private; bo->dumb_handle = -1; + bo->is_import = false; list_inithead(&bo->list_link); } +void +v3dv_bo_init_import(struct v3dv_bo *bo, + uint32_t handle, + uint32_t size, + uint32_t offset, + bool private) +{ + v3dv_bo_init(bo, handle, size, offset, "import", private); + bo->is_import = true; +} + struct v3dv_bo * v3dv_bo_alloc(struct v3dv_device *device, uint32_t size, diff --git a/src/broadcom/vulkan/v3dv_bo.h b/src/broadcom/vulkan/v3dv_bo.h index 191c087dfb4..d7a48234677 100644 --- a/src/broadcom/vulkan/v3dv_bo.h +++ b/src/broadcom/vulkan/v3dv_bo.h @@ -52,6 +52,9 @@ struct v3dv_bo { */ bool private; + /** If this BO has been imported */ + bool is_import; + /** * If this BO was allocated for a swapchain on the display device, the * handle of the dumb BO on that device. @@ -62,6 +65,7 @@ struct v3dv_bo { }; void v3dv_bo_init(struct v3dv_bo *bo, uint32_t handle, uint32_t size, uint32_t offset, const char *name, bool private); +void v3dv_bo_init_import(struct v3dv_bo *bo, uint32_t handle, uint32_t size, uint32_t offset, bool private); struct v3dv_bo *v3dv_bo_alloc(struct v3dv_device *device, uint32_t size, const char *name, bool private); diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 4f3e2dae7b7..b86239d66ec 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -2278,7 +2278,7 @@ device_import_bo(struct v3dv_device *device, assert(*bo); if ((*bo)->refcnt == 0) - v3dv_bo_init(*bo, handle, size, get_offset.offset, "import", false); + v3dv_bo_init_import(*bo, handle, size, get_offset.offset, false); else p_atomic_inc(&(*bo)->refcnt);