Mesa (main): crocus: Make iris_bo_import_dmabuf take a modifier

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 00:13:26 UTC 2021


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

Author: Dave Airlie <airlied at gmail.com>
Date:   Mon Jun 14 11:51:37 2021 +1000

crocus: Make iris_bo_import_dmabuf take a modifier

Port 493298528a82e2ab7cf3ce6aed187fe19730e3d0 from iris

    Replace the tiling parameter with a modifier parameter. I find it more
    straightforward to have this function figure out the tiling from the
    modifier than to have its caller do it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11352>

---

 src/gallium/drivers/crocus/crocus_bufmgr.c   | 9 +++++----
 src/gallium/drivers/crocus/crocus_bufmgr.h   | 2 +-
 src/gallium/drivers/crocus/crocus_resource.c | 7 +------
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.c b/src/gallium/drivers/crocus/crocus_bufmgr.c
index 68e8453f581..e013cbf9854 100644
--- a/src/gallium/drivers/crocus/crocus_bufmgr.c
+++ b/src/gallium/drivers/crocus/crocus_bufmgr.c
@@ -1219,7 +1219,7 @@ crocus_bo_get_tiling(struct crocus_bo *bo, uint32_t *tiling_mode,
 
 struct crocus_bo *
 crocus_bo_import_dmabuf(struct crocus_bufmgr *bufmgr, int prime_fd,
-                        uint32_t tiling)
+                        uint64_t modifier)
 {
    uint32_t handle;
    struct crocus_bo *bo;
@@ -1265,9 +1265,10 @@ crocus_bo_import_dmabuf(struct crocus_bufmgr *bufmgr, int prime_fd,
    bo->gem_handle = handle;
    _mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo);
 
-   if (tiling != -1) {
-      /* Modifiers path */
-      bo->tiling_mode = tiling;
+   const struct isl_drm_modifier_info *mod_info =
+      isl_drm_modifier_get_info(modifier);
+   if (mod_info) {
+      bo->tiling_mode = isl_tiling_to_i915_tiling(mod_info->tiling);
    } else if (bufmgr->has_tiling_uapi) {
       struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
       if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.h b/src/gallium/drivers/crocus/crocus_bufmgr.h
index 52b6d58a078..21595e8117a 100644
--- a/src/gallium/drivers/crocus/crocus_bufmgr.h
+++ b/src/gallium/drivers/crocus/crocus_bufmgr.h
@@ -306,7 +306,7 @@ void crocus_destroy_hw_context(struct crocus_bufmgr *bufmgr, uint32_t ctx_id);
 
 int crocus_bo_export_dmabuf(struct crocus_bo *bo, int *prime_fd);
 struct crocus_bo *crocus_bo_import_dmabuf(struct crocus_bufmgr *bufmgr,
-                                          int prime_fd, uint32_t tiling);
+                                          int prime_fd, uint64_t modifier);
 
 /**
  * Exports a bo as a GEM handle into a given DRM file descriptor
diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c
index bb67d6f5377..397b1714e9c 100644
--- a/src/gallium/drivers/crocus/crocus_resource.c
+++ b/src/gallium/drivers/crocus/crocus_resource.c
@@ -856,19 +856,14 @@ crocus_resource_from_handle(struct pipe_screen *pscreen,
    struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
    const struct isl_drm_modifier_info *mod_inf =
       isl_drm_modifier_get_info(whandle->modifier);
-   uint32_t tiling;
 
    if (!res)
       return NULL;
 
    switch (whandle->type) {
    case WINSYS_HANDLE_TYPE_FD:
-      if (mod_inf)
-         tiling = isl_tiling_to_i915_tiling(mod_inf->tiling);
-      else
-         tiling = I915_TILING_LAST + 1;
       res->bo = crocus_bo_import_dmabuf(bufmgr, whandle->handle,
-                                        tiling);
+                                        whandle->modifier);
       break;
    case WINSYS_HANDLE_TYPE_SHARED:
       res->bo = crocus_bo_gem_create_from_name(bufmgr, "winsys image",



More information about the mesa-commit mailing list