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 <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24120>
This commit is contained in:
Nanley Chery 2023-07-11 12:01:26 -04:00 committed by Marge Bot
parent ba071ee81c
commit c042eb653d

View file

@ -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);
}