svga: add new GALLIUM_HUD queries
authorNeha Bhende <nbhende@vmware.com>
Fri, 9 Oct 2015 22:10:16 +0000 (16:10 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 16 Oct 2015 17:43:28 +0000 (11:43 -0600)
Add new GALLIUM_HUD queries for:
    num-shaders
    num-resources
    num-state-objects
    num-validations
    map-buffer-time
    num-surface-views
    num-resources-mapped
    num-flushes

Most of this patch was originally written by Neha.  Additional clean-ups
and num-flushes counter added by Brian Paul.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
16 files changed:
src/gallium/drivers/svga/svga_context.c
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_blend.c
src/gallium/drivers/svga/svga_pipe_depthstencil.c
src/gallium/drivers/svga/svga_pipe_draw.c
src/gallium/drivers/svga/svga_pipe_query.c
src/gallium/drivers/svga/svga_pipe_rasterizer.c
src/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/drivers/svga/svga_pipe_vertex.c
src/gallium/drivers/svga/svga_resource_buffer.c
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/svga/svga_screen.h
src/gallium/drivers/svga/svga_shader.c
src/gallium/drivers/svga/svga_state.c
src/gallium/drivers/svga/svga_surface.c

index 2bf795de22da3251ac076d94001f090906ba2d73..f8622b96f45b1cc3a8f873baa578e2624b37d471 100644 (file)
@@ -312,6 +312,8 @@ void svga_context_flush( struct svga_context *svga,
     */
    svga->swc->flush(svga->swc, &fence);
 
+   svga->hud.num_flushes++;
+
    svga_screen_cache_flush(svgascreen, fence);
 
    /* To force the re-emission of rendertargets and texture sampler bindings on
index e8575f36c3b176c614b495191ef7b8d38a6a2886..bcce18a3502536a3da6638b7caac551285b22959 100644 (file)
 
 
 /** Non-GPU queries for gallium HUD */
-#define SVGA_QUERY_DRAW_CALLS   (PIPE_QUERY_DRIVER_SPECIFIC + 0)
-#define SVGA_QUERY_FALLBACKS    (PIPE_QUERY_DRIVER_SPECIFIC + 1)
-#define SVGA_QUERY_MEMORY_USED  (PIPE_QUERY_DRIVER_SPECIFIC + 2)
-#define SVGA_QUERY_MAX          (PIPE_QUERY_DRIVER_SPECIFIC + 3)
+/* per-frame counters */
+#define SVGA_QUERY_NUM_DRAW_CALLS          (PIPE_QUERY_DRIVER_SPECIFIC + 0)
+#define SVGA_QUERY_NUM_FALLBACKS           (PIPE_QUERY_DRIVER_SPECIFIC + 1)
+#define SVGA_QUERY_NUM_FLUSHES             (PIPE_QUERY_DRIVER_SPECIFIC + 2)
+#define SVGA_QUERY_NUM_VALIDATIONS         (PIPE_QUERY_DRIVER_SPECIFIC + 3)
+#define SVGA_QUERY_MAP_BUFFER_TIME         (PIPE_QUERY_DRIVER_SPECIFIC + 4)
+#define SVGA_QUERY_NUM_RESOURCES_MAPPED    (PIPE_QUERY_DRIVER_SPECIFIC + 5)
+/* running total counters */
+#define SVGA_QUERY_MEMORY_USED             (PIPE_QUERY_DRIVER_SPECIFIC + 6)
+#define SVGA_QUERY_NUM_SHADERS             (PIPE_QUERY_DRIVER_SPECIFIC + 7)
+#define SVGA_QUERY_NUM_RESOURCES           (PIPE_QUERY_DRIVER_SPECIFIC + 8)
+#define SVGA_QUERY_NUM_STATE_OBJECTS       (PIPE_QUERY_DRIVER_SPECIFIC + 9)
+#define SVGA_QUERY_NUM_SURFACE_VIEWS       (PIPE_QUERY_DRIVER_SPECIFIC + 10)
+/*SVGA_QUERY_MAX has to be last because it is size of an array*/
+#define SVGA_QUERY_MAX                     (PIPE_QUERY_DRIVER_SPECIFIC + 11)
 
 /**
  * Maximum supported number of constant buffers per shader
@@ -463,9 +474,18 @@ struct svga_context
    /** List of buffers with queued transfers */
    struct list_head dirty_buffers;
 
-   /** performance / info queries */
-   uint64_t num_draw_calls;  /**< SVGA_QUERY_DRAW_CALLS */
-   uint64_t num_fallbacks;   /**< SVGA_QUERY_FALLBACKS */
+   /** performance / info queries for HUD */
+   struct {
+      uint64_t num_draw_calls;       /**< SVGA_QUERY_DRAW_CALLS */
+      uint64_t num_fallbacks;        /**< SVGA_QUERY_NUM_FALLBACKS */
+      uint64_t num_flushes;          /**< SVGA_QUERY_NUM_FLUSHES */
+      uint64_t num_validations;      /**< SVGA_QUERY_NUM_VALIDATIONS */
+      uint64_t map_buffer_time;      /**< SVGA_QUERY_MAP_BUFFER_TIME */
+      uint64_t num_resources_mapped; /**< SVGA_QUERY_NUM_RESOURCES_MAPPED */
+      uint64_t num_shaders;          /**< SVGA_QUERY_NUM_SHADERS */
+      uint64_t num_state_objects;    /**< SVGA_QUERY_NUM_STATE_OBJECTS */
+      uint64_t num_surface_views;    /**< SVGA_QUERY_NUM_SURFACE_VIEWS */
+   } hud;
 
    /** The currently bound stream output targets */
    unsigned num_so_targets;
index 06bb3e3bd7e29c6a5055c6c2f7405ca6efe23c03..0c9d6129b53e144f51db4db31be472031a9b6a5f 100644 (file)
@@ -321,6 +321,8 @@ svga_create_blend_state(struct pipe_context *pipe,
       define_blend_state_object(svga, blend);
    }
 
+   svga->hud.num_state_objects++;
+
    return blend;
 }
 
@@ -359,6 +361,7 @@ static void svga_delete_blend_state(struct pipe_context *pipe,
    }
 
    FREE(blend);
+   svga->hud.num_state_objects--;
 }
 
 static void svga_set_blend_color( struct pipe_context *pipe,
index 5ea623be4d90fa005a591450042bdc571e33d4de..d84ed1df48e78fe1d25b12d1992c0639b31f0037 100644 (file)
@@ -202,6 +202,8 @@ svga_create_depth_stencil_state(struct pipe_context *pipe,
       define_depth_stencil_state_object(svga, ds);
    }
 
+   svga->hud.num_state_objects++;
+
    return ds;
 }
 
