From 6d605a3dde06ba19e5863a4162d965ad1b97fa78 Mon Sep 17 00:00:00 2001 From: Brais Solla Date: Fri, 12 Sep 2025 12:38:53 +0200 Subject: [PATCH] r300: move r300_query_memory_info to r300_screen.c Part-of: --- src/gallium/drivers/r300/meson.build | 2 -- src/gallium/drivers/r300/r300_meminfo.c | 39 ------------------------- src/gallium/drivers/r300/r300_meminfo.h | 13 --------- src/gallium/drivers/r300/r300_screen.c | 29 +++++++++++++++++- 4 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 src/gallium/drivers/r300/r300_meminfo.c delete mode 100644 src/gallium/drivers/r300/r300_meminfo.h diff --git a/src/gallium/drivers/r300/meson.build b/src/gallium/drivers/r300/meson.build index 0d993457107..402b8d15f88 100644 --- a/src/gallium/drivers/r300/meson.build +++ b/src/gallium/drivers/r300/meson.build @@ -28,8 +28,6 @@ files_r300 = files( 'r300_screen_buffer.h', 'r300_screen.c', 'r300_screen.h', - 'r300_meminfo.c', - 'r300_meminfo.h', 'r300_shader_semantics.h', 'r300_state.c', 'r300_state_derived.c', diff --git a/src/gallium/drivers/r300/r300_meminfo.c b/src/gallium/drivers/r300/r300_meminfo.c deleted file mode 100644 index 804a792d627..00000000000 --- a/src/gallium/drivers/r300/r300_meminfo.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017 Advanced Micro Devices, Inc. - * Copyright 2025 Brais Solla rws; - - info->total_device_memory = rscreen->info.vram_size_kb; - info->total_staging_memory = rscreen->info.gart_size_kb; - - /* The real TTM memory usage is somewhat random, because: - * - * 1) TTM delays freeing memory, because it can only free it after - * fences expire. - * - * 2) The memory usage can be really low if big VRAM evictions are - * taking place, but the real usage is well above the size of VRAM. - * - * Instead, return statistics of this process. - */ - unsigned vram_used = ws->query_value(ws, RADEON_VRAM_USAGE) / 1024; - unsigned gtt_used = ws->query_value(ws, RADEON_GTT_USAGE) / 1024; - - info->avail_device_memory = (vram_used > info->total_device_memory) ? 0 : info->total_device_memory - vram_used; - info->avail_staging_memory = (gtt_used > info->total_staging_memory) ? 0 : info->total_staging_memory - gtt_used; - info->device_memory_evicted = ws->query_value(ws, RADEON_NUM_BYTES_MOVED) / 1024; - info->nr_device_memory_evictions = ws->query_value(ws, RADEON_NUM_EVICTIONS); - -} \ No newline at end of file diff --git a/src/gallium/drivers/r300/r300_meminfo.h b/src/gallium/drivers/r300/r300_meminfo.h deleted file mode 100644 index c296a11f8ce..00000000000 --- a/src/gallium/drivers/r300/r300_meminfo.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2017 Advanced Micro Devices, Inc. - * Copyright 2025 Brais Solla get_fd(rws); } +static void r300_query_memory_info(struct pipe_screen *pscreen, + struct pipe_memory_info *info) +{ + struct r300_screen *rscreen = (struct r300_screen*) pscreen; + struct radeon_winsys *ws = rscreen->rws; + + info->total_device_memory = rscreen->info.vram_size_kb; + info->total_staging_memory = rscreen->info.gart_size_kb; + + /* The real TTM memory usage is somewhat random, because: + * + * 1) TTM delays freeing memory, because it can only free it after + * fences expire. + * + * 2) The memory usage can be really low if big VRAM evictions are + * taking place, but the real usage is well above the size of VRAM. + * + * Instead, return statistics of this process. + */ + unsigned vram_used = ws->query_value(ws, RADEON_VRAM_USAGE) / 1024; + unsigned gtt_used = ws->query_value(ws, RADEON_GTT_USAGE) / 1024; + + info->avail_device_memory = (vram_used > info->total_device_memory) ? 0 : info->total_device_memory - vram_used; + info->avail_staging_memory = (gtt_used > info->total_staging_memory) ? 0 : info->total_staging_memory - gtt_used; + info->device_memory_evicted = ws->query_value(ws, RADEON_NUM_BYTES_MOVED) / 1024; + info->nr_device_memory_evictions = ws->query_value(ws, RADEON_NUM_EVICTIONS); +} + struct pipe_screen* r300_screen_create(struct radeon_winsys *rws, const struct pipe_screen_config *config) {