anv: compute commands required to implement perf queries
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 15 Sep 2020 08:22:17 +0000 (11:22 +0300)
committerMarge Bot <eric+marge@anholt.net>
Tue, 2 Feb 2021 13:25:55 +0000 (13:25 +0000)
We'll use this later to try to limit the number of NOOPs emitted for
self modifying batches.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6518>

src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_perf.c
src/intel/vulkan/anv_private.h

index 0332471..037641a 100644 (file)
@@ -603,7 +603,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
    if (result != VK_SUCCESS)
       goto fail_engine_info;
 
-   device->perf = anv_get_perf(&device->info, fd);
+   anv_physical_device_init_perf(device, fd);
 
    anv_measure_device_init(device);
 
index 35bd246..1a80793 100644 (file)
 
 #include "util/mesa-sha1.h"
 
-struct gen_perf_config *
-anv_get_perf(const struct gen_device_info *devinfo, int fd)
+void
+anv_physical_device_init_perf(struct anv_physical_device *device, int fd)
 {
+   const struct gen_device_info *devinfo = &device->info;
+
+   device->perf = NULL;
+
    /* We need self modifying batches. The i915 parser prevents it on
     * Gen7.5 :( maybe one day.
     */
    if (devinfo->gen < 8)
-      return NULL;
+      return;
 
    struct gen_perf_config *perf = gen_perf_new(NULL);
 
-   gen_perf_init_metrics(perf, devinfo, fd, false /* pipeline statistics */);
+   gen_perf_init_metrics(perf, &device->info, fd, false /* pipeline statistics */);
 
    if (!perf->n_queries) {
       if (perf->platform_supported)
@@ -61,11 +65,35 @@ anv_get_perf(const struct gen_device_info *devinfo, int fd)
          goto err;
    }
 
-   return perf;
+   device->perf = perf;
+
+   /* Compute the number of commands we need to implement a performance
+    * query.
+    */
+   const struct gen_perf_query_field_layout *layout = &perf->query_layout;
+   device->n_perf_query_commands = 0;
+   for (uint32_t f = 0; f < layout->n_fields; f++) {
+      struct gen_perf_query_field *field = &layout->fields[f];
+
+      switch (field->type) {
+      case GEN_PERF_QUERY_FIELD_TYPE_MI_RPC:
+         device->n_perf_query_commands++;
+         break;
+      case GEN_PERF_QUERY_FIELD_TYPE_SRM_PERFCNT:
+      case GEN_PERF_QUERY_FIELD_TYPE_SRM_RPSTAT:
+      case GEN_PERF_QUERY_FIELD_TYPE_SRM_OA_B:
+      case GEN_PERF_QUERY_FIELD_TYPE_SRM_OA_C:
+         device->n_perf_query_commands += field->size / 4;
+         break;
+      }
+   }
+   device->n_perf_query_commands *= 2; /* Begin & End */
+   device->n_perf_query_commands += 1; /* availability */
+
+   return;
 
  err:
    ralloc_free(perf);
-   return NULL;
 }
 
 void
index 5fd4582..1775236 100644 (file)
@@ -991,6 +991,11 @@ struct anv_physical_device {
     struct brw_compiler *                       compiler;
     struct isl_device                           isl_dev;
     struct gen_perf_config *                    perf;
+    /*
+     * Number of commands required to implement a performance query begin +
+     * end.
+     */
+    uint32_t                                    n_perf_query_commands;
     int                                         cmd_parser_version;
     bool                                        has_softpin;
     bool                                        has_exec_async;
@@ -4432,7 +4437,7 @@ struct anv_performance_configuration_intel {
    uint64_t                   config_id;
 };
 
-struct gen_perf_config *anv_get_perf(const struct gen_device_info *devinfo, int fd);
+void anv_physical_device_init_perf(struct anv_physical_device *device, int fd);
 void anv_device_perf_init(struct anv_device *device);
 void anv_perf_write_pass_results(struct gen_perf_config *perf,
                                  struct anv_query_pool *pool, uint32_t pass,