@@ -248,6 +250,7 @@ static void svga_delete_depth_stencil_state(struct pipe_context *pipe,
    }
 
    FREE(depth_stencil);
+   svga->hud.num_state_objects--;
 }
 
 
index 303d4565cdb7648b9a5f26138b023f7ed19a452e..50ebb53df906c69ee5ada6a5049181aea2e44caf 100644 (file)
@@ -177,7 +177,7 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    enum pipe_error ret = 0;
    boolean needed_swtnl;
 
-   svga->num_draw_calls++;  /* for SVGA_QUERY_DRAW_CALLS */
+   svga->hud.num_draw_calls++;  /* for SVGA_QUERY_NUM_DRAW_CALLS */
 
    if (u_reduced_prim(info->mode) == PIPE_PRIM_TRIANGLES &&
        svga->curr.rast->templ.cull_face == PIPE_FACE_FRONT_AND_BACK)
@@ -219,7 +219,7 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 #endif
 
    if (svga->state.sw.need_swtnl) {
-      svga->num_fallbacks++;  /* for SVGA_QUERY_FALLBACKS */
+      svga->hud.num_fallbacks++;  /* for SVGA_QUERY_NUM_FALLBACKS */
       if (!needed_swtnl) {
          /*
           * We're switching from HW to SW TNL.  SW TNL will require mapping all
index 7081e5a1c43f28356b91064b3fe4d2f7c578887b..8b9818334ca716c901d1479f78b743e81fb8b078 100644 (file)
@@ -720,9 +720,17 @@ svga_create_query(struct pipe_context *pipe,
       define_query_vgpu10(svga, sq,
                           sizeof(SVGADXTimestampQueryResult));
       break;
-   case SVGA_QUERY_DRAW_CALLS:
-   case SVGA_QUERY_FALLBACKS:
+   case SVGA_QUERY_NUM_DRAW_CALLS:
+   case SVGA_QUERY_NUM_FALLBACKS:
+   case SVGA_QUERY_NUM_FLUSHES:
    case SVGA_QUERY_MEMORY_USED:
+   case SVGA_QUERY_NUM_SHADERS:
+   case SVGA_QUERY_NUM_RESOURCES:
+   case SVGA_QUERY_NUM_STATE_OBJECTS:
+   case SVGA_QUERY_NUM_VALIDATIONS:
+   case SVGA_QUERY_MAP_BUFFER_TIME:
+   case SVGA_QUERY_NUM_SURFACE_VIEWS:
+   case SVGA_QUERY_NUM_RESOURCES_MAPPED:
       break;
    default:
       assert(!"unexpected query type in svga_create_query()");
@@ -778,9 +786,17 @@ svga_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
       destroy_query_vgpu10(svga, sq);
       sws->fence_reference(sws, &sq->fence, NULL);
       break;
-   case SVGA_QUERY_DRAW_CALLS:
-   case SVGA_QUERY_FALLBACKS:
+   case SVGA_QUERY_NUM_DRAW_CALLS:
+   case SVGA_QUERY_NUM_FALLBACKS:
+   case SVGA_QUERY_NUM_FLUSHES:
    case SVGA_QUERY_MEMORY_USED:
+   case SVGA_QUERY_NUM_SHADERS:
+   case SVGA_QUERY_NUM_RESOURCES:
+   case SVGA_QUERY_NUM_STATE_OBJECTS:
+   case SVGA_QUERY_NUM_VALIDATIONS:
+   case SVGA_QUERY_MAP_BUFFER_TIME:
+   case SVGA_QUERY_NUM_SURFACE_VIEWS:
+   case SVGA_QUERY_NUM_RESOURCES_MAPPED:
       /* nothing */
       break;
    default:
@@ -842,13 +858,29 @@ svga_begin_query(struct pipe_context *pipe, struct pipe_query *q)
       ret = begin_query_vgpu10(svga, sq);
       assert(ret == PIPE_OK);
       break;
-   case SVGA_QUERY_DRAW_CALLS:
-      sq->begin_count = svga->num_draw_calls;
+   case SVGA_QUERY_NUM_DRAW_CALLS:
+      sq->begin_count = svga->hud.num_draw_calls;
       break;
-   case SVGA_QUERY_FALLBACKS:
-      sq->begin_count = svga->num_fallbacks;
+   case SVGA_QUERY_NUM_FALLBACKS:
+      sq->begin_count = svga->hud.num_fallbacks;
+      break;
+   case SVGA_QUERY_NUM_FLUSHES:
+      sq->begin_count = svga->hud.num_flushes;
+      break;
+   case SVGA_QUERY_NUM_VALIDATIONS:
+      sq->begin_count = svga->hud.num_validations;
+      break;
+   case SVGA_QUERY_MAP_BUFFER_TIME:
+      sq->begin_count = svga->hud.map_buffer_time;
+      break;
+   case SVGA_QUERY_NUM_RESOURCES_MAPPED:
+      sq->begin_count = svga->hud.num_resources_mapped;
       break;
    case SVGA_QUERY_MEMORY_USED:
+   case SVGA_QUERY_NUM_SHADERS:
+   case SVGA_QUERY_NUM_RESOURCES:
+   case SVGA_QUERY_NUM_STATE_OBJECTS:
+   case SVGA_QUERY_NUM_SURFACE_VIEWS:
       /* nothing */
       break;
    default:
@@ -916,13 +948,29 @@ svga_end_query(struct pipe_context *pipe, struct pipe_query *q)
       ret = end_query_vgpu10(svga, sq);
       assert(ret == PIPE_OK);
       break;
-   case SVGA_QUERY_DRAW_CALLS:
-      sq->end_count = svga->num_draw_calls;
+   case SVGA_QUERY_NUM_DRAW_CALLS:
+      sq->end_count = svga->hud.num_draw_calls;
+      break;
+   case SVGA_QUERY_NUM_FALLBACKS:
+      sq->end_count = svga->hud.num_fallbacks;
+      break;
+   case SVGA_QUERY_NUM_FLUSHES:
+      sq->end_count = svga->hud.num_flushes;
       break;
-   case SVGA_QUERY_FALLBACKS:
-      sq->end_count = svga->num_fallbacks;
+   case SVGA_QUERY_NUM_VALIDATIONS:
+      sq->end_count = svga->hud.num_validations;
+      break;
+   case SVGA_QUERY_MAP_BUFFER_TIME:
+      sq->end_count = svga->hud.map_buffer_time;
+      break;
+   case SVGA_QUERY_NUM_RESOURCES_MAPPED:
+      sq->end_count = svga->hud.num_resources_mapped;
       break;
    case SVGA_QUERY_MEMORY_USED:
+   case SVGA_QUERY_NUM_SHADERS:
+   case SVGA_QUERY_NUM_RESOURCES:
+   case SVGA_QUERY_NUM_STATE_OBJECTS:
+   case SVGA_QUERY_NUM_SURFACE_VIEWS:
       /* nothing */
       break;
    default:
@@ -1007,13 +1055,30 @@ svga_get_query_result(struct pipe_context *pipe,
       *result = (uint64_t)sResult.numPrimitivesWritten;
       break;
    }
-   case SVGA_QUERY_DRAW_CALLS:
-      /* fall-through */
-   case SVGA_QUERY_FALLBACKS:
+   /* These are per-frame counters */
+   case SVGA_QUERY_NUM_DRAW_CALLS:
+   case SVGA_QUERY_NUM_FALLBACKS:
+   case SVGA_QUERY_NUM_FLUSHES:
+   case SVGA_QUERY_NUM_VALIDATIONS:
+   case SVGA_QUERY_NUM_RESOURCES_MAPPED:
+   case SVGA_QUERY_MAP_BUFFER_TIME:
       vresult->u64 = sq->end_count - sq->begin_count;
       break;
+   /* These are running total counters */
    case SVGA_QUERY_MEMORY_USED:
-      vresult->u64 = svgascreen->total_resource_bytes;
+      vresult->u64 = svgascreen->hud.total_resource_bytes;
+      break;
+   case SVGA_QUERY_NUM_SHADERS:
+      vresult->u64 = svga->hud.num_shaders;
+      break;
+   case SVGA_QUERY_NUM_RESOURCES:
+      vresult->u64 = svgascreen->hud.num_resources;
+      break;
+   case SVGA_QUERY_NUM_STATE_OBJECTS:
+      vresult->u64 = svga->hud.num_state_objects;
+      break;
+   case SVGA_QUERY_NUM_SURFACE_VIEWS:
+      vresult->u64 = svga->hud.num_surface_views;
       break;
    default:
       assert(!"unexpected query type in svga_get_query_result");
index a7aadac0111ae7b9290d7fed44fe146755987ada..6310b7a5e86f567341c5770e525f17b1d0356b80 100644 (file)
@@ -352,6 +352,8 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
       define_rasterizer_object(svga, rast);
    }
 
+   svga->hud.num_state_objects++;
+
    return rast;
 }
 
