From 267d4868892916ccedc99c820f2bbc6aa2e13e49 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 27 May 2019 15:05:43 +0200 Subject: [PATCH] tweaks: Add cap and tweak support to the guest-host protocol Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh --- src/virgl_hw.h | 1 + src/virgl_protocol.h | 6 ++++++ src/vrend_debug.c | 1 + src/vrend_decode.c | 19 +++++++++++++++++++ src/vrend_renderer.h | 1 + 5 files changed, 28 insertions(+) diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 3104e1b..91e4259 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -255,6 +255,7 @@ enum virgl_formats { #define VIRGL_CAP_INDIRECT_INPUT_ADDR (1 << 25) #define VIRGL_CAP_COPY_TRANSFER (1 << 26) #define VIRGL_CAP_CLIP_HALFZ (1 << 27) +#define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28) /* virgl bind flags - these are compatible with mesa 10.5 gallium. * but are fixed, no other should be passed to virgl either. diff --git a/src/virgl_protocol.h b/src/virgl_protocol.h index 107076a..7874433 100644 --- a/src/virgl_protocol.h +++ b/src/virgl_protocol.h @@ -101,6 +101,7 @@ enum virgl_context_cmd { VIRGL_CCMD_TRANSFER3D, VIRGL_CCMD_END_TRANSFERS, VIRGL_CCMD_COPY_TRANSFER3D, + VIRGL_CCMD_SET_TWEAKS, VIRGL_MAX_COMMANDS }; @@ -592,6 +593,11 @@ enum virgl_context_cmd { #define VIRGL_COPY_TRANSFER3D_SRC_RES_OFFSET 13 #define VIRGL_COPY_TRANSFER3D_SYNCHRONIZED 14 +/* set tweak flags */ +#define VIRGL_SET_TWEAKS_SIZE 2 +#define VIRGL_SET_TWEAKS_ID 1 +#define VIRGL_SET_TWEAKS_VALUE 2 + enum vrend_tweak_type { virgl_tweak_undefined }; diff --git a/src/vrend_debug.c b/src/vrend_debug.c index 6b525ce..2ab85c7 100644 --- a/src/vrend_debug.c +++ b/src/vrend_debug.c @@ -75,6 +75,7 @@ static const char *command_names[VIRGL_MAX_COMMANDS] = { "TRANSFER3D", "END_TRANSFERS", "COPY_TRANSFER3D", + "TWEAK" }; static const char *object_type_names[VIRGL_MAX_OBJECTS] = { diff --git a/src/vrend_decode.c b/src/vrend_decode.c index ad49098..4a3d671 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -35,6 +35,7 @@ #include "vrend_object.h" #include "tgsi/tgsi_text.h" #include "vrend_debug.h" +#include "vrend_tweaks.h" /* decode side */ #define DECODE_MAX_TOKENS 8000 @@ -1321,6 +1322,21 @@ static int vrend_decode_set_debug_mask(struct vrend_decode_ctx *ctx, int length) return 0; } +static int vrend_decode_set_tweaks(struct vrend_decode_ctx *ctx, int length) +{ + VREND_DEBUG(dbg_tweak, NULL, "Received TWEAK set command\n"); + + if (length < VIRGL_SET_TWEAKS_SIZE) + return EINVAL; + + uint32_t tweak_id = get_buf_entry(ctx, VIRGL_SET_TWEAKS_ID); + uint32_t tweak_value = get_buf_entry(ctx, VIRGL_SET_TWEAKS_VALUE); + + vrend_set_active_tweaks(vrend_get_context_tweaks(ctx->grctx), tweak_id, tweak_value); + return 0; +} + + static int vrend_decode_transfer3d(struct vrend_decode_ctx *ctx, int length, uint32_t ctx_id) { struct pipe_box box; @@ -1610,6 +1626,9 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw) case VIRGL_CCMD_END_TRANSFERS: ret = 0; break; + case VIRGL_CCMD_SET_TWEAKS: + ret = vrend_decode_set_tweaks(gdctx, len); + break; default: ret = EINVAL; } diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 7d92427..13b26f9 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -29,6 +29,7 @@ #include "util/u_inlines.h" #include "virgl_protocol.h" #include "vrend_debug.h" +#include "vrend_tweaks.h" #include "vrend_iov.h" #include "virgl_hw.h" #include