Mesa (master): iris: Map each surf to it's aux-surf in the aux-map tables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 28 07:46:34 UTC 2019


Module: Mesa
Branch: master
Commit: f046c6d0906ebb7068126415804123950bc23c1c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f046c6d0906ebb7068126415804123950bc23c1c

Author: Jordan Justen <jordan.l.justen at intel.com>
Date:   Sat Apr 28 01:58:54 2018 -0700

iris: Map each surf to it's aux-surf in the aux-map tables

Rework: Nanley Chery
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/gallium/drivers/iris/iris_bufmgr.c   | 19 +++++++++++++++++++
 src/gallium/drivers/iris/iris_resource.c | 17 +++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 1624257729a..21c0d517861 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -395,6 +395,20 @@ alloc_bo_from_cache(struct iris_bufmgr *bufmgr,
    if (!bo)
       return NULL;
 
+   if (bo->aux_map_address) {
+      /* This buffer was associated with an aux-buffer range. We make sure
+       * that buffers are not reused from the cache while the buffer is (busy)
+       * being used by an executing batch. Since we are here, the buffer is no
+       * longer being used by a batch and the buffer was deleted (in order to
+       * end up in the cache). Therefore its old aux-buffer range can be
+       * removed from the aux-map.
+       */
+      if (bo->bufmgr->aux_map_ctx)
+         gen_aux_map_unmap_range(bo->bufmgr->aux_map_ctx, bo->gtt_offset,
+                                 bo->size);
+      bo->aux_map_address = 0;
+   }
+
    /* If the cached BO isn't in the right memory zone, or the alignment
     * isn't sufficient, free the old memory and assign it a new address.
     */
@@ -730,6 +744,11 @@ bo_close(struct iris_bo *bo)
           bo->gem_handle, bo->name, strerror(errno));
    }
 
+   if (bo->aux_map_address && bo->bufmgr->aux_map_ctx) {
+      gen_aux_map_unmap_range(bo->bufmgr->aux_map_ctx, bo->gtt_offset,
+                              bo->size);
+   }
+
    /* Return the VMA for reuse */
    vma_free(bo->bufmgr, bo->gtt_offset, bo->size);
 
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 5e532e80100..3ad0874094d 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -47,6 +47,7 @@
 #include "iris_context.h"
 #include "iris_resource.h"
 #include "iris_screen.h"
+#include "intel/common/gen_aux_map.h"
 #include "intel/dev/gen_debug.h"
 #include "isl/isl.h"
 #include "drm-uapi/drm_fourcc.h"
@@ -384,6 +385,19 @@ iris_get_aux_clear_color_state_size(struct iris_screen *screen)
    return devinfo->gen >= 10 ? screen->isl_dev.ss.clear_color_state_size : 0;
 }
 
+static void
+map_aux_addresses(struct iris_screen *screen, struct iris_resource *res)
+{
+   const struct gen_device_info *devinfo = &screen->devinfo;
+   if (devinfo->gen >= 12 && isl_aux_usage_has_ccs(res->aux.usage)) {
+      void *aux_map_ctx = iris_bufmgr_get_aux_map_context(screen->bufmgr);
+      assert(aux_map_ctx);
+      gen_aux_map_add_image(aux_map_ctx, &res->surf, res->bo->gtt_offset,
+                            res->aux.bo->gtt_offset + res->aux.offset);
+      res->bo->aux_map_address = res->aux.bo->gtt_offset;
+   }
+}
+
 /**
  * Configure aux for the resource, but don't allocate it. For images which
  * might be shared with modifiers, we must allocate the image and aux data in
@@ -560,6 +574,8 @@ iris_resource_alloc_separate_aux(struct iris_screen *screen,
                                    iris_get_aux_clear_color_state_size(screen)))
       return false;
 
+   map_aux_addresses(screen, res);
+
    return true;
 }
 
@@ -846,6 +862,7 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen,
             res->aux.clear_color_offset += aux_offset;
          if (!iris_resource_init_aux_buf(res, flags, clear_color_state_size))
             aux_enabled = false;
+         map_aux_addresses(screen, res);
       }
    }
 




More information about the mesa-commit mailing list