diff options
author | Marek Olšák <[email protected]> | 2013-03-22 02:39:42 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-03-26 01:28:19 +0100 |
commit | 8ddae684aff5bae3f9bf12b35d938fe53aadc1a8 (patch) | |
tree | 23900c4e4cc6a00fcceca502e670f4b34b6dd60f /src/gallium/winsys | |
parent | 2504380aafe5ff745c87a2e715bc29a20597ebe4 (diff) |
r600g: add a driver query returning the amount of requested VRAM and GTT memory
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 14 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_bo.h | 1 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 15 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 2 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_winsys.h | 8 |
5 files changed, 40 insertions, 0 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index f4ac526ed88..61570d0ee76 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -388,6 +388,11 @@ static void radeon_bo_destroy(struct pb_buffer *_buf) } pipe_mutex_destroy(bo->map_mutex); + + if (bo->initial_domain & RADEON_DOMAIN_VRAM) + bo->rws->allocated_vram -= align(bo->base.size, 4096); + else if (bo->initial_domain & RADEON_DOMAIN_GTT) + bo->rws->allocated_gtt -= align(bo->base.size, 4096); FREE(bo); } @@ -576,6 +581,7 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct pb_manager *_mgr, bo->rws = mgr->rws; bo->handle = args.handle; bo->va = 0; + bo->initial_domain = rdesc->initial_domains; pipe_mutex_init(bo->map_mutex); if (mgr->va) { @@ -608,6 +614,11 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct pb_manager *_mgr, } } + if (rdesc->initial_domains & RADEON_DOMAIN_VRAM) + rws->allocated_vram += align(size, 4096); + else if (rdesc->initial_domains & RADEON_DOMAIN_GTT) + rws->allocated_gtt += align(size, 4096); + return &bo->base; } @@ -931,6 +942,9 @@ done: } } + ws->allocated_vram += align(open_arg.size, 4096); + bo->initial_domain = RADEON_DOMAIN_VRAM; + return (struct pb_buffer*)bo; fail: diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h index 82ea14105df..710a04cdc3d 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h @@ -57,6 +57,7 @@ struct radeon_bo { uint32_t name; uint64_t va; uint64_t va_size; + enum radeon_bo_domain initial_domain; /* how many command streams is this bo referenced in? */ int num_cs_references; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 62ba4b1f713..d1f76431b19 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -483,6 +483,20 @@ static uint64_t radeon_query_timestamp(struct radeon_winsys *rws) return ts; } +static uint64_t radeon_query_value(struct radeon_winsys *rws, + enum radeon_value_id value) +{ + struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws; + + switch (value) { + case RADEON_REQUESTED_VRAM_MEMORY: + return ws->allocated_vram; + case RADEON_REQUESTED_GTT_MEMORY: + return ws->allocated_gtt; + } + return 0; +} + static unsigned hash_fd(void *key) { return pointer_to_intptr(key); @@ -606,6 +620,7 @@ struct radeon_winsys *radeon_drm_winsys_create(int fd) ws->base.surface_init = radeon_drm_winsys_surface_init; ws->base.surface_best = radeon_drm_winsys_surface_best; ws->base.query_timestamp = radeon_query_timestamp; + ws->base.query_value = radeon_query_value; radeon_bomgr_init_functions(ws); radeon_drm_cs_init_functions(ws); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h index 74eb408151b..842579c6138 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h @@ -46,6 +46,8 @@ struct radeon_drm_winsys { int fd; /* DRM file descriptor */ int num_cs; /* The number of command streams created. */ + uint64_t allocated_vram; + uint64_t allocated_gtt; enum radeon_generation gen; struct radeon_info info; diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index c57a87d7a9b..36f1f8e7ec4 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -145,6 +145,11 @@ enum ring_type { RING_LAST, }; +enum radeon_value_id { + RADEON_REQUESTED_VRAM_MEMORY, + RADEON_REQUESTED_GTT_MEMORY, +}; + struct winsys_handle; struct radeon_winsys_cs_handle; @@ -483,6 +488,9 @@ struct radeon_winsys { * \param ws The winsys this function is called from. */ uint64_t (*query_timestamp)(struct radeon_winsys *ws); + + uint64_t (*query_value)(struct radeon_winsys *ws, + enum radeon_value_id value); }; #endif |