+static bool
+iris_resource_configure_main(const struct iris_screen *screen,
+ struct iris_resource *res,
+ const struct pipe_resource *templ,
+ uint64_t modifier, uint32_t row_pitch_B)
+{
+ res->mod_info = isl_drm_modifier_get_info(modifier);
+
+ if (modifier != DRM_FORMAT_MOD_INVALID && res->mod_info == NULL)
+ return false;
+
+ isl_tiling_flags_t tiling_flags = 0;
+
+ if (res->mod_info != NULL) {
+ tiling_flags = 1 << res->mod_info->tiling;
+ } else if (templ->usage == PIPE_USAGE_STAGING ||
+ templ->bind & (PIPE_BIND_LINEAR | PIPE_BIND_CURSOR)) {
+ tiling_flags = ISL_TILING_LINEAR_BIT;
+ } else if (templ->bind & PIPE_BIND_SCANOUT) {
+ tiling_flags = screen->devinfo.has_tiling_uapi ?
+ ISL_TILING_X_BIT : ISL_TILING_LINEAR_BIT;
+ } else {
+ tiling_flags = ISL_TILING_ANY_MASK;
+ }
+
+ isl_surf_usage_flags_t usage = 0;
+
+ if (templ->bind & PIPE_BIND_RENDER_TARGET)
+ usage |= ISL_SURF_USAGE_RENDER_TARGET_BIT;
+
+ if (templ->bind & PIPE_BIND_SAMPLER_VIEW)
+ usage |= ISL_SURF_USAGE_TEXTURE_BIT;
+
+ if (templ->bind & PIPE_BIND_SHADER_IMAGE)
+ usage |= ISL_SURF_USAGE_STORAGE_BIT;
+
+ if (templ->bind & PIPE_BIND_SCANOUT)
+ usage |= ISL_SURF_USAGE_DISPLAY_BIT;
+
+ if (templ->target == PIPE_TEXTURE_CUBE ||
+ templ->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ usage |= ISL_SURF_USAGE_CUBE_BIT;
+ }
+
+ if (templ->usage != PIPE_USAGE_STAGING &&
+ util_format_is_depth_or_stencil(templ->format)) {
+
+ /* Should be handled by u_transfer_helper */
+ assert(!util_format_is_depth_and_stencil(templ->format));
+
+ usage |= templ->format == PIPE_FORMAT_S8_UINT ?
+ ISL_SURF_USAGE_STENCIL_BIT : ISL_SURF_USAGE_DEPTH_BIT;
+ }
+
+ const enum isl_format format =
+ iris_format_for_usage(&screen->devinfo, templ->format, usage).fmt;
+
+ const struct isl_surf_init_info init_info = {
+ .dim = target_to_isl_surf_dim(templ->target),
+ .format = format,
+ .width = templ->width0,
+ .height = templ->height0,
+ .depth = templ->depth0,
+ .levels = templ->last_level + 1,
+ .array_len = templ->array_size,
+ .samples = MAX2(templ->nr_samples, 1),
+ .min_alignment_B = 0,
+ .row_pitch_B = row_pitch_B,
+ .usage = usage,
+ .tiling_flags = tiling_flags
+ };
+
+ if (!isl_surf_init_s(&screen->isl_dev, &res->surf, &init_info))
+ return false;
+
+ res->internal_format = templ->format;
+
+ return true;
+}
+