iris: Make iris_bo_import_dmabuf take a modifier
authorNanley Chery <nanley.g.chery@intel.com>
Thu, 30 Jul 2020 18:47:23 +0000 (11:47 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 13 Aug 2020 22:03:48 +0000 (22:03 +0000)
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.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6296>

src/gallium/drivers/iris/iris_bufmgr.c
src/gallium/drivers/iris/iris_bufmgr.h
src/gallium/drivers/iris/iris_resource.c

index a2f60f175afca7dbb476150951219d0faeb9dff5..b733ab330befb8719dd04eab139690b0ac71fe2a 100644 (file)
@@ -1381,7 +1381,7 @@ bo_set_tiling_internal(struct iris_bo *bo, uint32_t tiling_mode,
 
 struct iris_bo *
 iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
-                      int tiling)
+                      uint64_t modifier)
 {
    uint32_t handle;
    struct iris_bo *bo;
@@ -1441,9 +1441,10 @@ iris_bo_import_dmabuf(struct iris_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 (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
index a2fe96842468827d143f9400858e5740b6b205cc..b78794c9be23351b0a6f1e7407c8a35b93fa794a 100644 (file)
@@ -396,7 +396,7 @@ void iris_destroy_hw_context(struct iris_bufmgr *bufmgr, uint32_t ctx_id);
 
 int iris_bo_export_dmabuf(struct iris_bo *bo, int *prime_fd);
 struct iris_bo *iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
-                                      int tiling);
+                                      uint64_t modifier);
 
 /**
  * Exports a bo as a GEM handle into a given DRM file descriptor
index 53643d1b16c3cdca54d4cf9a9de4045a65433c75..d0cda57642fc266b06edb6090e9c6113fd5f4f8b 100644 (file)
@@ -1034,19 +1034,14 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
    struct iris_resource *res = iris_alloc_resource(pscreen, templ);
    const struct isl_drm_modifier_info *mod_inf =
           isl_drm_modifier_get_info(whandle->modifier);
-   int 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 = -1;
       res->bo = iris_bo_import_dmabuf(bufmgr, whandle->handle,
-                                      tiling);
+                                      whandle->modifier);
       break;
    case WINSYS_HANDLE_TYPE_SHARED:
       res->bo = iris_bo_gem_create_from_name(bufmgr, "winsys image",