Mesa (master): iris: hook up resource creation from memory object

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 20 14:11:14 UTC 2021


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

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Thu Jan 14 13:28:28 2021 +0200

iris: hook up resource creation from memory object

v2:
* Fixed indentation in iris_resource_from_memobj

v3:
* Removed the call to iris_resource_configure_aux, as we don't
  have any auxiliary buffer support.

v4:
* Added a comment about the assertion that there's no aux buffer
  in case we add them later.

v5:
* Changed the logic of iris_resource_from_memobj. When the user doesn't
  explicitly set the tiling to linear, we use a similar logic with the
  anv driver's logic to calculate it instead of querying the kernel.
  This is because the Vulkan driver doesn't perform ioctls to update the
  kernel when it suballocates buffers.

v6:
* Removed the line that sets the modifier info in the resource. We
  shouldn't need it.

v7, v8:
* Removed left over code related to modifiers.

v9:
* Replaced FORCE_LINEAR_TILING flag with PIPE_BIND_LINEAR where
  necessary.

v10: rebase, use iris_resource_configure_main (Tapani)

v11:
* isl surfaces should be created only for textures and not for
  buffers (fixes: pixel buffer tests assertion failure on BDW).

v12:
* fix in return type is required after rebasing to master.

Signed-off--by: Juan A. Suarez Romero <jasuarez at igalia.com>
Signed-off-by: Eleni Maria Stea <estea at igalia.com>
Co-authored-by: Eleni Maria Stea <estea at igalia.com>
Reviewed-by: Rohan Garg <rohan.garg at collabora.com> (v9)
Reviewed-by: Tapani Pälli <tapani.palli at intel.com> (v12)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4337>

---

 src/gallium/drivers/iris/iris_resource.c | 29 +++++++++++++++++++++++++++++
 src/gallium/drivers/iris/iris_resource.h |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 95c4c1ee6cb..c1914b213b3 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -338,6 +338,8 @@ iris_memobj_create_from_handle(struct pipe_screen *pscreen,
 
    memobj->b.dedicated = dedicated;
    memobj->bo = bo;
+   memobj->format = whandle->format;
+   memobj->stride = whandle->stride;
 
    iris_bo_reference(memobj->bo);
 
@@ -1214,6 +1216,32 @@ fail:
    return NULL;
 }
 
+static struct pipe_resource *
+iris_resource_from_memobj(struct pipe_screen *pscreen,
+                          const struct pipe_resource *templ,
+                          struct pipe_memory_object *pmemobj,
+                          uint64_t offset)
+{
+   struct iris_screen *screen = (struct iris_screen *)pscreen;
+   struct iris_memory_object *memobj = (struct iris_memory_object *)pmemobj;
+   struct iris_resource *res = iris_alloc_resource(pscreen, templ);
+
+   if (!res)
+      return NULL;
+
+   if (templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY) {
+      UNUSED const bool isl_surf_created_successfully =
+         iris_resource_configure_main(screen, res, templ, DRM_FORMAT_MOD_INVALID, 0);
+      assert(isl_surf_created_successfully);
+   }
+
+   res->bo = memobj->bo;
+   res->offset = offset;
+   res->external_format = memobj->format;
+
+   return &res->base.b;
+}
+
 static void
 iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource)
 {
@@ -2347,6 +2375,7 @@ iris_init_screen_resource_functions(struct pipe_screen *pscreen)
    pscreen->resource_create = u_transfer_helper_resource_create;
    pscreen->resource_from_user_memory = iris_resource_from_user_memory;
    pscreen->resource_from_handle = iris_resource_from_handle;
+   pscreen->resource_from_memobj = iris_resource_from_memobj;
    pscreen->resource_get_handle = iris_resource_get_handle;
    pscreen->resource_get_param = iris_resource_get_param;
    pscreen->resource_destroy = u_transfer_helper_resource_destroy;
diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h
index 69867e0741e..7b146f0ce76 100644
--- a/src/gallium/drivers/iris/iris_resource.h
+++ b/src/gallium/drivers/iris/iris_resource.h
@@ -283,6 +283,8 @@ struct iris_transfer {
 struct iris_memory_object {
    struct pipe_memory_object b;
    struct iris_bo *bo;
+   uint64_t format;
+   unsigned stride;
 };
 
 /**



More information about the mesa-commit mailing list