virgl: Add driconf tweak for emulating BGRA surfaces on GLES
authorGert Wollny <gert.wollny@collabora.com>
Mon, 27 May 2019 14:31:17 +0000 (16:31 +0200)
committerGert Wollny <gert.wollny@collabora.com>
Thu, 20 Jun 2019 06:50:38 +0000 (08:50 +0200)
These tweaks are used to fix rendering issues with Valve games and
at least also "The Raven Remastered" when run on a GLES host.

v2: Fix type in define and remove virgl from driconf option (Emil)
v3: Encode tweak binary instead of using strings (Gurchetan)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_protocol.h
src/gallium/drivers/virgl/virgl_screen.c
src/util/00-mesa-defaults.conf
src/util/xmlpool/t_options.h

index cd653b70ce90b02bef8e8e9fdcbf8340b753d6a6..3ce131a1e06ce7a4eb129c623e56f9c730f35e09 100644 (file)
@@ -1404,6 +1404,8 @@ static void virgl_get_sample_position(struct pipe_context *ctx,
 
 static void virgl_send_tweaks(struct virgl_context *vctx, struct virgl_screen *rs)
 {
+   if (rs->tweak_gles_emulate_bgra)
+      virgl_encode_tweak(vctx, virgl_tweak_gles_brga_emulate, 1);
 }
 
 struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
index c3ad598601ddc85d05aa9bb92f3910ff1e1ddb7e..71d1703cada29e168f56f5f64e7d81e5b3807beb 100644 (file)
@@ -592,6 +592,7 @@ enum virgl_context_cmd {
 #define VIRGL_SET_TWEAKS_VALUE 2
 
 enum vrend_tweak_type {
+   virgl_tweak_gles_brga_emulate,
    virgl_tweak_undefined
 };
 
index 31de32f928910f5bf2cd55c14344609cbeb26084..54bde6f123788d482c12b350d950d59f4891a0f2 100644 (file)
@@ -27,6 +27,7 @@
 #include "util/u_video.h"
 #include "util/u_math.h"
 #include "util/os_time.h"
+#include "util/xmlconfig.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
@@ -36,6 +37,7 @@
 #include "virgl_resource.h"
 #include "virgl_public.h"
 #include "virgl_context.h"
+#include "virgl_protocol.h"
 
 int virgl_debug = 0;
 static const struct debug_named_value debug_options[] = {
@@ -852,11 +854,16 @@ 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";
    if (!screen)
       return NULL;
 
    virgl_debug = debug_get_option_virgl_debug();
 
+   if (config && config->options) {
+      screen->tweak_gles_emulate_bgra =
+            driQueryOptionb(config->options, VIRGL_GLES_EMULATE_BGRA);
+   }
    screen->vws = vws;
    screen->base.get_name = virgl_get_name;
    screen->base.get_vendor = virgl_get_vendor;
index e36190f61c878ac8c7d50f177334e8e2a95cfe96..ae29d8837d581987d70b666a66e72a8e120f9e21 100644 (file)
@@ -490,4 +490,30 @@ TODO: document the other workarounds.
             <option name="radeonsi_prim_restart_tri_strips_only" value="true"/>
         </application>
     </device>
-  </driconf>
+    <device driver="virtio_gpu">
+        <!-- Some Valve games do a final blit to a BRGA_sRGB surface. On a GLES
+        host this format is not supported and the blit will go to BGRA_UNORM
+        resulting in an unintended linearization and the final output being
+        too dark. -->
+        <application name="Half Life 2" executable="hl2_linux">
+            <option name="gles_emulate_bgra" value="true" />
+        </application>
+        <application name="Portal" executable="hl2_linux">
+            <option name="gles_emulate_bgra" value="true" />
+        </application>
+        <application name="Left 4 Dead 2" executable="hl2_linux">
+            <option name="gles_emulate_bgra" value="true" />
+        </application>
+        <application name="Dota 2" executable="dota2">
+            <option name="gles_emulate_bgra" value="true" />
+        </application>
+        <!-- The Raven Remastered expects a BGRA_sRGB surface and a BGRA_sRGB
+         surface that is capable to do texture views, since on GLES the BGRA
+         format provided by EXT_texture_BGRA8888 has no sRGB counterpart and
+         is not in the list of suppoerted TextureView formats we need to
+         emulate this  -->
+        <application name="The Raven Remastered" executable="Raven">
+            <option name="gles_emulate_bgra" value="true" />
+        </application>
+    </device>
+</driconf>
index 4396ba79f79ee79219343ff2de1f860bc48d3ae4..e43692c8ef978dd6745f03c23494c79b8f382eb9 100644 (file)
@@ -361,5 +361,12 @@ DRI_CONF_OPT_END
 #define DRI_CONF_V3D_NONMSAA_TEXTURE_SIZE_LIMIT(def) \
 DRI_CONF_OPT_BEGIN_B(v3d_nonmsaa_texture_size_limit, def) \
         DRI_CONF_DESC(en,"Report the non-MSAA-only texture size limit") \
+/**
+ * \brief virgl specific configuration options
+ */
+
+#define DRI_CONF_GLES_EMULATE_BGRA(def) \
+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