anv: enable blorp query reset for performance queries
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 13 Apr 2023 18:29:36 +0000 (21:29 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sat, 15 Apr 2023 09:25:57 +0000 (12:25 +0300)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Felix DeGrood <felix.j.degrood@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22480>

src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_query.c

index cc04b8d..2f67b45 100644 (file)
@@ -4153,6 +4153,14 @@ struct anv_query_pool {
    uint32_t                                     slots;
    struct anv_bo *                              bo;
 
+   /** Location for the KHR_performance_query small batch updating
+    *  ANV_PERF_QUERY_OFFSET_REG
+    */
+   uint32_t                                     khr_perf_preambles_offset;
+
+   /** Size of each small batch */
+   uint32_t                                     khr_perf_preamble_stride;
+
    /* KHR perf queries : */
    uint32_t                                     pass_size;
    uint32_t                                     data_offset;
@@ -4166,7 +4174,8 @@ struct anv_query_pool {
 static inline uint32_t khr_perf_query_preamble_offset(const struct anv_query_pool *pool,
                                                       uint32_t pass)
 {
-   return pool->pass_size * pass + 8;
+   return pool->khr_perf_preambles_offset +
+          pool->khr_perf_preamble_stride * pass;
 }
 
 struct anv_vid_mem {
index a4c1eb0..9635332 100644 (file)
@@ -156,7 +156,7 @@ VkResult genX(CreateQueryPool)(
                              perf_query_info->counterIndexCount);
       vk_multialloc_add(&ma, &pass_query, struct intel_perf_query_info *,
                              n_passes);
-      uint64s_per_slot = 4 /* availability + small batch */;
+      uint64s_per_slot = 1 /* availability */;
       /* Align to the requirement of the layout */
       uint64s_per_slot = align(uint64s_per_slot,
                                DIV_ROUND_UP(layout->alignment, sizeof(uint64_t)));
@@ -222,6 +222,16 @@ VkResult genX(CreateQueryPool)(
    }
 
    uint64_t size = pool->slots * (uint64_t)pool->stride;
+
+   /* For KHR_performance_query we need some space in the buffer for a small
+    * batch updating ANV_PERF_QUERY_OFFSET_REG.
+    */
+   if (pool->type == VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR) {
+      pool->khr_perf_preamble_stride = 32;
+      pool->khr_perf_preambles_offset = size;
+      size += pool->n_passes * pool->khr_perf_preamble_stride;
+   }
+
    result = anv_device_alloc_bo(device, "query-pool", size,
                                 ANV_BO_ALLOC_MAPPED |
                                 ANV_BO_ALLOC_SNOOPED,
@@ -277,36 +287,24 @@ void genX(DestroyQueryPool)(
  * --------------------------------------------
  * |       availability (8b)       | |        |
  * |-------------------------------| |        |
- * |      Small batch loading      | |        |
- * |   ANV_PERF_QUERY_OFFSET_REG   | |        |
- * |            (24b)              | | Pass 0 |
- * |-------------------------------| |        |
  * |       some padding (see       | |        |
- * | query_field_layout:alignment) | |        |
+ * | query_field_layout:alignment) | | Pass 0 |
  * |-------------------------------| |        |
  * |           query data          | |        |
  * | (2 * query_field_layout:size) | |        |
  * |-------------------------------|--        | Query 0
  * |       availability (8b)       | |        |
  * |-------------------------------| |        |
- * |      Small batch loading      | |        |
- * |   ANV_PERF_QUERY_OFFSET_REG   | |        |
- * |            (24b)              | | Pass 1 |
- * |-------------------------------| |        |
  * |       some padding (see       | |        |
- * | query_field_layout:alignment) | |        |
+ * | query_field_layout:alignment) | | Pass 1 |
  * |-------------------------------| |        |
  * |           query data          | |        |
  * | (2 * query_field_layout:size) | |        |
  * |-------------------------------|-----------
  * |       availability (8b)       | |        |
  * |-------------------------------| |        |
- * |      Small batch loading      | |        |
- * |   ANV_PERF_QUERY_OFFSET_REG   | |        |
- * |            (24b)              | | Pass 0 |
- * |-------------------------------| |        |
  * |       some padding (see       | |        |
- * | query_field_layout:alignment) | |        |
+ * | query_field_layout:alignment) | | Pass 0 |
  * |-------------------------------| |        |
  * |           query data          | |        |
  * | (2 * query_field_layout:size) | |        |
@@ -787,8 +785,7 @@ void genX(CmdResetQueryPool)(
    /* Temporarily disable on MTL until we understand why some tests hang.
     */
    if (queryCount >= pdevice->instance->query_clear_with_blorp_threshold &&
-       !intel_device_info_is_mtl(cmd_buffer->device->info) &&
-       pool->type != VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR) {
+       !intel_device_info_is_mtl(cmd_buffer->device->info)) {
       anv_cmd_buffer_fill_area(cmd_buffer,
                                anv_query_address(pool, firstQuery),
                                queryCount * pool->stride,