@@ -392,6 +394,7 @@ svga_delete_rasterizer_state(struct pipe_context *pipe, void *state)
    }
 
    FREE(state);
+   svga->hud.num_state_objects--;
 }
 
 
index 60e2d44ace4e23c0b7a3a7bf0fd412f46e89cd75..952411765107583b0c2923c56efffa0808a9c340 100644 (file)
@@ -273,6 +273,8 @@ svga_create_sampler_state(struct pipe_context *pipe,
             cso->min_lod, cso->view_min_lod, cso->view_max_lod,
             cso->mipfilter == SVGA3D_TEX_FILTER_NONE ? "SVGA3D_TEX_FILTER_NONE" : "SOMETHING");
 
+   svga->hud.num_state_objects++;
+
    return cso;
 }
 
@@ -328,6 +330,7 @@ static void svga_delete_sampler_state(struct pipe_context *pipe,
    }
 
    FREE(sampler);
+   svga->hud.num_state_objects--;
 }
 
 
index e0932a9dbc1eea24e7669a4376197b3be66f3dbb..b932c568f539d8be0811b2ad0d4de4975cb82943 100644 (file)
@@ -274,6 +274,9 @@ svga_create_vertex_elements_state(struct pipe_context *pipe,
          translate_vertex_decls(svga, velems);
       }
    }
