From ab1902e6666d758b9f5669d2a3ec6d8338d7372f Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Mon, 27 Oct 2025 23:34:38 -0700 Subject: [PATCH] llvmpipe: add fd type INVALID and ANONYMOUS This is mainly to ensure internal anonymous file based memory allocs do not collide with opaque fd type. Since we are here, add INVALID type and assign to non-Linux internal alloc. Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/llvmpipe/lp_texture.c | 3 +++ src/gallium/drivers/llvmpipe/lp_texture.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 1289ec39991..06df8223413 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -1332,6 +1332,7 @@ llvmpipe_allocate_memory(struct pipe_screen *_screen, uint64_t size) mem->cpu_addr = MAP_FAILED; mem->fd = screen->fd_mem_alloc; + mem->type = LLVMPIPE_MEMORY_FD_TYPE_ANONYMOUS; mtx_lock(&screen->mem_mutex); @@ -1351,6 +1352,8 @@ llvmpipe_allocate_memory(struct pipe_screen *_screen, uint64_t size) mtx_unlock(&screen->mem_mutex); #else mem->cpu_addr = malloc(mem->size); + mem->fd = -1; + mem->type = LLVMPIPE_MEMORY_FD_TYPE_INVALID; #endif return (struct pipe_memory_allocation *)mem; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index e052863678c..e7f1f2be970 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -47,6 +47,8 @@ enum lp_texture_usage enum llvmpipe_memory_fd_type { + LLVMPIPE_MEMORY_FD_TYPE_INVALID, + LLVMPIPE_MEMORY_FD_TYPE_ANONYMOUS, LLVMPIPE_MEMORY_FD_TYPE_OPAQUE, LLVMPIPE_MEMORY_FD_TYPE_DMA_BUF, };