diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 7054fb31a29..7daa5319a12 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -930,10 +930,12 @@ llvmpipe_destroy_screen(struct pipe_screen *_screen) close(screen->udmabuf_fd); #endif +#if DETECT_OS_LINUX util_vma_heap_finish(&screen->mem_heap); close(screen->fd_mem_alloc); mtx_destroy(&screen->mem_mutex); +#endif mtx_destroy(&screen->rast_mutex); mtx_destroy(&screen->cs_mutex); FREE(screen); @@ -1175,15 +1177,17 @@ llvmpipe_create_screen(struct sw_winsys *winsys) screen->udmabuf_fd = open("/dev/udmabuf", O_RDWR); #endif - screen->fd_mem_alloc = os_create_anonymous_file(0, "allocation fd"); - (void) mtx_init(&screen->mem_mutex, mtx_plain); - uint64_t alignment; if (!os_get_page_size(&alignment)) alignment = 256; +#if DETECT_OS_LINUX + (void) mtx_init(&screen->mem_mutex, mtx_plain); + util_vma_heap_init(&screen->mem_heap, alignment, UINT64_MAX - alignment); screen->mem_heap.alloc_high = false; + screen->fd_mem_alloc = os_create_anonymous_file(0, "allocation fd"); +#endif snprintf(screen->renderer_string, sizeof(screen->renderer_string), "llvmpipe (LLVM " MESA_LLVM_VERSION_STRING ", %u bits)", diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index 766e64d80e6..2e18da15687 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -79,10 +79,12 @@ struct llvmpipe_screen int udmabuf_fd; #endif +#if DETECT_OS_LINUX int fd_mem_alloc; mtx_t mem_mutex; uint64_t mem_file_size; struct util_vma_heap mem_heap; +#endif }; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 9bd6ce5a4a0..43810016ad2 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -1290,17 +1290,18 @@ llvmpipe_memory_barrier(struct pipe_context *pipe, static struct pipe_memory_allocation * llvmpipe_allocate_memory(struct pipe_screen *_screen, uint64_t size) { - struct llvmpipe_screen *screen = llvmpipe_screen(_screen); struct llvmpipe_memory_allocation *mem = CALLOC_STRUCT(llvmpipe_memory_allocation); uint64_t alignment; if (!os_get_page_size(&alignment)) alignment = 256; - mem->fd = screen->fd_mem_alloc; mem->size = align64(size, alignment); #if DETECT_OS_LINUX + struct llvmpipe_screen *screen = llvmpipe_screen(_screen); + mem->cpu_addr = MAP_FAILED; + mem->fd = screen->fd_mem_alloc; mtx_lock(&screen->mem_mutex); @@ -1330,16 +1331,17 @@ static void llvmpipe_free_memory(struct pipe_screen *pscreen, struct pipe_memory_allocation *pmem) { - struct llvmpipe_screen *screen = llvmpipe_screen(pscreen); struct llvmpipe_memory_allocation *mem = (struct llvmpipe_memory_allocation *)pmem; +#if DETECT_OS_LINUX + struct llvmpipe_screen *screen = llvmpipe_screen(pscreen); + if (mem->fd) { mtx_lock(&screen->mem_mutex); util_vma_heap_free(&screen->mem_heap, mem->offset, mem->size); mtx_unlock(&screen->mem_mutex); } -#if DETECT_OS_LINUX if (mem->cpu_addr != MAP_FAILED) munmap(mem->cpu_addr, mem->size); #else