Mesa (master): virgl: Add code to accept BGRx_SRGB as RGBx_SRGB

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 20 07:18:47 UTC 2019


Module: Mesa
Branch: master
Commit: 22edafb23942f98b3e805f0871dcad839f20b977
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=22edafb23942f98b3e805f0871dcad839f20b977

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Mon May 27 16:26:25 2019 +0200

virgl: Add code to accept BGRx_SRGB as RGBx_SRGB

This will be enabled in later patches by the emulation tweak.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh at chromium.org>

---

 src/gallium/drivers/virgl/virgl_screen.c | 25 ++++++++++++++++++++++---
 src/gallium/drivers/virgl/virgl_screen.h |  1 +
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index e8fbdac6544..1baea5d3f19 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -595,13 +595,30 @@ virgl_is_vertex_format_supported(struct pipe_screen *screen,
 
 static boolean
 virgl_format_check_bitmask(enum pipe_format format,
-                           uint32_t bitmask[16])
+                           uint32_t bitmask[16],
+                           boolean may_emulate_bgra)
 {
    int big = format / 32;
    int small = format % 32;
    if ((bitmask[big] & (1 << small)))
       return TRUE;
 
+   /* On GLES hosts we don't advertise BGRx_SRGB, but we may be able
+    * emulate it by using a swizzled RGBx */
+   if (may_emulate_bgra) {
+      if (format == PIPE_FORMAT_B8G8R8A8_SRGB)
+         format = PIPE_FORMAT_R8G8B8A8_SRGB;
+      else if (format == PIPE_FORMAT_B8G8R8X8_SRGB)
+         format = PIPE_FORMAT_R8G8B8X8_SRGB;
+      else {
+         return FALSE;
+      }
+
+      big = format / 32;
+      small = format % 32;
+      if (bitmask[big] & (1 << small))
+         return TRUE;
+   }
    return FALSE;
 }
 
@@ -693,7 +710,8 @@ virgl_is_format_supported( struct pipe_screen *screen,
          return FALSE;
 
       if (!virgl_format_check_bitmask(format,
-                                      vscreen->caps.caps.v1.render.bitmask))
+                                      vscreen->caps.caps.v1.render.bitmask,
+                                      may_emulate_bgra))
          return FALSE;
    }
 
@@ -738,7 +756,8 @@ virgl_is_format_supported( struct pipe_screen *screen,
 
  out_lookup:
    return virgl_format_check_bitmask(format,
-                                     vscreen->caps.caps.v1.sampler.bitmask);
+                                     vscreen->caps.caps.v1.sampler.bitmask,
+                                     may_emulate_bgra);
 }
 
 static void virgl_flush_frontbuffer(struct pipe_screen *screen,
diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h
index 93b52b5138d..62001421936 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -46,6 +46,7 @@ struct virgl_screen {
    struct slab_parent_pool transfer_pool;
 
    uint32_t sub_ctx_id;
+   bool tweak_gles_emulate_bgra;
 };
 
 




More information about the mesa-commit mailing list