}
struct iris_bo *
-iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd)
+iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
+ uint32_t tiling, uint32_t stride)
{
uint32_t handle;
struct iris_bo *bo;
if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
goto err;
- bo->tiling_mode = get_tiling.tiling_mode;
- bo->swizzle_mode = get_tiling.swizzle_mode;
- /* XXX stride is unknown */
+ if (get_tiling.tiling_mode == tiling || tiling > I915_TILING_LAST) {
+ bo->tiling_mode = get_tiling.tiling_mode;
+ bo->swizzle_mode = get_tiling.swizzle_mode;
+ /* XXX stride is unknown */
+ } else {
+ if (bo_set_tiling_internal(bo, tiling, stride)) {
+ goto err;
+ }
+ }
out:
mtx_unlock(&bufmgr->lock);
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);
+struct iris_bo *iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd,
+ uint32_t tiling, uint32_t stride);
uint32_t iris_bo_export_gem_handle(struct iris_bo *bo);
struct gen_device_info *devinfo = &screen->devinfo;
struct iris_bufmgr *bufmgr = screen->bufmgr;
struct iris_resource *res = iris_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:
- res->bo = iris_bo_import_dmabuf(bufmgr, whandle->handle);
+ if (mod_inf)
+ tiling = isl_tiling_to_i915_tiling(mod_inf->tiling);
+ else
+ tiling = I915_TILING_LAST + 1;
+ res->bo = iris_bo_import_dmabuf(bufmgr, whandle->handle,
+ tiling, whandle->stride);
break;
case WINSYS_HANDLE_TYPE_SHARED:
res->bo = iris_bo_gem_create_from_name(bufmgr, "winsys image",
res->offset = whandle->offset;
- uint64_t modifier = whandle->modifier;
- if (modifier == DRM_FORMAT_MOD_INVALID) {
- modifier = tiling_to_modifier(res->bo->tiling_mode);
+ if (mod_inf == NULL) {
+ mod_inf =
+ isl_drm_modifier_get_info(tiling_to_modifier(res->bo->tiling_mode));
}
- res->mod_info = isl_drm_modifier_get_info(modifier);
- assert(res->mod_info);
+ assert(mod_inf);
+
+ res->mod_info = mod_inf;
isl_surf_usage_flags_t isl_usage = pipe_bind_to_isl_usage(templ->bind);