virgl: fix virgl_renderer_resource_get_map_info for untyped resources

Add virgl_resource::map_info and return it in
virgl_renderer_resource_get_map_info.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
macos/master
Chia-I Wu 4 years ago
parent 3bd6244579
commit f6c704558b
  1. 2
      src/virgl_context.h
  2. 2
      src/virgl_resource.h
  3. 17
      src/virglrenderer.c
  4. 5
      src/vrend_decode.c

@ -42,6 +42,8 @@ struct virgl_context_blob {
struct pipe_resource *pipe_resource; struct pipe_resource *pipe_resource;
} u; } u;
uint32_t map_info;
void *renderer_data; void *renderer_data;
}; };

@ -66,6 +66,8 @@ struct virgl_resource {
const struct iovec *iov; const struct iovec *iov;
int iov_count; int iov_count;
uint32_t map_info;
void *private_data; void *private_data;
}; };

@ -94,6 +94,8 @@ static int virgl_renderer_resource_create_internal(struct virgl_renderer_resourc
return -ENOMEM; return -ENOMEM;
} }
res->map_info = vrend_renderer_resource_get_map_info(pipe_res);
return 0; return 0;
} }
@ -711,7 +713,11 @@ int virgl_renderer_resource_create_blob(const struct virgl_renderer_resource_cre
res = virgl_resource_create_from_iov(args->res_handle, res = virgl_resource_create_from_iov(args->res_handle,
args->iovecs, args->iovecs,
args->num_iovs); args->num_iovs);
return res ? 0 : -ENOMEM; if (!res)
return -ENOMEM;
res->map_info = VIRGL_RENDERER_MAP_CACHE_CACHED;
return 0;
} }
ctx = virgl_context_lookup(args->ctx_id); ctx = virgl_context_lookup(args->ctx_id);
@ -743,6 +749,8 @@ int virgl_renderer_resource_create_blob(const struct virgl_renderer_resource_cre
} }
} }
res->map_info = blob.map_info;
if (ctx->get_blob_done) if (ctx->get_blob_done)
ctx->get_blob_done(ctx, args->res_handle, &blob); ctx->get_blob_done(ctx, args->res_handle, &blob);
@ -773,15 +781,14 @@ int virgl_renderer_resource_get_map_info(uint32_t res_handle, uint32_t *map_info
{ {
TRACE_FUNC(); TRACE_FUNC();
struct virgl_resource *res = virgl_resource_lookup(res_handle); struct virgl_resource *res = virgl_resource_lookup(res_handle);
if (!res || !res->pipe_resource) if (!res)
return -EINVAL; return -EINVAL;
uint32_t info = vrend_renderer_resource_get_map_info(res->pipe_resource); if ((res->map_info & VIRGL_RENDERER_MAP_CACHE_MASK) ==
if ((info & VIRGL_RENDERER_MAP_CACHE_MASK) ==
VIRGL_RENDERER_MAP_CACHE_NONE) VIRGL_RENDERER_MAP_CACHE_NONE)
return -EINVAL; return -EINVAL;
*map_info = info; *map_info = res->map_info;
return 0; return 0;
} }

@ -1508,8 +1508,11 @@ static int vrend_decode_ctx_get_blob(struct virgl_context *ctx,
blob->type = VIRGL_RESOURCE_FD_INVALID; blob->type = VIRGL_RESOURCE_FD_INVALID;
/* this transfers ownership and blob_id is no longer valid */ /* this transfers ownership and blob_id is no longer valid */
blob->u.pipe_resource = vrend_get_blob_pipe(dctx->grctx, blob_id); blob->u.pipe_resource = vrend_get_blob_pipe(dctx->grctx, blob_id);
if (!blob->u.pipe_resource)
return -EINVAL;
return blob->u.pipe_resource ? 0 : EINVAL; blob->map_info = vrend_renderer_resource_get_map_info(blob->u.pipe_resource);
return 0;
} }
typedef int (*vrend_decode_callback)(struct vrend_context *ctx, const uint32_t *buf, uint32_t length); typedef int (*vrend_decode_callback)(struct vrend_context *ctx, const uint32_t *buf, uint32_t length);

Loading…
Cancel
Save