gallium/radeon: add VRAM-vis-usage HUD query
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 25 Jan 2017 15:56:46 +0000 (16:56 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 26 Jan 2017 18:40:52 +0000 (19:40 +0100)
This new query returns the current visible usage of VRAM accessed
by the CPU. It will return 0 on radeon because it's unimplemented.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeon/r600_query.h
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index 96157cd..d4e4130 100644 (file)
@@ -71,6 +71,7 @@ static enum radeon_value_id winsys_id_from_type(unsigned type)
        case R600_QUERY_NUM_BYTES_MOVED: return RADEON_NUM_BYTES_MOVED;
        case R600_QUERY_NUM_EVICTIONS: return RADEON_NUM_EVICTIONS;
        case R600_QUERY_VRAM_USAGE: return RADEON_VRAM_USAGE;
+       case R600_QUERY_VRAM_VIS_USAGE: return RADEON_VRAM_VIS_USAGE;
        case R600_QUERY_GTT_USAGE: return RADEON_GTT_USAGE;
        case R600_QUERY_GPU_TEMPERATURE: return RADEON_GPU_TEMPERATURE;
        case R600_QUERY_CURRENT_GPU_SCLK: return RADEON_CURRENT_SCLK;
@@ -129,6 +130,7 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
        case R600_QUERY_MAPPED_VRAM:
        case R600_QUERY_MAPPED_GTT:
        case R600_QUERY_VRAM_USAGE:
+       case R600_QUERY_VRAM_VIS_USAGE:
        case R600_QUERY_GTT_USAGE:
        case R600_QUERY_GPU_TEMPERATURE:
        case R600_QUERY_CURRENT_GPU_SCLK:
@@ -238,6 +240,7 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
        case R600_QUERY_MAPPED_VRAM:
        case R600_QUERY_MAPPED_GTT:
        case R600_QUERY_VRAM_USAGE:
+       case R600_QUERY_VRAM_VIS_USAGE:
        case R600_QUERY_GTT_USAGE:
        case R600_QUERY_GPU_TEMPERATURE:
        case R600_QUERY_CURRENT_GPU_SCLK:
@@ -1731,6 +1734,7 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
        X("num-bytes-moved",            NUM_BYTES_MOVED,        BYTES, CUMULATIVE),
        X("num-evictions",              NUM_EVICTIONS,          UINT64, CUMULATIVE),
        X("VRAM-usage",                 VRAM_USAGE,             BYTES, AVERAGE),
+       X("VRAM-vis-usage",             VRAM_VIS_USAGE,         BYTES, AVERAGE),
        X("GTT-usage",                  GTT_USAGE,              BYTES, AVERAGE),
        X("back-buffer-ps-draw-ratio",  BACK_BUFFER_PS_DRAW_RATIO, UINT64, AVERAGE),
 
@@ -1814,6 +1818,9 @@ static int r600_get_driver_query_info(struct pipe_screen *screen,
        case R600_QUERY_GPU_TEMPERATURE:
                info->max_value.u64 = 125;
                break;
+       case R600_QUERY_VRAM_VIS_USAGE:
+               info->max_value.u64 = rscreen->info.vram_vis_size;
+               break;
        }
 
        if (info->group_id != ~(unsigned)0 && rscreen->perfcounters)
index 20856a5..f2af924 100644 (file)
@@ -66,6 +66,7 @@ enum {
        R600_QUERY_NUM_BYTES_MOVED,
        R600_QUERY_NUM_EVICTIONS,
        R600_QUERY_VRAM_USAGE,
+       R600_QUERY_VRAM_VIS_USAGE,
        R600_QUERY_GTT_USAGE,
        R600_QUERY_GPU_TEMPERATURE,
        R600_QUERY_CURRENT_GPU_SCLK,
index e373e2f..881bd5f 100644 (file)
@@ -88,6 +88,7 @@ enum radeon_value_id {
     RADEON_NUM_BYTES_MOVED,
     RADEON_NUM_EVICTIONS,
     RADEON_VRAM_USAGE,
+    RADEON_VRAM_VIS_USAGE,
     RADEON_GTT_USAGE,
     RADEON_GPU_TEMPERATURE, /* DRM 2.42.0 */
     RADEON_CURRENT_SCLK,
index ea4d254..c3dfda5 100644 (file)
@@ -451,6 +451,10 @@ static uint64_t amdgpu_query_value(struct radeon_winsys *rws,
    case RADEON_VRAM_USAGE:
       amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_VRAM, 0, &heap);
       return heap.heap_usage;
+   case RADEON_VRAM_VIS_USAGE:
+      amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_VRAM,
+                             AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, &heap);
+      return heap.heap_usage;
    case RADEON_GTT_USAGE:
       amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_GTT, 0, &heap);
       return heap.heap_usage;
index ce5b7ff..3a92b58 100644 (file)
@@ -635,6 +635,7 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
                              "num-bytes-moved", (uint32_t*)&retval);
         return retval;
     case RADEON_NUM_EVICTIONS:
+    case RADEON_VRAM_VIS_USAGE:
         return 0; /* unimplemented */
     case RADEON_VRAM_USAGE:
         radeon_get_drm_value(ws->fd, RADEON_INFO_VRAM_USAGE,