From ab6141561dd738e5a501310fa2b3976bb8519ef8 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Mon, 21 Jul 2025 00:24:01 -0700 Subject: [PATCH] lavapipe: use common tracked size and override if needed For lavapipe, there's no need for a separate internally tracked size. Reviewed-by: Konstantin Seurer Part-of: --- src/gallium/frontends/lavapipe/lvp_android.c | 2 +- src/gallium/frontends/lavapipe/lvp_device.c | 5 ++--- src/gallium/frontends/lavapipe/lvp_private.h | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_android.c b/src/gallium/frontends/lavapipe/lvp_android.c index 2332d55eb39..0014b1bb445 100644 --- a/src/gallium/frontends/lavapipe/lvp_android.c +++ b/src/gallium/frontends/lavapipe/lvp_android.c @@ -129,7 +129,7 @@ lvp_import_ahb_memory(struct lvp_device *device, struct lvp_device_memory *mem) if (!result) return VK_ERROR_INVALID_EXTERNAL_HANDLE; - mem->size = size; + mem->vk.size = size; mem->map = device->pscreen->map_memory(device->pscreen, mem->pmem); mem->memory_type = LVP_DEVICE_MEMORY_TYPE_DMA_BUF; diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 0b20599615f..4ad1853474f 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1931,7 +1931,7 @@ set_mem_priority(struct lvp_device_memory *mem, int priority) if (priority > 0) advice |= MADV_WILLNEED; if (advice) - madvise(mem->map, mem->size, advice); + madvise(mem->map, mem->vk.size, advice); } #endif } @@ -1992,7 +1992,6 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory( mem->memory_type = LVP_DEVICE_MEMORY_TYPE_DEFAULT; mem->backed_fd = -1; - mem->size = pAllocateInfo->allocationSize; if (mem->vk.host_ptr) { mem->mem_alloc = (struct llvmpipe_memory_allocation) { @@ -2032,7 +2031,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory( close(import_info->fd); } - mem->size = size; + mem->vk.size = size; mem->map = device->pscreen->map_memory(device->pscreen, mem->pmem); mem->memory_type = dmabuf ? LVP_DEVICE_MEMORY_TYPE_DMA_BUF : LVP_DEVICE_MEMORY_TYPE_OPAQUE_FD; } diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h index 1a61a858287..a3e8a8d39b0 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -244,7 +244,6 @@ struct lvp_device_memory { struct pipe_memory_allocation *pmem; struct llvmpipe_memory_allocation mem_alloc; VkDeviceSize map_size; - VkDeviceSize size; void * map; enum lvp_device_memory_type memory_type; int backed_fd;