Mesa (main): iris: Add a MEMZONE_BINDLESS and uploader

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 25 00:41:23 UTC 2021


Module: Mesa
Branch: main
Commit: 545011b445b31279e9c6b837b71f2953fa42f1f5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=545011b445b31279e9c6b837b71f2953fa42f1f5

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Tue Oct 20 21:29:50 2020 -0500

iris: Add a MEMZONE_BINDLESS and uploader

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11582>

---

 src/gallium/drivers/iris/iris_binder.c   |  2 +-
 src/gallium/drivers/iris/iris_bufmgr.c   | 28 ++++++++++++++++++----------
 src/gallium/drivers/iris/iris_bufmgr.h   |  5 ++++-
 src/gallium/drivers/iris/iris_context.c  |  4 ++++
 src/gallium/drivers/iris/iris_context.h  |  1 +
 src/gallium/drivers/iris/iris_resource.c |  6 +++++-
 src/gallium/drivers/iris/iris_resource.h |  7 ++++---
 src/gallium/drivers/iris/iris_state.c    |  2 ++
 8 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_binder.c b/src/gallium/drivers/iris/iris_binder.c
index 46f3aca3dfa..f41444e6009 100644
--- a/src/gallium/drivers/iris/iris_binder.c
+++ b/src/gallium/drivers/iris/iris_binder.c
@@ -78,7 +78,7 @@ binder_realloc(struct iris_context *ice)
        * end of the memory zone...then wrap around to the start again.
        */
       next_address = binder->bo->gtt_offset + IRIS_BINDER_SIZE;
-      if (next_address >= IRIS_MEMZONE_SURFACE_START)
+      if (next_address >= IRIS_MEMZONE_BINDLESS_START)
          next_address = IRIS_MEMZONE_BINDER_START;
 
       iris_bo_unreference(binder->bo);
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 7cdb4474d98..e74ca19fcda 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -129,11 +129,12 @@ static const char *
 memzone_name(enum iris_memory_zone memzone)
 {
    const char *names[] = {
-      [IRIS_MEMZONE_SHADER]  = "shader",
-      [IRIS_MEMZONE_BINDER]  = "binder",
-      [IRIS_MEMZONE_SURFACE] = "surface",
-      [IRIS_MEMZONE_DYNAMIC] = "dynamic",
-      [IRIS_MEMZONE_OTHER]   = "other",
+      [IRIS_MEMZONE_SHADER]   = "shader",
+      [IRIS_MEMZONE_BINDER]   = "binder",
+      [IRIS_MEMZONE_BINDLESS] = "scratchsurf",
+      [IRIS_MEMZONE_SURFACE]  = "surface",
+      [IRIS_MEMZONE_DYNAMIC]  = "dynamic",
+      [IRIS_MEMZONE_OTHER]    = "other",
       [IRIS_MEMZONE_BORDER_COLOR_POOL] = "bordercolor",
    };
    assert(memzone < ARRAY_SIZE(names));
@@ -285,10 +286,11 @@ bucket_for_size(struct iris_bufmgr *bufmgr, uint64_t size, bool local)
 enum iris_memory_zone
 iris_memzone_for_address(uint64_t address)
 {
-   STATIC_ASSERT(IRIS_MEMZONE_OTHER_START   > IRIS_MEMZONE_DYNAMIC_START);
-   STATIC_ASSERT(IRIS_MEMZONE_DYNAMIC_START > IRIS_MEMZONE_SURFACE_START);
-   STATIC_ASSERT(IRIS_MEMZONE_SURFACE_START > IRIS_MEMZONE_BINDER_START);
-   STATIC_ASSERT(IRIS_MEMZONE_BINDER_START  > IRIS_MEMZONE_SHADER_START);
+   STATIC_ASSERT(IRIS_MEMZONE_OTHER_START    > IRIS_MEMZONE_DYNAMIC_START);
+   STATIC_ASSERT(IRIS_MEMZONE_DYNAMIC_START  > IRIS_MEMZONE_SURFACE_START);
+   STATIC_ASSERT(IRIS_MEMZONE_SURFACE_START  > IRIS_MEMZONE_BINDLESS_START);
+   STATIC_ASSERT(IRIS_MEMZONE_BINDLESS_START > IRIS_MEMZONE_BINDER_START);
+   STATIC_ASSERT(IRIS_MEMZONE_BINDER_START   > IRIS_MEMZONE_SHADER_START);
    STATIC_ASSERT(IRIS_BORDER_COLOR_POOL_ADDRESS == IRIS_MEMZONE_DYNAMIC_START);
 
    if (address >= IRIS_MEMZONE_OTHER_START)
@@ -303,6 +305,9 @@ iris_memzone_for_address(uint64_t address)
    if (address >= IRIS_MEMZONE_SURFACE_START)
       return IRIS_MEMZONE_SURFACE;
 
+   if (address >= IRIS_MEMZONE_BINDLESS_START)
+      return IRIS_MEMZONE_BINDLESS;
+
    if (address >= IRIS_MEMZONE_BINDER_START)
       return IRIS_MEMZONE_BINDER;
 
@@ -1761,9 +1766,12 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse)
 
    util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_SHADER],
                       PAGE_SIZE, _4GB_minus_1 - PAGE_SIZE);
+   util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_BINDLESS],
+                      IRIS_MEMZONE_BINDLESS_START, IRIS_BINDLESS_SIZE);
    util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_SURFACE],
                       IRIS_MEMZONE_SURFACE_START,
