From c6fd7d55ac71a8f0865134e75a2bf7a552178285 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 9 Mar 2015 10:16:47 +1000 Subject: [PATCH] tests: add flush callback to test large transfers --- tests/testvirgl.c | 7 +++++++ tests/testvirgl.h | 1 + tests/testvirgl_encode.c | 10 +++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/testvirgl.c b/tests/testvirgl.c index e1c30b9..dd3f025 100644 --- a/tests/testvirgl.c +++ b/tests/testvirgl.c @@ -131,6 +131,12 @@ void testvirgl_fini_single_ctx(void) virgl_renderer_cleanup(&mystruct); } +static void testvirgl_flush(struct virgl_context *ctx) +{ + virgl_renderer_submit_cmd(ctx->cbuf->buf, ctx->ctx_id, ctx->cbuf->cdw); + ctx->cbuf->cdw = 0; +} + int testvirgl_init_ctx_cmdbuf(struct virgl_context *ctx) { int ret; @@ -138,6 +144,7 @@ int testvirgl_init_ctx_cmdbuf(struct virgl_context *ctx) if (ret) return ret; + ctx->flush = testvirgl_flush; ctx->ctx_id = 1; ctx->cbuf = CALLOC_STRUCT(virgl_cmd_buf); if (!ctx->cbuf) { diff --git a/tests/testvirgl.h b/tests/testvirgl.h index 497957e..a2b0ffe 100644 --- a/tests/testvirgl.h +++ b/tests/testvirgl.h @@ -36,6 +36,7 @@ struct virgl_cmd_buf { }; struct virgl_context { + void (*flush)(struct virgl_context *ctx); struct virgl_cmd_buf *cbuf; int ctx_id; }; diff --git a/tests/testvirgl_encode.c b/tests/testvirgl_encode.c index 7aded11..898aaf9 100644 --- a/tests/testvirgl_encode.c +++ b/tests/testvirgl_encode.c @@ -13,10 +13,10 @@ static int virgl_encoder_write_cmd_dword(struct virgl_context *ctx, uint32_t dword) { - // int len = (dword >> 16); + int len = (dword >> 16); - // if ((ctx->cbuf->cdw + len + 1) > VIRGL_MAX_CMDBUF_DWORDS) - // ctx->base.flush(&ctx->base, NULL, 0); + if ((ctx->cbuf->cdw + len + 1) > VIRGL_MAX_CMDBUF_DWORDS) + ctx->flush(ctx); virgl_encoder_write_dword(ctx->cbuf, dword); return 0; @@ -426,8 +426,8 @@ int virgl_encoder_inline_write(struct virgl_context *ctx, left_bytes = size; while (left_bytes) { - // if (ctx->cbuf->cdw + 12 > VIRGL_MAX_CMDBUF_DWORDS) - // ctx->base.flush(&ctx->base, NULL, 0); + if (ctx->cbuf->cdw + 12 > VIRGL_MAX_CMDBUF_DWORDS) + ctx->flush(ctx); thispass = (VIRGL_MAX_CMDBUF_DWORDS - ctx->cbuf->cdw - 12) * 4;