zink: track resource mem usage per batch
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 28 Sep 2020 14:51:06 +0000 (10:51 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 1 Mar 2021 19:36:26 +0000 (19:36 +0000)
we want to be able to track this so we can check whether a given batch is
going wild with memory usage for resources that might be pending free once
the batch finishes

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9274>

src/gallium/drivers/zink/zink_batch.c
src/gallium/drivers/zink/zink_batch.h

index cb83a11..972f88c 100644 (file)
@@ -73,6 +73,7 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
    if (vkResetCommandPool(screen->dev, batch->cmdpool, 0) != VK_SUCCESS)
       fprintf(stderr, "vkResetCommandPool failed\n");
    batch->submitted = batch->has_work = false;
+   batch->resource_size = 0;
 }
 
 void
@@ -170,8 +171,11 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
    if (!entry) {
       entry = _mesa_set_add(batch->resources, res);
       pipe_reference(NULL, &res->base.reference);
-      if (stencil)
+      batch->resource_size += res->size;
+      if (stencil) {
          pipe_reference(NULL, &stencil->base.reference);
+         batch->resource_size += stencil->size;
+      }
    }
    /* multiple array entries are fine */
    if (res->persistent_maps)
index 83def45..dd9d97a 100644 (file)
@@ -62,6 +62,9 @@ struct zink_batch {
    struct util_dynarray zombie_samplers;
 
    struct set *active_queries; /* zink_query objects which were active at some point in this batch */
+
+   VkDeviceSize resource_size;
+
    bool has_work;
    bool submitted;
    bool in_rp; //renderpass is currently active