From f85ad92dae82b42983eb8023133a6fe8ced4aa81 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 18 Jan 2024 22:09:19 -0800 Subject: [PATCH] iris: Implement query_memory_info() on discrete cards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This has been stubbed since 2019, but wasn't advertised or implemented. Neither kernel offers us any interface for tracking evictions, but we can at least report the size of various heaps. Fixes various SPECviewperf subtests on Alchemist. Reviewed-by: José Roberto de Souza Part-of: --- src/gallium/drivers/iris/iris_screen.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 0eb54494b25..334fbee39c2 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -304,6 +304,8 @@ iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return true; case PIPE_CAP_UMA: return iris_bufmgr_vram_size(screen->bufmgr) == 0; + case PIPE_CAP_QUERY_MEMORY_INFO: + return iris_bufmgr_vram_size(screen->bufmgr) != 0; case PIPE_CAP_PREFER_BACK_BUFFER_REUSE: return false; case PIPE_CAP_FBFETCH: @@ -683,6 +685,23 @@ static void iris_query_memory_info(struct pipe_screen *pscreen, struct pipe_memory_info *info) { + struct iris_screen *screen = (struct iris_screen *)pscreen; + struct intel_device_info di; + memcpy(&di, screen->devinfo, sizeof(di)); + + if (!intel_device_info_update_memory_info(&di, screen->fd)) + return; + + info->total_device_memory = + (di.mem.vram.mappable.size + di.mem.vram.unmappable.size) / 1024; + info->avail_device_memory = + (di.mem.vram.mappable.free + di.mem.vram.unmappable.free) / 1024; + info->total_staging_memory = di.mem.sram.mappable.size / 1024; + info->avail_staging_memory = di.mem.sram.mappable.free / 1024; + + /* Neither kernel gives us any way to calculate this information */ + info->device_memory_evicted = 0; + info->nr_device_memory_evictions = 0; } static const void *