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 <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38074>
This commit is contained in:
Yiwei Zhang
2025-10-27 23:34:38 -07:00
committed by Marge Bot
parent 8f7543e450
commit ab1902e666
2 changed files with 5 additions and 0 deletions
@@ -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;
@@ -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,
};