mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-21 10:18:30 +02:00
radv/amdgpu: add a function to query heap info
To remove the winsys dependency. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41824>
This commit is contained in:
parent
37dca71612
commit
9bbc72f3de
2 changed files with 50 additions and 0 deletions
|
|
@ -374,3 +374,41 @@ fail:
|
|||
ac_drm_device_deinitialize(dev);
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
radv_amdgpu_winsys_query_heap_info(ac_drm_device *dev, struct radeon_winsys_heap_info *heap_info)
|
||||
{
|
||||
struct amdgpu_heap_info heap_vram = {0}, heap_vram_vis = {0}, heap_gtt = {0};
|
||||
struct radv_amdgpu_alloc_tracker *alloc_tracker;
|
||||
int r;
|
||||
|
||||
memset(heap_info, 0, sizeof(*heap_info));
|
||||
|
||||
alloc_tracker = radv_amdgpu_alloc_tracker_acquire(ac_drm_device_get_cookie(dev));
|
||||
if (!alloc_tracker)
|
||||
return -1;
|
||||
|
||||
/* Allocated memory for the current process. */
|
||||
heap_info->allocated_vram = alloc_tracker->allocated_vram;
|
||||
heap_info->allocated_vram_vis = alloc_tracker->allocated_vram_vis;
|
||||
heap_info->allocated_gtt = alloc_tracker->allocated_gtt;
|
||||
|
||||
/* VRAM usage. */
|
||||
r = ac_drm_query_heap_info(dev, AMDGPU_GEM_DOMAIN_VRAM, 0, &heap_vram);
|
||||
if (!r)
|
||||
heap_info->vram_usage = heap_vram.heap_usage;
|
||||
|
||||
/* VRAM visible usage. */
|
||||
r = ac_drm_query_heap_info(dev, AMDGPU_GEM_DOMAIN_VRAM, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, &heap_vram_vis);
|
||||
if (!r)
|
||||
heap_info->vram_vis_usage = heap_vram_vis.heap_usage;
|
||||
|
||||
/* GTT usage. */
|
||||
r = ac_drm_query_heap_info(dev, AMDGPU_GEM_DOMAIN_GTT, 0, &heap_gtt);
|
||||
if (!r)
|
||||
heap_info->gtt_usage = heap_gtt.heap_usage;
|
||||
|
||||
radv_amdgpu_alloc_tracker_release(alloc_tracker);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#define RADV_AMDGPU_WINSYS_PUBLIC_H
|
||||
|
||||
#include "ac_gpu_info.h"
|
||||
#include "ac_linux_drm.h"
|
||||
|
||||
#include "vk_sync.h"
|
||||
|
||||
|
|
@ -27,4 +28,15 @@ struct radeon_winsys_info {
|
|||
|
||||
VkResult radv_amdgpu_winsys_query_info(int fd, uint64_t debug_flags, bool is_virtio, struct radeon_winsys_info *info);
|
||||
|
||||
struct radeon_winsys_heap_info {
|
||||
uint64_t allocated_vram;
|
||||
uint64_t vram_usage;
|
||||
uint64_t allocated_vram_vis;
|
||||
uint64_t vram_vis_usage;
|
||||
uint64_t allocated_gtt;
|
||||
uint64_t gtt_usage;
|
||||
};
|
||||
|
||||
int radv_amdgpu_winsys_query_heap_info(ac_drm_device *dev, struct radeon_winsys_heap_info *heap_info);
|
||||
|
||||
#endif /* RADV_AMDGPU_WINSYS_PUBLIC_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue