summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <[email protected]>2018-06-02 12:32:19 +0100
committerKenneth Graunke <[email protected]>2019-02-21 10:26:06 -0800
commita504b98e7202ebd0aac4ad9bf7a919c00bd1f64f (patch)
treeb7dcabfdf090aff0298f3dc31606d69a2461c9ec
parentbadefe50a06d9e7196367dcaa1f233ff68d5c67c (diff)
iris: fix import from dri2/3
-rw-r--r--src/gallium/drivers/iris/iris_resource.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 6c90f01085b..dde859ab795 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -289,6 +289,20 @@ iris_resource_create(struct pipe_screen *pscreen,
return iris_resource_create_with_modifiers(pscreen, templ, NULL, 0);
}
+static uint64_t
+tiling_to_modifier(uint32_t tiling)
+{
+ static const uint64_t map[] = {
+ [I915_TILING_NONE] = DRM_FORMAT_MOD_LINEAR,
+ [I915_TILING_X] = I915_FORMAT_MOD_X_TILED,
+ [I915_TILING_Y] = I915_FORMAT_MOD_Y_TILED,
+ };
+
+ assert(tiling < ARRAY_SIZE(map));
+
+ return map[tiling];
+}
+
static struct pipe_resource *
iris_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *templ,
@@ -308,19 +322,26 @@ iris_resource_from_handle(struct pipe_screen *pscreen,
}
switch (whandle->type) {
- case WINSYS_HANDLE_TYPE_SHARED:
+ case WINSYS_HANDLE_TYPE_FD:
res->bo = iris_bo_import_dmabuf(bufmgr, whandle->handle);
break;
- case WINSYS_HANDLE_TYPE_FD:
+ case WINSYS_HANDLE_TYPE_SHARED:
res->bo = iris_bo_gem_create_from_name(bufmgr, "winsys image",
whandle->handle);
break;
default:
unreachable("invalid winsys handle type");
}
+ if (!res->bo)
+ return NULL;
+ uint64_t modifier = whandle->modifier;
+ if (modifier == DRM_FORMAT_MOD_INVALID) {
+ modifier = tiling_to_modifier(res->bo->tiling_mode);
+ }
const struct isl_drm_modifier_info *mod_info =
- isl_drm_modifier_get_info(whandle->modifier);
+ isl_drm_modifier_get_info(modifier);
+ assert(mod_info);
// XXX: usage...
isl_surf_usage_flags_t isl_usage = ISL_SURF_USAGE_DISPLAY_BIT;