From 9c4930946a53d4f547e3c3ee6dcf672fbf0ac3a5 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Wed, 28 Nov 2018 15:36:07 -0800 Subject: [PATCH] virgl: add encoder functions for new protocol Let's encode the new protocol with new helper functions. Reviewed-by: Gert Wollny --- src/gallium/drivers/virgl/virgl_encode.c | 22 ++++++++++++++++++++++ src/gallium/drivers/virgl/virgl_encode.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index fe390ea93fe..ad7842f0f37 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -1103,3 +1103,25 @@ int virgl_encode_get_query_result_qbo(struct virgl_context *ctx, virgl_encoder_write_dword(ctx->cbuf, index); return 0; } + +void virgl_encode_transfer(struct virgl_screen *vs, struct virgl_cmd_buf *buf, + struct virgl_transfer *trans, uint32_t direction) +{ + uint32_t command; + struct virgl_resource *res = virgl_resource(trans->base.resource); + command = VIRGL_CMD0(VIRGL_CCMD_TRANSFER3D, 0, VIRGL_TRANSFER3D_SIZE); + virgl_encoder_write_dword(buf, command); + virgl_encoder_transfer3d_common(vs, buf, trans); + virgl_encoder_write_dword(buf, trans->offset); + virgl_encoder_write_dword(buf, direction); +} + +void virgl_encode_end_transfers(struct virgl_cmd_buf *buf) +{ + uint32_t command, diff; + diff = VIRGL_MAX_TBUF_DWORDS - buf->cdw; + if (diff) { + command = VIRGL_CMD0(VIRGL_CCMD_END_TRANSFERS, 0, diff - 1); + virgl_encoder_write_dword(buf, command); + } +} diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h index 70fae1db4e5..150ed17f994 100644 --- a/src/gallium/drivers/virgl/virgl_encode.h +++ b/src/gallium/drivers/virgl/virgl_encode.h @@ -32,6 +32,8 @@ struct tgsi_token; struct virgl_context; struct virgl_resource; +struct virgl_screen; +struct virgl_transfer; struct virgl_sampler_view; struct virgl_surface { @@ -287,4 +289,8 @@ int virgl_encode_get_query_result_qbo(struct virgl_context *ctx, uint32_t offset, uint32_t index); +void virgl_encode_transfer(struct virgl_screen *vs, struct virgl_cmd_buf *buf, + struct virgl_transfer *trans, uint32_t direction); + +void virgl_encode_end_transfers(struct virgl_cmd_buf *buf); #endif -- 2.30.2