diff --git a/src/virgl_context.h b/src/virgl_context.h index 92628be..879618d 100644 --- a/src/virgl_context.h +++ b/src/virgl_context.h @@ -25,6 +25,7 @@ #ifndef VIRGL_CONTEXT_H #define VIRGL_CONTEXT_H +#include #include struct virgl_context { @@ -36,6 +37,10 @@ struct virgl_context { uint32_t res_id); void (*detach_resource)(struct virgl_context *ctx, uint32_t res_id); + + int (*submit_cmd)(struct virgl_context *ctx, + const void *buffer, + size_t size); }; int diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 5d37c71..955ea87 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -101,7 +101,10 @@ int virgl_renderer_submit_cmd(void *buffer, int ctx_id, int ndw) { - return vrend_decode_block(ctx_id, buffer, ndw); + struct virgl_context *ctx = virgl_context_lookup(ctx_id); + if (!ctx) + return EINVAL; + return ctx->submit_cmd(ctx, buffer, sizeof(uint32_t) * ndw); } int virgl_renderer_transfer_write_iov(uint32_t handle, diff --git a/src/vrend_decode.c b/src/vrend_decode.c index 5b79670..e8e1345 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -1469,25 +1469,20 @@ static void vrend_decode_ctx_detach_resource(struct virgl_context *ctx, vrend_renderer_detach_res_ctx(dctx->grctx, res_id); } -int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw) +static int vrend_decode_ctx_submit_cmd(struct virgl_context *ctx, + const void *buffer, + size_t size) { - struct vrend_decode_ctx *gdctx; + struct vrend_decode_ctx *gdctx = (struct vrend_decode_ctx *)ctx; bool bret; int ret; - if (ctx_id == 0) - return EINVAL; - - gdctx = vrend_decode_ctx_lookup(ctx_id); - if (!gdctx) - return EINVAL; - bret = vrend_hw_switch_context(gdctx->grctx, true); if (bret == false) return EINVAL; - gdctx->ds->buf = block; - gdctx->ds->buf_total = ndw; + gdctx->ds->buf = buffer; + gdctx->ds->buf_total = size / sizeof(uint32_t); gdctx->ds->buf_offset = 0; while (gdctx->ds->buf_offset < gdctx->ds->buf_total) { @@ -1632,7 +1627,7 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw) ret = vrend_decode_get_query_result_qbo(gdctx, len); break; case VIRGL_CCMD_TRANSFER3D: - ret = vrend_decode_transfer3d(gdctx, len, ctx_id); + ret = vrend_decode_transfer3d(gdctx, len, gdctx->base.ctx_id); break; case VIRGL_CCMD_COPY_TRANSFER3D: ret = vrend_decode_copy_transfer3d(gdctx, len); @@ -1669,6 +1664,7 @@ static void vrend_decode_ctx_init_base(struct vrend_decode_ctx *dctx, ctx->destroy = vrend_decode_ctx_destroy; ctx->attach_resource = vrend_decode_ctx_attach_resource; ctx->detach_resource = vrend_decode_ctx_detach_resource; + ctx->submit_cmd = vrend_decode_ctx_submit_cmd; } void vrend_decode_reset(bool ctx_0_only) diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index c2eef18..b8da54d 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -332,7 +332,6 @@ void vrend_set_tess_state(struct vrend_context *ctx, const float tess_factors[6] void vrend_renderer_fini(void); -int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw); struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id); int vrend_renderer_create_fence(int client_fence_id, uint32_t ctx_id);