iris: results write
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 27 Sep 2018 08:39:04 +0000 (10:39 +0200)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_query.c
src/gallium/drivers/iris/iris_state.c

index c7627c15de323aa8ef1273a30ad9f6fe8e2a6a58..1d51316c62598e7e8733f635719d622b4e04c97b 100644 (file)
@@ -292,6 +292,10 @@ struct iris_vtable {
    void (*store_data_imm64)(struct iris_batch *batch,
                             struct iris_bo *bo, uint32_t offset,
                             uint64_t value);
+   void (*copy_mem_mem)(struct iris_batch *batch,
+                        struct iris_bo *dst_bo, uint32_t dst_offset,
+                        struct iris_bo *src_bo, uint32_t src_offset,
+                        unsigned bytes);
    void (*emit_raw_pipe_control)(struct iris_batch *batch, uint32_t flags,
                                  struct iris_bo *bo, uint32_t offset,
                                  uint64_t imm);
index e4597ed7a7c3ecdae870f279c65a7d9829646618..7ae346a52c72a413d68f770f01767a19a27e11a1 100644 (file)
@@ -325,6 +325,16 @@ iris_get_query_result_resource(struct pipe_context *ctx,
    struct iris_context *ice = (void *) ctx;
    struct iris_query *q = (void *) query;
    struct iris_batch *batch = &ice->render_batch;
+   unsigned snapshots_landed_offset =
+      offsetof(struct iris_query_snapshots, snapshots_landed);
+
+   if (index == -1) {
+      /* They're asking for the availability of the result. */
+      ice->vtbl.copy_mem_mem(batch, iris_resource_bo(p_res), offset,
+                             q->bo, snapshots_landed_offset,
+                             result_type <= PIPE_QUERY_TYPE_U32 ? 4 : 8);
+      return;
+   }
 
    if (!q->ready && q->map->snapshots_landed) {
       /* The final snapshots happen to have landed, so let's just compute
@@ -353,8 +363,7 @@ iris_get_query_result_resource(struct pipe_context *ctx,
    if (predicated) {
       ice->vtbl.load_register_imm64(batch, MI_PREDICATE_SRC1, 0ull);
       ice->vtbl.load_register_mem64(batch, MI_PREDICATE_SRC0, q->bo,
-                                    offsetof(struct iris_query_snapshots,
-                                             snapshots_landed));
+                                    snapshots_landed_offset);
       uint32_t predicate = MI_PREDICATE |
                            MI_PREDICATE_LOADOP_LOADINV |
                            MI_PREDICATE_COMBINEOP_SET |
index e2c8412dc1d7af044b2ecf180e1c4288e53c881f..7882061453c373dc551290a6e6b853740fc7d6e5 100644 (file)
@@ -4121,6 +4121,25 @@ iris_store_data_imm64(struct iris_batch *batch,
    }
 }
 
+static void
+iris_copy_mem_mem(struct iris_batch *batch,
+                  struct iris_bo *dst_bo, uint32_t dst_offset,
+                  struct iris_bo *src_bo, uint32_t src_offset,
+                  unsigned bytes)
+{
+   /* MI_COPY_MEM_MEM operates on DWords. */
+   assert(bytes % 4 == 0);
+   assert(dst_offset % 4 == 0);
+   assert(src_offset % 4 == 0);
+
+   for (unsigned i = 0; i < bytes; i += 4) {
+      iris_emit_cmd(batch, GENX(MI_COPY_MEM_MEM), cp) {
+         cp.DestinationMemoryAddress = rw_bo(dst_bo, dst_offset + i);
+         cp.SourceMemoryAddress = ro_bo(src_bo, src_offset + i);
+      }
+   }
+}
+
 /* ------------------------------------------------------------------- */
 
 static unsigned
@@ -4593,6 +4612,7 @@ genX(init_state)(struct iris_context *ice)
    ice->vtbl.store_register_mem64 = iris_store_register_mem64;
    ice->vtbl.store_data_imm32 = iris_store_data_imm32;
    ice->vtbl.store_data_imm64 = iris_store_data_imm64;
+   ice->vtbl.copy_mem_mem = iris_copy_mem_mem;
    ice->vtbl.derived_program_state_size = iris_derived_program_state_size;
    ice->vtbl.store_derived_program_state = iris_store_derived_program_state;
    ice->vtbl.create_so_decl_list = iris_create_so_decl_list;