+
+   svga->hud.num_state_objects++;
+
    return velems;
 }
 
@@ -315,6 +318,7 @@ svga_delete_vertex_elements_state(struct pipe_context *pipe, void *state)
    }
 
    FREE(velems);
+   svga->hud.num_state_objects--;
 }
 
 void svga_cleanup_vertex_state( struct svga_context *svga )
index 57e37fcfe14af43463d722809fbc693ea07be9ce..6a8fff454e4e248995ebaaf15b473923084b6cdc 100644 (file)
@@ -29,6 +29,7 @@
 #include "pipe/p_defines.h"
 #include "util/u_inlines.h"
 #include "os/os_thread.h"
+#include "os/os_time.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_resource.h"
@@ -77,6 +78,7 @@ svga_buffer_transfer_map(struct pipe_context *pipe,
    struct svga_buffer *sbuf = svga_buffer(resource);
    struct pipe_transfer *transfer;
    uint8_t *map;
+   int64_t begin = os_time_get();
 
    transfer = CALLOC_STRUCT(pipe_transfer);
    if (transfer == NULL) {
@@ -244,6 +246,9 @@ svga_buffer_transfer_map(struct pipe_context *pipe,
       FREE(transfer);
    }
 
+   svga->hud.map_buffer_time += (os_time_get() - begin);
+   svga->hud.num_resources_mapped++;
+
    return map;
 }
 
@@ -331,7 +336,10 @@ svga_buffer_destroy( struct pipe_screen *screen,
    if (sbuf->swbuf && !sbuf->user)
       align_free(sbuf->swbuf);
 
-   ss->total_resource_bytes -= sbuf->size;
+   ss->hud.total_resource_bytes -= sbuf->size;
+   assert(ss->hud.num_resources > 0);
+   if (ss->hud.num_resources > 0)
+      ss->hud.num_resources--;
 
    FREE(sbuf);
 }
@@ -409,7 +417,9 @@ svga_buffer_create(struct pipe_screen *screen,
                    (debug_reference_descriptor)debug_describe_resource, 0);
 
    sbuf->size = util_resource_size(&sbuf->b.b);
-   ss->total_resource_bytes += sbuf->size;
+   ss->hud.total_resource_bytes += sbuf->size;
+
+   ss->hud.num_resources++;
 
    return &sbuf->b.b;
 
@@ -427,6 +437,7 @@ svga_user_buffer_create(struct pipe_screen *screen,
                        unsigned bind)
 {
    struct svga_buffer *sbuf;
+   struct svga_screen *ss = svga_screen(screen);
 
    sbuf = CALLOC_STRUCT(svga_buffer);
    if (!sbuf)
@@ -450,6 +461,8 @@ svga_user_buffer_create(struct pipe_screen *screen,
    debug_reference(&sbuf->b.b.reference,
                    (debug_reference_descriptor)debug_describe_resource, 0);
 
+   ss->hud.num_resources++;
+
    return &sbuf->b.b;
 
 no_sbuf:
index 90787be80730609f8d3ec4966b68fdeebf7fe951..a02d1e495ff72c807deb47c243fe9d76d6939bce 100644 (file)
@@ -29,6 +29,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "os/os_thread.h"
+#include "os/os_time.h"
 #include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_math.h"
@@ -229,11 +230,15 @@ svga_texture_destroy(struct pipe_screen *screen,
    SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
    svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
 
-   ss->total_resource_bytes -= tex->size;
+   ss->hud.total_resource_bytes -= tex->size;
 
    FREE(tex->defined);
    FREE(tex->rendered_to);
    FREE(tex);
+
+   assert(ss->hud.num_resources > 0);
+   if (ss->hud.num_resources > 0)
+      ss->hud.num_resources--;
 }
 
 
@@ -322,6 +327,8 @@ svga_texture_transfer_map(struct pipe_context *pipe,
    boolean use_direct_map = svga_have_gb_objects(svga) &&
       !svga_have_gb_dma(svga);
    unsigned d;
+   void *returnVal;
+   int64_t begin = os_time_get();
 
    /* We can't map texture storage directly unless we have GB objects */
    if (usage & PIPE_TRANSFER_MAP_DIRECTLY) {
@@ -464,10 +471,10 @@ svga_texture_transfer_map(struct pipe_context *pipe,
     * Begin mapping code
     */
    if (st->swbuf) {
-      return st->swbuf;
+      returnVal = st->swbuf;
    }
    else if (!st->use_direct_map) {
-      return sws->buffer_map(sws, st->hwbuf, usage);
+      returnVal = sws->buffer_map(sws, st->hwbuf, usage);
    }
    else {
       SVGA3dSize baseLevelSize;
@@ -518,9 +525,13 @@ svga_texture_transfer_map(struct pipe_context *pipe,
       offset += svga3dsurface_get_pixel_offset(tex->key.format,
                                                mip_width, mip_height,
                                                xoffset, yoffset, zoffset);
-
-      return (void *) (map + offset);
+      returnVal = (void *) (map + offset);
    }
+
+   svga->hud.map_buffer_time += (os_time_get() - begin);
+   svga->hud.num_resources_mapped++;
+
+   return returnVal;
 }
 
 
@@ -889,7 +900,8 @@ svga_texture_create(struct pipe_screen *screen,
                    (debug_reference_descriptor)debug_describe_resource, 0);
 
    tex->size = util_resource_size(template);
-   svgascreen->total_resource_bytes += tex->size;
+   svgascreen->hud.total_resource_bytes += tex->size;
+   svgascreen->hud.num_resources++;
 
    return &tex->b.b;
 }
@@ -901,6 +913,7 @@ svga_texture_from_handle(struct pipe_screen *screen,
                         struct winsys_handle *whandle)
 {
    struct svga_winsys_screen *sws = svga_winsys_screen(screen);
+   struct svga_screen *ss = svga_screen(screen);
    struct svga_winsys_surface *srf;
    struct svga_texture *tex;
    enum SVGA3dSurfaceFormat format = 0;
@@ -970,5 +983,7 @@ svga_texture_from_handle(struct pipe_screen *screen,
    tex->rendered_to = CALLOC(1, sizeof(tex->rendered_to[0]));
    tex->imported = TRUE;
 
+   ss->hud.num_resources++;
+
    return &tex->b.b;
 }
index e0a28788238b578dbcb7e1dce7634d3369e0a066..dab898143348eae969adf5629d687ebbf45aa982 100644 (file)
@@ -772,9 +772,22 @@ svga_get_driver_query_info(struct pipe_screen *screen,
                            struct pipe_driver_query_info *info)
 {
    static const struct pipe_driver_query_info queries[] = {
-      {"draw-calls", SVGA_QUERY_DRAW_CALLS, {0}},
-      {"fallbacks", SVGA_QUERY_FALLBACKS, {0}},
-      {"memory-used", SVGA_QUERY_MEMORY_USED, {0}, PIPE_DRIVER_QUERY_TYPE_BYTES}
+      /* per-frame counters */
+      {"num-draw-calls", SVGA_QUERY_NUM_DRAW_CALLS, {0}},
+      {"num-fallbacks", SVGA_QUERY_NUM_FALLBACKS, {0}},
+      {"num-flushes", SVGA_QUERY_NUM_FLUSHES, {0}},
+      {"num-validations", SVGA_QUERY_NUM_VALIDATIONS, {0}},
+      {"map-buffer-time", SVGA_QUERY_MAP_BUFFER_TIME, {0},
+       PIPE_DRIVER_QUERY_TYPE_MICROSECONDS},
+      {"num-resources-mapped", SVGA_QUERY_NUM_RESOURCES_MAPPED, {0}},
+
+      /* running total counters */
+      {"memory-used", SVGA_QUERY_MEMORY_USED, {0},
+       PIPE_DRIVER_QUERY_TYPE_BYTES},
+      {"num-shaders", SVGA_QUERY_NUM_SHADERS, {0}},
+      {"num-resources", SVGA_QUERY_NUM_RESOURCES, {0}},
+      {"num-state-objects", SVGA_QUERY_NUM_STATE_OBJECTS, {0}},
+      {"num-surface-views", SVGA_QUERY_NUM_SURFACE_VIEWS, {0}},
    };
 
    if (!info)
index 5581d2e1ffdac2e5f1efc939c4d9e90aef774ea3..98b56b2a6d1c420a164ed38e26f4f4542a9aaac1 100644 (file)
@@ -80,8 +80,12 @@ struct svga_screen
 
    struct svga_host_surface_cache cache;
 
-   /** Memory used by all resources (buffers and surfaces) */
-   uint64_t total_resource_bytes;
+   /** HUD counters */
+   struct {
+      /** Memory used by all resources (buffers and surfaces) */
+      uint64_t total_resource_bytes;
+      uint64_t num_resources;
+   } hud;
 };
 
 #ifndef DEBUG
index 7b847558db16d311a63d17f66be9a09db9755c83..5c99e16d97659fc5f2ad44623c55b1e3f88b94e3 100644 (file)
@@ -417,6 +417,7 @@ svga_set_shader(struct svga_context *svga,
 struct svga_shader_variant *
 svga_new_shader_variant(struct svga_context *svga)
 {
+   svga->hud.num_shaders++;
    return CALLOC_STRUCT(svga_shader_variant);
 }
 
@@ -462,6 +463,8 @@ svga_destroy_shader_variant(struct svga_context *svga,
    FREE((unsigned *)variant->tokens);
    FREE(variant);
 
+   svga->hud.num_shaders--;
+
    return ret;
 }
 
index 37d16dc9afe9ec20f6cb9f6b95188d721639fd90..722b369fd4b479979c0d9021321e89d0d3da2590 100644 (file)
@@ -225,6 +225,9 @@ svga_update_state(struct svga_context *svga, unsigned max_level)
       svga->state.dirty[i] |= svga->dirty;
 
    svga->dirty = 0;
+
+   svga->hud.num_validations++;
+
    return PIPE_OK;
 }
 
index aca5abcdfce8768d8a6ca95504c2f1e40de43daf..9f09311116e6cce0af28763aea33fa23336c561d 100644 (file)
@@ -317,6 +317,8 @@ svga_create_surface_view(struct pipe_context *pipe,
       s->real_level = surf_tmpl->u.tex.level;
    }
 
+   svga->hud.num_surface_views++;
+
    return &s->base;
 }
 
@@ -509,6 +511,8 @@ svga_surface_destroy(struct pipe_context *pipe,
 
    pipe_resource_reference(&surf->texture, NULL);
    FREE(surf);
+
+   svga->hud.num_surface_views--;
 }