From f1e72a87b3d754633e5e8560ce9126a45c5695de Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2021 12:06:11 -0800 Subject: [PATCH] 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 Acked-by: Gert Wollny --- src/vrend_decode.c | 9 ++------- src/vrend_renderer.c | 16 ++++++++++------ src/vrend_renderer.h | 6 +++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/vrend_decode.c b/src/vrend_decode.c index bc0cc1b..3008f60 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -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, diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 6c3dbf4..a0d2bcb 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -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) diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 639caaf..0bd7daf 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -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);