virgl: Add tweak to apply a swizzle when drawing/blitting to a emulated BGRA texture
authorGert Wollny <gert.wollny@collabora.com>
Mon, 27 May 2019 14:32:40 +0000 (16:32 +0200)
committerGert Wollny <gert.wollny@collabora.com>
Thu, 20 Jun 2019 06:50:38 +0000 (08:50 +0200)
With Qemu this final swizzle is not needed, but with vtest it is, i.e. it depends on
how a program using virglrenderer uses the surface that is rendered to, hence
a tweak is added.

v2: Update description and fix spelling (Emil)
v3: Send tweak as binary value instead of using strings (Gurchetan)
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_driinfo.h.in
src/gallium/drivers/virgl/virgl_protocol.h
src/gallium/drivers/virgl/virgl_screen.c
src/gallium/drivers/virgl/virgl_screen.h
src/util/xmlpool/t_options.h

index 3ce131a1e06ce7a4eb129c623e56f9c730f35e09..5f6437886642160e6dc8bfe753957e8a1581f417 100644 (file)
@@ -1406,6 +1406,9 @@ static void virgl_send_tweaks(struct virgl_context *vctx, struct virgl_screen *r
 {
    if (rs->tweak_gles_emulate_bgra)
       virgl_encode_tweak(vctx, virgl_tweak_gles_brga_emulate, 1);
+
+   if (rs->tweak_gles_apply_bgra_dest_swizzle)
+      virgl_encode_tweak(vctx, virgl_tweak_gles_brga_apply_dest_swizzle, 1);
 }
 
 struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
index 66d547d4712185ce6c2377e71be5d98b45ad7bc8..d6162b3f39a3ee055717364dd8f35e5a437bf796 100644 (file)
@@ -8,5 +8,6 @@
 //   5. Implement the tweak in virglrenderer
 DRI_CONF_SECTION_MISCELLANEOUS
     DRI_CONF_GLES_EMULATE_BGRA("false")
+    DRI_CONF_GLES_APPLY_BGRA_DEST_SWIZZLE("false")
 DRI_CONF_SECTION_END
 
index 71d1703cada29e168f56f5f64e7d81e5b3807beb..73795a8a7cdee6cd4bb1168ea4d5f4c637ba2093 100644 (file)
@@ -593,6 +593,7 @@ enum virgl_context_cmd {
 
 enum vrend_tweak_type {
    virgl_tweak_gles_brga_emulate,
+   virgl_tweak_gles_brga_apply_dest_swizzle,
    virgl_tweak_undefined
 };
 
index 54bde6f123788d482c12b350d950d59f4891a0f2..e96a10ffbc70b8bd6262cc93143e595a60aff39c 100644 (file)
@@ -855,6 +855,7 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
    struct virgl_screen *screen = CALLOC_STRUCT(virgl_screen);
 
    const char *VIRGL_GLES_EMULATE_BGRA = "gles_emulate_bgra";
+   const char *VIRGL_GLES_APPLY_BGRA_DEST_SWIZZLE = "gles_apply_bgra_dest_swizzle";
    if (!screen)
       return NULL;
 
@@ -863,6 +864,8 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
    if (config && config->options) {
       screen->tweak_gles_emulate_bgra =
             driQueryOptionb(config->options, VIRGL_GLES_EMULATE_BGRA);
+      screen->tweak_gles_apply_bgra_dest_swizzle =
+            driQueryOptionb(config->options, VIRGL_GLES_APPLY_BGRA_DEST_SWIZZLE);
    }
    screen->vws = vws;
    screen->base.get_name = virgl_get_name;
index 620014219368bbe4269cf9647821c50ded7aa7ec..89b06a25e3569a34cf9ece97e9661120a8f12d17 100644 (file)
@@ -47,6 +47,7 @@ struct virgl_screen {
 
    uint32_t sub_ctx_id;
    bool tweak_gles_emulate_bgra;
+   bool tweak_gles_apply_bgra_dest_swizzle;
 };
 
 
index e43692c8ef978dd6745f03c23494c79b8f382eb9..2abd2dd0fc4174d9ec5ede054c7a777051b1f2c5 100644 (file)
@@ -370,3 +370,7 @@ DRI_CONF_OPT_BEGIN_B(gles_emulate_bgra, def) \
         DRI_CONF_DESC(en,gettext("On GLES emulate BGRA formats by using a swizzled RGBA format")) \
 DRI_CONF_OPT_END
 
+#define DRI_CONF_GLES_APPLY_BGRA_DEST_SWIZZLE(def) \
+DRI_CONF_OPT_BEGIN_B(gles_apply_bgra_dest_swizzle, def) \
+        DRI_CONF_DESC(en,gettext("When the BGRA formats are emulated by using swizzled RGBA formats on GLES apply the swizzle when writing")) \
+DRI_CONF_OPT_END