vrend: attach/detach virgl_resource rather than pipe_resource

An untyped virgl_resource does not have a pipe_resource.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Chia-I Wu 4 years ago
parent e9de44ea19
commit f1e72a87b3
  1. 9
      src/vrend_decode.c
  2. 16
      src/vrend_renderer.c
  3. 6
      src/vrend_renderer.h

@ -1469,12 +1469,7 @@ static void vrend_decode_ctx_attach_resource(struct virgl_context *ctx,
{
TRACE_FUNC();
struct vrend_decode_ctx *dctx = (struct vrend_decode_ctx *)ctx;
/* in the future, we should import to create the pipe resource */
if (!res->pipe_resource)
return;
vrend_renderer_attach_res_ctx(dctx->grctx, res->res_id,
res->pipe_resource);
vrend_renderer_attach_res_ctx(dctx->grctx, res);
}
static void vrend_decode_ctx_detach_resource(struct virgl_context *ctx,
@ -1482,7 +1477,7 @@ static void vrend_decode_ctx_detach_resource(struct virgl_context *ctx,
{
TRACE_FUNC();
struct vrend_decode_ctx *dctx = (struct vrend_decode_ctx *)ctx;
vrend_renderer_detach_res_ctx(dctx->grctx, res->res_id);
vrend_renderer_detach_res_ctx(dctx->grctx, res);
}
static int vrend_decode_ctx_transfer_3d(struct virgl_context *ctx,

@ -10421,17 +10421,21 @@ void vrend_renderer_get_rect(struct pipe_resource *pres,
}
void vrend_renderer_attach_res_ctx(struct vrend_context *ctx,
uint32_t res_id,
struct pipe_resource *pres)
struct virgl_resource *res)
{
struct vrend_resource *res = (struct vrend_resource *)pres;
vrend_ctx_resource_insert(ctx->res_hash, res_id, res);
/* in the future, we should import to create the pipe resource */
if (!res->pipe_resource)
return;
vrend_ctx_resource_insert(ctx->res_hash,
res->res_id,
(struct vrend_resource *)res->pipe_resource);
}
void vrend_renderer_detach_res_ctx(struct vrend_context *ctx,
uint32_t res_id)
struct virgl_resource *res)
{
vrend_ctx_resource_remove(ctx->res_hash, res_id);
vrend_ctx_resource_remove(ctx->res_hash, res->res_id);
}
static struct vrend_resource *vrend_renderer_ctx_res_lookup(struct vrend_context *ctx, int res_handle)

@ -46,6 +46,7 @@ struct virgl_gl_ctx_param {
};
struct virgl_context;
struct virgl_resource;
struct vrend_context;
/* Number of mipmap levels for which to keep the backing iov offsets.
@ -405,10 +406,9 @@ void vrend_renderer_get_rect(struct pipe_resource *pres,
int x, int y, int width, int height);
void vrend_renderer_attach_res_ctx(struct vrend_context *ctx,
uint32_t res_id,
struct pipe_resource *pres);
struct virgl_resource *res);
void vrend_renderer_detach_res_ctx(struct vrend_context *ctx,
uint32_t res_id);
struct virgl_resource *res);
struct vrend_context_tweaks *vrend_get_context_tweaks(struct vrend_context *ctx);

Loading…
Cancel
Save