diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 52e22f4e1df..c1ebecd88f1 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -6,4 +6,5 @@ VK_ARM_shader_core_builtins on panvk VK_KHR_shader_untyped_pointers on anv cl_ext_immutable_memory_objects VK_KHR_video_encode_intra_refresh on radv -VK_KHR_video_encode_quantization_map on radv \ No newline at end of file +VK_KHR_video_encode_quantization_map on radv +GL_ATI_meminfo and GL_NVX_gpu_memory_info on r300 diff --git a/src/gallium/drivers/r300/meson.build b/src/gallium/drivers/r300/meson.build index 402b8d15f88..0d993457107 100644 --- a/src/gallium/drivers/r300/meson.build +++ b/src/gallium/drivers/r300/meson.build @@ -28,6 +28,8 @@ 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 new file mode 100644 index 00000000000..804a792d627 --- /dev/null +++ b/src/gallium/drivers/r300/r300_meminfo.c @@ -0,0 +1,39 @@ +/* + * 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 new file mode 100644 index 00000000000..c296a11f8ce --- /dev/null +++ b/src/gallium/drivers/r300/r300_meminfo.h @@ -0,0 +1,13 @@ +/* + * Copyright 2017 Advanced Micro Devices, Inc. + * Copyright 2025 Brais Solla clip_halfz = true; caps->allow_mapped_buffers_during_execution = true; caps->legacy_math_rules = true; + caps->query_memory_info = true; caps->texture_transfer_modes = PIPE_TEXTURE_TRANSFER_BLIT; @@ -691,6 +693,7 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws, r300screen->screen.context_create = r300_create_context; r300screen->screen.fence_reference = r300_fence_reference; r300screen->screen.fence_finish = r300_fence_finish; + r300screen->screen.query_memory_info = r300_query_memory_info; r300screen->screen.nir_options[MESA_SHADER_VERTEX] = !r300screen->caps.has_tcl ? &gallivm_compiler_options :