From 645d395d9af74573ed09223720e799073d34b647 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 5 Aug 2016 01:28:17 +0200 Subject: [PATCH] winsys/radeon: track the amount of mapped memory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 13 ++++++++++++- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 4 ++++ src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index 897b5367092..56aab489540 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -375,8 +375,13 @@ void *radeon_bo_do_map(struct radeon_bo *bo) } bo->ptr = ptr; bo->map_count = 1; - pipe_mutex_unlock(bo->map_mutex); + if (bo->initial_domain & RADEON_DOMAIN_VRAM) + bo->rws->mapped_vram += bo->base.size; + else + bo->rws->mapped_gtt += bo->base.size; + + pipe_mutex_unlock(bo->map_mutex); return bo->ptr; } @@ -479,6 +484,12 @@ static void radeon_bo_unmap(struct pb_buffer *_buf) os_munmap(bo->ptr, bo->base.size); bo->ptr = NULL; + + if (bo->initial_domain & RADEON_DOMAIN_VRAM) + bo->rws->mapped_vram -= bo->base.size; + else + bo->rws->mapped_gtt -= bo->base.size; + pipe_mutex_unlock(bo->map_mutex); } diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 1b32c377452..b1cc3d50fd8 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -603,6 +603,10 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws, return ws->allocated_vram; case RADEON_REQUESTED_GTT_MEMORY: return ws->allocated_gtt; + case RADEON_MAPPED_VRAM: + return ws->mapped_vram; + case RADEON_MAPPED_GTT: + return ws->mapped_gtt; case RADEON_BUFFER_WAIT_TIME_NS: return ws->buffer_wait_time; case RADEON_TIMESTAMP: diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h index fdbaebe67b5..27fbe906f6a 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h @@ -71,6 +71,8 @@ struct radeon_drm_winsys { int num_cs; /* The number of command streams created. */ uint64_t allocated_vram; uint64_t allocated_gtt; + uint64_t mapped_vram; + uint64_t mapped_gtt; uint64_t buffer_wait_time; /* time spent in buffer_wait in ns */ uint64_t num_cs_flushes; -- 2.30.2