From 8ad994b1994b9ea70765d1c10a285db32a831b14 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 20 Jul 2020 10:54:35 -0700 Subject: [PATCH] virgl: pass iov to virgl_resource_create_from_pipe Allow iov to be initialized when resource is created. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/virgl_resource.c | 8 +++++++- src/virgl_resource.h | 9 ++++++--- src/virglrenderer.c | 23 +++++------------------ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/virgl_resource.c b/src/virgl_resource.c index 4e9d640..89224c7 100644 --- a/src/virgl_resource.c +++ b/src/virgl_resource.c @@ -97,7 +97,10 @@ virgl_resource_create(uint32_t res_id) } int -virgl_resource_create_from_pipe(uint32_t res_id, struct pipe_resource *pres) +virgl_resource_create_from_pipe(uint32_t res_id, + struct pipe_resource *pres, + const struct iovec *iov, + int iov_count) { struct virgl_resource *res; @@ -108,6 +111,9 @@ virgl_resource_create_from_pipe(uint32_t res_id, struct pipe_resource *pres) /* take ownership */ res->pipe_resource = pres; + res->iov = iov; + res->iov_count = iov_count; + return 0; } diff --git a/src/virgl_resource.h b/src/virgl_resource.h index c3e1438..3b165da 100644 --- a/src/virgl_resource.h +++ b/src/virgl_resource.h @@ -41,12 +41,12 @@ struct pipe_resource; struct virgl_resource { uint32_t res_id; + struct pipe_resource *pipe_resource; + const struct iovec *iov; int iov_count; void *private_data; - - struct pipe_resource *pipe_resource; }; struct virgl_resource_pipe_callbacks { @@ -71,7 +71,10 @@ void virgl_resource_table_reset(void); int -virgl_resource_create_from_pipe(uint32_t res_id, struct pipe_resource *pres); +virgl_resource_create_from_pipe(uint32_t res_id, + struct pipe_resource *pres, + const struct iovec *iov, + int iov_count); int virgl_resource_create_from_iov(uint32_t res_id, diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 89680e2..71166c5 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -80,20 +80,12 @@ static int virgl_renderer_resource_create_internal(struct virgl_renderer_resourc if (!pipe_res) return EINVAL; - ret = virgl_resource_create_from_pipe(args->handle, pipe_res); + ret = virgl_resource_create_from_pipe(args->handle, pipe_res, iov, num_iovs); if (ret) { vrend_renderer_resource_destroy((struct vrend_resource *)pipe_res); return ret; } - if (!ret && num_iovs) { - ret = virgl_renderer_resource_attach_iov(args->handle, iov, num_iovs); - if (ret) { - virgl_resource_remove(args->handle); - return ret; - } - } - return 0; } @@ -706,20 +698,15 @@ int virgl_renderer_resource_create_blob(const struct virgl_renderer_resource_cre if (!pipe_res) return -EINVAL; - ret = virgl_resource_create_from_pipe(args->res_handle, pipe_res); + ret = virgl_resource_create_from_pipe(args->res_handle, + pipe_res, + args->iovecs, + args->num_iovs); if (ret) { vrend_renderer_resource_destroy((struct vrend_resource *)pipe_res); return ret; } - if (has_guest_storage) { - ret = virgl_renderer_resource_attach_iov(args->res_handle, args->iovecs, args->num_iovs); - if (ret) { - virgl_resource_remove(args->res_handle); - return ret; - } - } - return 0; }