virgl: make virgl_renderer_submit_cmd generic

Add and use virgl_context::submit_cmd callback.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 5 years ago
parent d25d59f9e8
commit 241a096139
  1. 5
      src/virgl_context.h
  2. 5
      src/virglrenderer.c
  3. 20
      src/vrend_decode.c
  4. 1
      src/vrend_renderer.h

@ -25,6 +25,7 @@
#ifndef VIRGL_CONTEXT_H
#define VIRGL_CONTEXT_H
#include <stddef.h>
#include <stdint.h>
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

@ -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,

@ -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)

@ -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);

Loading…
Cancel
Save