virgl: move resource lookup up for some functions

Move resource lookup up from vrend for
virgl_renderer_resource_get_info, virgl_renderer_get_cursor_data,
and virgl_renderer_get_rect.

These functions are mostly for dumb/scanout resources, and they need
information that virgl_resource does not have.  I intentionally pass
pipe_resource down to vrend to emphasize that there is no
virgl_context to dispatch to and those functions can only work with
virgl_resource created from virgl_resource_create_from_pipe.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 5 years ago
parent 5d7f76f87d
commit d471b7d1ba
  1. 25
      src/virglrenderer.c
  2. 30
      src/vrend_renderer.c
  3. 12
      src/vrend_renderer.h

@ -246,8 +246,16 @@ void virgl_renderer_ctx_detach_resource(int ctx_id, int res_handle)
int virgl_renderer_resource_get_info(int res_handle,
struct virgl_renderer_resource_info *info)
{
struct virgl_resource *res = virgl_resource_lookup(res_handle);
int ret;
ret = vrend_renderer_resource_get_info(res_handle, (struct vrend_renderer_resource_info *)info);
if (!res || !res->pipe_resource)
return EINVAL;
if (!info)
return EINVAL;
ret = vrend_renderer_resource_get_info(res->pipe_resource,
(struct vrend_renderer_resource_info *)info);
#ifdef HAVE_EPOXY_EGL_H
if (ret == 0 && use_context == CONTEXT_EGL)
return virgl_egl_get_fourcc_for_texture(egl, info->tex_id, info->virgl_format, &info->drm_fourcc);
@ -265,7 +273,12 @@ void virgl_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,
void virgl_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs,
uint32_t offset, int x, int y, int width, int height)
{
vrend_renderer_get_rect(resource_id, iov, num_iovs, offset, x, y, width, height);
struct virgl_resource *res = virgl_resource_lookup(resource_id);
if (!res || !res->pipe_resource)
return;
vrend_renderer_get_rect(res->pipe_resource, iov, num_iovs, offset, x, y,
width, height);
}
@ -338,8 +351,14 @@ static struct vrend_if_cbs virgl_cbs = {
void *virgl_renderer_get_cursor_data(uint32_t resource_id, uint32_t *width, uint32_t *height)
{
struct virgl_resource *res = virgl_resource_lookup(resource_id);
if (!res || !res->pipe_resource)
return NULL;
vrend_renderer_force_ctx_0();
return vrend_renderer_get_cursor_contents(resource_id, width, height);
return vrend_renderer_get_cursor_contents(res->pipe_resource,
width,
height);
}
void virgl_renderer_poll(void)

@ -9911,19 +9911,17 @@ GLint64 vrend_renderer_get_timestamp(void)
return v;
}
void *vrend_renderer_get_cursor_contents(uint32_t res_handle, uint32_t *width, uint32_t *height)
void *vrend_renderer_get_cursor_contents(struct pipe_resource *pres,
uint32_t *width,
uint32_t *height)
{
struct vrend_resource *res = (struct vrend_resource *)pres;
GLenum format, type;
struct vrend_resource *res;
int blsize;
char *data, *data2;
int size;
uint h;
res = vrend_renderer_res_lookup(res_handle);
if (!res)
return NULL;
if (res->base.width0 > 128 || res->base.height0 > 128)
return NULL;
@ -9997,10 +9995,12 @@ void vrend_renderer_force_ctx_0(void)
vrend_hw_switch_context(vrend_state.ctx0, true);
}
void vrend_renderer_get_rect(int res_handle, struct iovec *iov, unsigned int num_iovs,
uint32_t offset, int x, int y, int width, int height)
void vrend_renderer_get_rect(struct pipe_resource *pres,
struct iovec *iov, unsigned int num_iovs,
uint32_t offset,
int x, int y, int width, int height)
{
struct vrend_resource *res = vrend_renderer_res_lookup(res_handle);
struct vrend_resource *res = (struct vrend_resource *)pres;
struct vrend_transfer_info transfer_info;
struct pipe_box box;
int elsize;
@ -10054,21 +10054,15 @@ void vrend_context_set_debug_flags(struct vrend_context *ctx, const char *flagst
}
}
int vrend_renderer_resource_get_info(int res_handle,
int vrend_renderer_resource_get_info(struct pipe_resource *pres,
struct vrend_renderer_resource_info *info)
{
struct vrend_resource *res;
struct vrend_resource *res = (struct vrend_resource *)pres;
int elsize;
if (!info)
return EINVAL;
res = vrend_renderer_res_lookup(res_handle);
if (!res)
return EINVAL;
elsize = util_format_get_blocksize(res->base.format);
info->handle = res_handle;
info->handle = res->handle;
info->tex_id = res->id;
info->width = res->base.width0;
info->height = res->base.height0;

@ -356,7 +356,9 @@ void vrend_render_condition(struct vrend_context *ctx,
uint32_t handle,
bool condtion,
uint mode);
void *vrend_renderer_get_cursor_contents(uint32_t res_handle, uint32_t *width, uint32_t *height);
void *vrend_renderer_get_cursor_contents(struct pipe_resource *pres,
uint32_t *width,
uint32_t *height);
void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
union virgl_caps *caps);
@ -388,8 +390,10 @@ vrend_resource_reference(struct vrend_resource **ptr, struct vrend_resource *tex
void vrend_renderer_force_ctx_0(void);
void vrend_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs,
uint32_t offset, int x, int y, int width, int height);
void vrend_renderer_get_rect(struct pipe_resource *pres,
struct iovec *iov, unsigned int num_iovs,
uint32_t offset,
int x, int y, int width, int height);
void vrend_renderer_attach_res_ctx(struct vrend_context *ctx,
uint32_t res_id,
@ -410,7 +414,7 @@ struct vrend_renderer_resource_info {
uint32_t stride;
};
int vrend_renderer_resource_get_info(int res_handle,
int vrend_renderer_resource_get_info(struct pipe_resource *pres,
struct vrend_renderer_resource_info *info);
#define VREND_CAP_SET 1

Loading…
Cancel
Save