gallium: add interface for querying memory usage and sizes (v2)
authorMarek Olšák <marek.olsak@amd.com>
Mon, 1 Feb 2016 20:56:50 +0000 (21:56 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 5 Feb 2016 16:29:38 +0000 (17:29 +0100)
If you're worried about the duplication of some CAPs, we can remove them
later.

v2: add fields for memory eviction stats

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
16 files changed:
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nv30/nv30_screen.c
src/gallium/drivers/nouveau/nv50/nv50_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/pipe/p_state.h

index f67c1604c67d82c43e291d846df41f6788c0102f..27f4d2674381845fee9278ebb0b6e4c2c1e39178 100644 (file)
@@ -165,6 +165,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_BARRIER:
        case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
        case PIPE_CAP_COMPUTE:
+       case PIPE_CAP_QUERY_MEMORY_INFO:
                return 0;
 
        case PIPE_CAP_SM3:
index 31856ad91139fd1afd4cc91504c32f9040918b97..8d010f9dc8cd4edfbed463db43061324eadac6e6 100644 (file)
@@ -264,6 +264,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_STRING_MARKER:
    case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
 
    case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
index 7c77197156eb0b25369ba873c4e598030eac36b9..44d7c11af43e31e61f71ab419aedd71bd82bd950 100644 (file)
@@ -490,6 +490,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_STRING_MARKER:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
    case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 17316816c70eb6ac0e7aac88e86fd0e145b35c66..2c66bf46332874dca2fb8d4d6792b21dbdcf5004 100644 (file)
@@ -314,6 +314,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
    case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
    }
    /* should only get here on unhandled cases */
index 4f09b74b8e377c93381b1ebd76f5aade74e7072f..b62889119c53960b9b94346daf499cc0ddd6796b 100644 (file)
@@ -187,6 +187,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
    case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index e0b93b7edee33d1e0c6bed0ff6f6151d5435abcb..14d0085975b5f293d2a209dddacc2c19f0646429 100644 (file)
@@ -230,6 +230,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
    case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 45693c8719f788a8873650b22665a1b7c360082a..d368fda707d272eea36f50b10089460586b9a884 100644 (file)
@@ -220,6 +220,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_STRING_MARKER:
    case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index cca5936258dacf1b437f4f358c88c51152d9ad8f..a2b7f87855db7c3b1bdbcb27bf680e16dc07bd2c 100644 (file)
@@ -213,6 +213,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
         case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
         case PIPE_CAP_QUERY_BUFFER_OBJECT:
+        case PIPE_CAP_QUERY_MEMORY_INFO:
             return 0;
 
         /* SWTCL-only features. */
index fb076f3151d1f51091652ff2bf0df9d587c2028c..3e47755f369f87930b8c6e2da14ea8f63b4061ed 100644 (file)
@@ -369,6 +369,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_GENERATE_MIPMAP:
        case PIPE_CAP_STRING_MARKER:
        case PIPE_CAP_QUERY_BUFFER_OBJECT:
+       case PIPE_CAP_QUERY_MEMORY_INFO:
                return 0;
 
        case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
index 2599197ee7366de05dcf1610f6eaa8a2c41a1739..fb3a776aeae91522dd9b6b083f575eaad819c657 100644 (file)
@@ -361,6 +361,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_GENERATE_MIPMAP:
        case PIPE_CAP_STRING_MARKER:
        case PIPE_CAP_QUERY_BUFFER_OBJECT:
+       case PIPE_CAP_QUERY_MEMORY_INFO:
                return 0;
 
        case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
index 1738cae8c1807dd886a88d4bd06f28959c40d3ed..097ffe6f9209974e001164dd23d5000ebd0eba9f 100644 (file)
@@ -265,6 +265,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_STRING_MARKER:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
    case PIPE_CAP_QUERY_BUFFER_OBJECT:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
    }
    /* should only get here on unhandled cases */
index eeed59c6dc04c702be040913cf66b5bb23917867..d5405f8eacfac7d649c5b5498979f4c01a8ee3c4 100644 (file)
@@ -359,6 +359,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_INVALIDATE_BUFFER:
    case PIPE_CAP_STRING_MARKER:
    case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
       return 0;
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 64;
index 371f662ab1d8a9d024996aad906331c8ae13d967..b19d31af6ac7c6d6ae59a7460962b11a70942b98 100644 (file)
@@ -202,6 +202,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_STRING_MARKER:
         case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
         case PIPE_CAP_QUERY_BUFFER_OBJECT:
+       case PIPE_CAP_QUERY_MEMORY_INFO:
                 return 0;
 
                 /* Stream output. */
index 75b9bf930b0e8bd4cd364f3a59cb03c4c48639ad..800f16cd2508201e2e510543c6564d8a21ce437d 100644 (file)
@@ -651,6 +651,7 @@ enum pipe_cap
    PIPE_CAP_STRING_MARKER,
    PIPE_CAP_SURFACE_REINTERPRET_BLOCKS,
    PIPE_CAP_QUERY_BUFFER_OBJECT,
+   PIPE_CAP_QUERY_MEMORY_INFO,
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index f868d71db231da9ca6945ba83dff15c4d8164634..211bc2440f90485dcefa5b61c38b22130b941f5f 100644 (file)
@@ -57,6 +57,7 @@ struct pipe_resource;
 struct pipe_surface;
 struct pipe_transfer;
 struct pipe_box;
+struct pipe_memory_info;
 
 
 /**
@@ -260,6 +261,11 @@ struct pipe_screen {
                                       unsigned index,
                                       struct pipe_driver_query_group_info *info);
 
+   /**
+    * Query information about memory usage.
+    */
+   void (*query_memory_info)(struct pipe_screen *screen,
+                             struct pipe_memory_info *info);
 };
 
 
index 2e4d2830199b5a2cb758f14c9c44366ebb6bced5..ed62a33ad72a932e7ec17bdc75dda98b7d8a92bf 100644 (file)
@@ -720,6 +720,19 @@ struct pipe_debug_callback
    void *data;
 };
 
+/**
+ * Information about memory usage. All sizes are in kilobytes.
+ */
+struct pipe_memory_info
+{
+   unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
+   unsigned avail_device_memory; /**< free device memory at the moment */
+   unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
+   unsigned avail_staging_memory; /**< free staging memory at the moment */
+   unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
+   unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
+};
+
 #ifdef __cplusplus
 }
 #endif