winsys/radeon: track the amount of mapped memory
authorMarek Olšák <marek.olsak@amd.com>
Thu, 4 Aug 2016 23:28:17 +0000 (01:28 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 9 Aug 2016 23:11:10 +0000 (01:11 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_bo.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.h

index 897b5367092efc63d5280f7032f211c2d6aab068..56aab4895405e4dfea434d28911053b597960364 100644 (file)
@@ -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);
 }
 
index 1b32c377452621c7aa53031bc19aacdc28dac27e..b1cc3d50fd8e36ba9c9a2df51f06d461d74e47cc 100644 (file)
@@ -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:
index fdbaebe67b5dd1ecf3b50a1dc690f2786f3ea00d..27fbe906f6abe59db5d704f5c61025e7cbe27478 100644 (file)
@@ -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;