virgl: pass iov to virgl_resource_create_from_pipe

Allow iov to be initialized when resource is created.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 4 years ago
parent 7283502949
commit 8ad994b199
  1. 8
      src/virgl_resource.c
  2. 9
      src/virgl_resource.h
  3. 23
      src/virglrenderer.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;
}

@ -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,

@ -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;
}

Loading…
Cancel
Save