iris: try to set the specified tiling when importing a dmabuf
When importing a dmabuf with a specified tiling, the dmabuf user should always try to set the tiling mode because: 1) the exporter can set tiling AFTER exporting/importing. 2) a dmabuf could be exported from a kernel driver other than i915, in this case the dmabuf user and exporter need to set tiling separately. This patch fixes a problem when running vkmark under weston with iris on ICL, it crashed to console with the following assert. i965 doesn't have this problem as it always tries to set the specified tiling mode. weston: ../src/gallium/drivers/iris/iris_resource.c:990: iris_resource_from_handle: Assertion `res->bo->tiling_mode == isl_tiling_to_i915_tiling(res->surf.tiling)' failed. Signed-off-by: James Xiong <james.xiong@intel.com> Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
This commit is contained in:
committed by
Rafael Antognolli
parent
fc7b748086
commit
b6d45e7f74
@@ -1294,7 +1294,8 @@ iris_bo_get_tiling(struct iris_bo *bo, uint32_t *tiling_mode,
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -1345,9 +1346,15 @@ iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd)
|
||||
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);
|
||||
|
||||
@@ -352,7 +352,8 @@ int iris_hw_context_set_priority(struct iris_bufmgr *bufmgr,
|
||||
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);
|
||||
|
||||
|
||||
@@ -960,12 +960,21 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
|
||||
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",
|
||||
@@ -979,12 +988,13 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user