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

Author: Nanley Chery <[email protected]>
Date:   Tue Jul 11 12:01:26 2023 -0400

iris: Remap DRM_FORMAT_MOD_INVALID more often during import

We'd eventually like to use an ISL helper that doesn't support
DRM_FORMAT_MOD_INVALID. Prepare for this by replacing the invalid value
with the modifier associated with the BO's tiling in more cases.

Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24120>

---

 src/gallium/drivers/iris/iris_resource.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_resource.c 
b/src/gallium/drivers/iris/iris_resource.c
index 68f5a43c3e0..29aa5221c32 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -1464,20 +1464,21 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
    if (!res->bo)
       goto fail;
 
+   uint64_t modifier;
+   if (whandle->modifier == DRM_FORMAT_MOD_INVALID) {
+      /* We don't have a modifier; match whatever GEM_GET_TILING says */
+      uint32_t tiling;
+      iris_gem_get_tiling(res->bo, &tiling);
+      modifier = tiling_to_modifier(tiling);
+   } else {
+      modifier = whandle->modifier;
+   }
+
    res->offset = whandle->offset;
    res->external_format = whandle->format;
 
    /* Create a surface for each plane specified by the external format. */
    if (whandle->plane < util_format_get_num_planes(whandle->format)) {
-      uint64_t modifier = whandle->modifier;
-
-      if (whandle->modifier == DRM_FORMAT_MOD_INVALID) {
-         /* We don't have a modifier; match whatever GEM_GET_TILING says */
-         uint32_t tiling;
-         iris_gem_get_tiling(res->bo, &tiling);
-         modifier = tiling_to_modifier(tiling);
-      }
-
       const bool isl_surf_created_successfully =
          iris_resource_configure_main(screen, res, templ, modifier,
                                       whandle->stride);
@@ -1491,7 +1492,7 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
        * aux image. iris_resource_finish_aux_import will merge the separate aux
        * parameters back into a single iris_resource.
        */
-   } else if (mod_plane_is_clear_color(whandle->modifier, whandle->plane)) {
+   } else if (mod_plane_is_clear_color(modifier, whandle->plane)) {
       res->aux.clear_color_offset = whandle->offset;
       res->aux.clear_color_bo = res->bo;
       res->bo = NULL;
@@ -1507,8 +1508,7 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
    }
 
    if (get_num_planes(&res->base.b) ==
-       iris_get_dmabuf_modifier_planes(pscreen, whandle->modifier,
-                                       whandle->format)) {
+       iris_get_dmabuf_modifier_planes(pscreen, modifier, whandle->format)) {
       iris_resource_finish_aux_import(pscreen, res);
    }
 

Reply via email to