virgl: add virgl_resource_get_size

This adds get_size to the virgl_resource_pipe_callbacks with a
vrend_pipe_resource_get_size for vrend.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Yiwei Zhang 3 years ago
parent 2b66582c32
commit 767037c0d0
  1. 12
      src/virgl_resource.c
  2. 5
      src/virgl_resource.h
  3. 9
      src/vrend_renderer.c

@ -230,3 +230,15 @@ virgl_resource_export_fd(struct virgl_resource *res, int *fd)
return VIRGL_RESOURCE_FD_INVALID;
}
uint64_t
virgl_resource_get_size(struct virgl_resource *res)
{
if (res->map_size)
return res->map_size;
if (res->pipe_resource)
return pipe_callbacks.get_size(res->pipe_resource, pipe_callbacks.data);
return 0;
}

@ -90,6 +90,8 @@ struct virgl_resource_pipe_callbacks {
enum virgl_resource_fd_type (*export_fd)(struct pipe_resource *pres,
int *fd,
void *data);
uint64_t (*get_size)(struct pipe_resource *pres, void *data);
};
int
@ -136,4 +138,7 @@ virgl_resource_detach_iov(struct virgl_resource *res);
enum virgl_resource_fd_type
virgl_resource_export_fd(struct virgl_resource *res, int *fd);
uint64_t
virgl_resource_get_size(struct virgl_resource *res);
#endif /* VIRGL_RESOURCE_H */

@ -6395,6 +6395,14 @@ static enum virgl_resource_fd_type vrend_pipe_resource_export_fd(UNUSED struct p
return VIRGL_RESOURCE_FD_INVALID;
}
static uint64_t vrend_pipe_resource_get_size(struct pipe_resource *pres,
UNUSED void *data)
{
struct vrend_resource *res = (struct vrend_resource *)pres;
return res->size;
}
const struct virgl_resource_pipe_callbacks *
vrend_renderer_get_pipe_callbacks(void)
{
@ -6403,6 +6411,7 @@ vrend_renderer_get_pipe_callbacks(void)
.attach_iov = vrend_pipe_resource_attach_iov,
.detach_iov = vrend_pipe_resource_detach_iov,
.export_fd = vrend_pipe_resource_export_fd,
.get_size = vrend_pipe_resource_get_size,
};
return &callbacks;

Loading…
Cancel
Save