-                      _4GB_minus_1 - IRIS_MAX_BINDERS * IRIS_BINDER_SIZE);
+                      _4GB_minus_1 - IRIS_MAX_BINDERS * IRIS_BINDER_SIZE -
+                     IRIS_BINDLESS_SIZE);
    /* TODO: Why does limiting to 2GB help some state items on gfx12?
     *  - CC Viewport Pointer
     *  - Blend State Pointer
diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h
index 30b004e5c7d..7b235de5161 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.h
+++ b/src/gallium/drivers/iris/iris_bufmgr.h
@@ -69,6 +69,7 @@ struct isl_surf;
 enum iris_memory_zone {
    IRIS_MEMZONE_SHADER,
    IRIS_MEMZONE_BINDER,
+   IRIS_MEMZONE_BINDLESS,
    IRIS_MEMZONE_SURFACE,
    IRIS_MEMZONE_DYNAMIC,
    IRIS_MEMZONE_OTHER,
@@ -81,10 +82,12 @@ enum iris_memory_zone {
 
 #define IRIS_BINDER_SIZE (64 * 1024)
 #define IRIS_MAX_BINDERS 100
+#define IRIS_BINDLESS_SIZE (8 * 1024 * 1024)
 
 #define IRIS_MEMZONE_SHADER_START     (0ull * (1ull << 32))
 #define IRIS_MEMZONE_BINDER_START     (1ull * (1ull << 32))
-#define IRIS_MEMZONE_SURFACE_START    (IRIS_MEMZONE_BINDER_START + IRIS_MAX_BINDERS * IRIS_BINDER_SIZE)
+#define IRIS_MEMZONE_BINDLESS_START   (IRIS_MEMZONE_BINDER_START + IRIS_MAX_BINDERS * IRIS_BINDER_SIZE)
+#define IRIS_MEMZONE_SURFACE_START    (IRIS_MEMZONE_BINDLESS_START + IRIS_BINDLESS_SIZE)
 #define IRIS_MEMZONE_DYNAMIC_START    (2ull * (1ull << 32))
 #define IRIS_MEMZONE_OTHER_START      (3ull * (1ull << 32))
 
diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c
index 20ae4af49f7..7bec71f2ef3 100644
--- a/src/gallium/drivers/iris/iris_context.c
+++ b/src/gallium/drivers/iris/iris_context.c
@@ -229,6 +229,7 @@ iris_destroy_context(struct pipe_context *ctx)
       iris_destroy_ctx_measure(ice);
 
    u_upload_destroy(ice->state.surface_uploader);
+   u_upload_destroy(ice->state.bindless_uploader);
    u_upload_destroy(ice->state.dynamic_uploader);
    u_upload_destroy(ice->query_buffer_uploader);
 
@@ -326,6 +327,9 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
    ice->state.surface_uploader =
       u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
                       IRIS_RESOURCE_FLAG_SURFACE_MEMZONE);
+   ice->state.bindless_uploader =
+      u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
+                      IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE);
    ice->state.dynamic_uploader =
       u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
                       IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE);
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index f34aeadd6fa..18a6ff6a327 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -768,6 +768,7 @@ struct iris_context {
       struct iris_state_ref null_fb;
 
       struct u_upload_mgr *surface_uploader;
+      struct u_upload_mgr *bindless_uploader;
       struct u_upload_mgr *dynamic_uploader;
 
       struct iris_binder binder;
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 5bdc7a2b62c..6e624993c80 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -982,6 +982,9 @@ iris_resource_create_for_buffer(struct pipe_screen *pscreen,
    } else if (templ->flags & IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE) {
       memzone = IRIS_MEMZONE_DYNAMIC;
       name = "dynamic state";
+   } else if (templ->flags & IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE) {
+      memzone = IRIS_MEMZONE_BINDLESS;
+      name = "bindless surface state";
    }
 
    unsigned flags = iris_resource_alloc_flags(screen, templ);
@@ -1035,7 +1038,8 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen,
    /* These are for u_upload_mgr buffers only */
    assert(!(templ->flags & (IRIS_RESOURCE_FLAG_SHADER_MEMZONE |
                             IRIS_RESOURCE_FLAG_SURFACE_MEMZONE |
-                            IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE)));
+                            IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE |
+                            IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE)));
 
    if (!iris_resource_configure_aux(screen, res, false))
       goto fail;
diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h
index 90105c40d55..ff4ce11374d 100644
--- a/src/gallium/drivers/iris/iris_resource.h
+++ b/src/gallium/drivers/iris/iris_resource.h
@@ -41,9 +41,10 @@ struct iris_format_info {
    struct isl_swizzle swizzle;
 };
 
-#define IRIS_RESOURCE_FLAG_SHADER_MEMZONE  (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
-#define IRIS_RESOURCE_FLAG_SURFACE_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
-#define IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
+#define IRIS_RESOURCE_FLAG_SHADER_MEMZONE   (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
+#define IRIS_RESOURCE_FLAG_SURFACE_MEMZONE  (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
+#define IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE  (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
+#define IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
 
 /**
  * Resources represent a GPU buffer object or image (mipmap tree).
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index abb315ebdb4..9e14fb29596 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -721,6 +721,8 @@ init_state_base_address(struct iris_batch *batch)
       sba.GeneralStateBufferSizeModifyEnable    = true;
       sba.DynamicStateBufferSizeModifyEnable    = true;
 #if (GFX_VER >= 9)
+      sba.BindlessSurfaceStateBaseAddress = ro_bo(NULL, IRIS_MEMZONE_BINDLESS_START);
+      sba.BindlessSurfaceStateSize = (IRIS_BINDLESS_SIZE >> 12) - 1;
       sba.BindlessSurfaceStateBaseAddressModifyEnable = true;
       sba.BindlessSurfaceStateMOCS    = mocs;
 #endif



More information about the mesa-commit mailing list