Commit 772dc50d authored by Juan A. Suárez's avatar Juan A. Suárez Committed by Eleni Maria Stea
Browse files

iris: hook up resource creation from memory object



v2:
* Fixed indentation in iris_resource_from_memobj

v3:
* Removed the call to iris_resource_configure_aux, as we don't
  have any auxiliary buffer support.

v4:
* Added a comment about the assertion that there's no aux buffer
  in case we add them later.

v5:
* Changed the logic of iris_resource_from_memobj. When the user doesn't
  explicitly set the tiling to linear, we use a similar logic with the
  anv driver's logic to calculate it instead of querying the kernel.
  This is because the Vulkan driver doesn't perform ioctls to update the
  kernel when it suballocates buffers.

v6:
* Removed the line that sets the modifier info in the resource. We
  shouldn't need it.

v7, v8:
* Removed left over code related to modifiers.

v9:
* Replaced FORCE_LINEAR_TILING flag with PIPE_BIND_LINEAR where
  necessary.

v10: rebase, use iris_resource_configure_main (Tapani)

v11:
* isl surfaces should be created only for textures and not for
  buffers (fixes: pixel buffer tests assertion failure on BDW).

v12:
* fix in return type is required after rebasing to master.
Signed-off--by: Juan A. Suárez's avatarJuan A. Suarez Romero <jasuarez@igalia.com>
Signed-off-by: Eleni Maria Stea's avatarEleni Maria Stea <estea@igalia.com>
Co-authored-by: Eleni Maria Stea's avatarEleni Maria Stea <estea@igalia.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com> (v9)
Reviewed-by: Tapani Pälli <tapani.palli@intel.com> (v12)
Part-of: <!4337>
parent cdb5a727
......@@ -338,6 +338,8 @@ iris_memobj_create_from_handle(struct pipe_screen *pscreen,
memobj->b.dedicated = dedicated;
memobj->bo = bo;
memobj->format = whandle->format;
memobj->stride = whandle->stride;
iris_bo_reference(memobj->bo);
......@@ -1214,6 +1216,32 @@ fail:
return NULL;
}
static struct pipe_resource *
iris_resource_from_memobj(struct pipe_screen *pscreen,
const struct pipe_resource *templ,
struct pipe_memory_object *pmemobj,
uint64_t offset)
{
struct iris_screen *screen = (struct iris_screen *)pscreen;
struct iris_memory_object *memobj = (struct iris_memory_object *)pmemobj;
struct iris_resource *res = iris_alloc_resource(pscreen, templ);
if (!res)
return NULL;
if (templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY) {
UNUSED const bool isl_surf_created_successfully =
iris_resource_configure_main(screen, res, templ, DRM_FORMAT_MOD_INVALID, 0);
assert(isl_surf_created_successfully);
}
res->bo = memobj->bo;
res->offset = offset;
res->external_format = memobj->format;
return &res->base.b;
}
static void
iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource)
{
......@@ -2347,6 +2375,7 @@ iris_init_screen_resource_functions(struct pipe_screen *pscreen)
pscreen->resource_create = u_transfer_helper_resource_create;
pscreen->resource_from_user_memory = iris_resource_from_user_memory;
pscreen->resource_from_handle = iris_resource_from_handle;
pscreen->resource_from_memobj = iris_resource_from_memobj;
pscreen->resource_get_handle = iris_resource_get_handle;
pscreen->resource_get_param = iris_resource_get_param;
pscreen->resource_destroy = u_transfer_helper_resource_destroy;
......
......@@ -283,6 +283,8 @@ struct iris_transfer {
struct iris_memory_object {
struct pipe_memory_object b;
struct iris_bo *bo;
uint64_t format;
unsigned stride;
};
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment