anv: Add a mi_memset and use it for zeroing queries
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 14 Sep 2018 22:06:48 +0000 (17:06 -0500)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 17 Sep 2018 07:57:21 +0000 (02:57 -0500)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_genX.h
src/intel/vulkan/genX_gpu_memcpy.c
src/intel/vulkan/genX_query.c

index bef9b5bde4e245e01b3a491dc963e22495b7c439..7921e0674a0181fca811abc276bd65fb0e363d1e 100644 (file)
@@ -80,5 +80,9 @@ void genX(cmd_buffer_mi_memcpy)(struct anv_cmd_buffer *cmd_buffer,
                                 struct anv_address dst, struct anv_address src,
                                 uint32_t size);
 
+void genX(cmd_buffer_mi_memset)(struct anv_cmd_buffer *cmd_buffer,
+                                struct anv_address dst, uint32_t value,
+                                uint32_t size);
+
 void genX(blorp_exec)(struct blorp_batch *batch,
                       const struct blorp_params *params);
index bbf3d4b63ae936178863919e03c26ba5f5e2d9ef..11ffd6fb436f167b6857b805379a0a1e3c01684e 100644 (file)
@@ -108,6 +108,23 @@ genX(cmd_buffer_mi_memcpy)(struct anv_cmd_buffer *cmd_buffer,
    return;
 }
 
+void
+genX(cmd_buffer_mi_memset)(struct anv_cmd_buffer *cmd_buffer,
+                           struct anv_address dst, uint32_t value,
+                           uint32_t size)
+{
+   /* This memset operates in units of dwords. */
+   assert(size % 4 == 0);
+   assert(dst.offset % 4 == 0);
+
+   for (uint32_t i = 0; i < size; i += 4) {
+      anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_DATA_IMM), sdi) {
+         sdi.Address = anv_address_add(dst, i);
+         sdi.ImmediateData = value;
+      }
+   }
+}
+
 void
 genX(cmd_buffer_so_memcpy)(struct anv_cmd_buffer *cmd_buffer,
                            struct anv_address dst, struct anv_address src,
index 56d18e021e4fc13089aaeaedb4d145beb45c1e42..4ccbe2975de89b3461782e78735b073537a84d99 100644 (file)
@@ -346,21 +346,11 @@ emit_zero_queries(struct anv_cmd_buffer *cmd_buffer,
                   struct anv_query_pool *pool,
                   uint32_t first_index, uint32_t num_queries)
 {
-   const uint32_t num_elements = pool->stride / sizeof(uint64_t);
-
    for (uint32_t i = 0; i < num_queries; i++) {
       struct anv_address slot_addr =
          anv_query_address(pool, first_index + i);
-      for (uint32_t j = 1; j < num_elements; j++) {
-         anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_DATA_IMM), sdi) {
-            sdi.Address = anv_address_add(slot_addr, j * sizeof(uint64_t));
-            sdi.ImmediateData = 0ull;
-         }
-         anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_DATA_IMM), sdi) {
-            sdi.Address = anv_address_add(slot_addr, j * sizeof(uint64_t) + 4);
-            sdi.ImmediateData = 0ull;
-         }
-      }
+      genX(cmd_buffer_mi_memset)(cmd_buffer, anv_address_add(slot_addr, 8),
+                                 0, pool->stride - 8);
       emit_query_availability(cmd_buffer, slot_addr);
    }
 }