[Mesa-dev] [PATCH 05/17] i965: Drop CPU-side shadow copy of the batchbuffer for non-LLC systems.

Kenneth Graunke kenneth at whitecape.org
Wed Sep 6 00:09:38 UTC 2017


Now that we have write-combining maps, our writes to the batch should be
reasonably fast.  (In the past, we only had uncached maps, which were
slow...so we kept a CPU-side shadow copy for write combining purposes.)

There are a few places that still read back a DWord or so from the
batch, which will unfortunately now have uncached performance.  We
should eliminate those.

XXX: benchmark, see if this is something we can live with for now, or
if we really need to fix it right away.
---
 src/mesa/drivers/dri/i965/brw_context.h       |  1 -
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 34 +++++----------------------
 2 files changed, 6 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 92fc16de136..b3a8fa01aff 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -448,7 +448,6 @@ struct intel_batchbuffer {
    uint16_t reserved_space;
    uint32_t *map_next;
    uint32_t *map;
-   uint32_t *cpu_map;
 
    uint32_t state_batch_offset;
    enum brw_gpu_ring ring;
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index a7243a27aeb..9b37470f926 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -44,8 +44,7 @@
 
 static void
 intel_batchbuffer_reset(struct intel_batchbuffer *batch,
-                        struct brw_bufmgr *bufmgr,
-                        bool has_llc);
+                        struct brw_bufmgr *bufmgr);
 
 static bool
 uint_key_compare(const void *a, const void *b)
@@ -66,12 +65,6 @@ intel_batchbuffer_init(struct intel_screen *screen,
    struct brw_bufmgr *bufmgr = screen->bufmgr;
    const struct gen_device_info *devinfo = &screen->devinfo;
 
-   if (!devinfo->has_llc) {
-      batch->cpu_map = malloc(BATCH_SZ);
-      batch->map = batch->cpu_map;
-      batch->map_next = batch->cpu_map;
-   }
-
    batch->reloc_count = 0;
    batch->reloc_array_size = 250;
    batch->relocs = malloc(batch->reloc_array_size *
@@ -96,7 +89,7 @@ intel_batchbuffer_init(struct intel_screen *screen,
    if (devinfo->gen == 6)
       batch->valid_reloc_flags |= EXEC_OBJECT_NEEDS_GTT;
 
-   intel_batchbuffer_reset(batch, bufmgr, devinfo->has_llc);
+   intel_batchbuffer_reset(batch, bufmgr);
 }
 
 #define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
@@ -144,8 +137,7 @@ add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo *bo)
 
 static void
 intel_batchbuffer_reset(struct intel_batchbuffer *batch,
-                        struct brw_bufmgr *bufmgr,
-                        bool has_llc)
+                        struct brw_bufmgr *bufmgr)
 {
    if (batch->last_bo != NULL) {
       brw_bo_unreference(batch->last_bo);
@@ -154,9 +146,7 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch,
    batch->last_bo = batch->bo;
 
    batch->bo = brw_bo_alloc(bufmgr, "batchbuffer", BATCH_SZ, 4096);
-   if (has_llc) {
-      batch->map = brw_bo_map(NULL, batch->bo, MAP_READ | MAP_WRITE);
-   }
+   batch->map = brw_bo_map(NULL, batch->bo, MAP_READ | MAP_WRITE);
    batch->map_next = batch->map;
 
    add_exec_bo(batch, batch->bo);
@@ -179,9 +169,7 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch,
 static void
 intel_batchbuffer_reset_and_clear_render_cache(struct brw_context *brw)
 {
-   const struct gen_device_info *devinfo = &brw->screen->devinfo;
-
-   intel_batchbuffer_reset(&brw->batch, brw->bufmgr, devinfo->has_llc);
+   intel_batchbuffer_reset(&brw->batch, brw->bufmgr);
    brw_render_cache_set_clear(brw);
 }
 
@@ -629,17 +617,7 @@ do_flush_locked(struct brw_context *brw, int in_fence_fd, int *out_fence_fd)
    struct intel_batchbuffer *batch = &brw->batch;
    int ret = 0;
 
-   if (devinfo->has_llc) {
-      brw_bo_unmap(batch->bo);
-   } else {
-      ret = brw_bo_subdata(batch->bo, 0, 4 * USED_BATCH(*batch), batch->map);
-      if (ret == 0 && batch->state_batch_offset != batch->bo->size) {
-         ret = brw_bo_subdata(batch->bo,
-                              batch->state_batch_offset,
-                              batch->bo->size - batch->state_batch_offset,
-                              (char *)batch->map + batch->state_batch_offset);
-      }
-   }
+   brw_bo_unmap(batch->bo);
 
    if (!brw->screen->no_hw) {
       /* The requirement for using I915_EXEC_NO_RELOC are:
-- 
2.14.1



More information about the mesa-dev mailing list