[virglrenderer-devel] [PATCH 08/16] vrend: Support BGRX & BGRA formats

Jakob Bornecrantz jakob.bornecrantz at collabora.com
Fri Dec 22 18:57:48 UTC 2017


These two formats are required by DRI in the guest and as such
Wayland, X11, GBM or any API built on top if DRI.

Signed-off-by: Jakob Bornecrantz <jakob.bornecrantz at collabora.com>
---
 src/vrend_formats.c  | 16 ++++++++++++++++
 src/vrend_renderer.c |  6 +++++-
 src/vrend_renderer.h |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/vrend_formats.c b/src/vrend_formats.c
index ce72c12..9bf4cfe 100644
--- a/src/vrend_formats.c
+++ b/src/vrend_formats.c
@@ -249,6 +249,11 @@ static struct vrend_format_table bptc_formats[] = {
    { VIRGL_FORMAT_BPTC_RGB_UFLOAT, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_UNSIGNED_BYTE },
 };
 
+static struct vrend_format_table gles_bgra_formats[] = {
+  { VIRGL_FORMAT_B8G8R8X8_UNORM, GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 0 },
+  { VIRGL_FORMAT_B8G8R8A8_UNORM, GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 0 },
+};
+
 static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
 {
   int i;
@@ -370,3 +375,14 @@ void vrend_build_format_list(void)
 
   add_formats(bptc_formats);
 }
+
+void vrend_build_format_list_gles(void)
+{
+  vrend_build_format_list();
+
+  /* The BGR[A|X] formats is required but OpenGL ES does not
+   * support rendering to it. Try to use GL_BGRA_EXT from the
+   * GL_EXT_texture_format_BGRA8888 extension.
+   */
+  add_formats(gles_bgra_formats);
+}
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 7b41ea1..1ca957f 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -3932,7 +3932,11 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
       glDisable(GL_DEBUG_OUTPUT);
    }
 
-   vrend_build_format_list();
+   if (vrend_state.use_gles) {
+      vrend_build_format_list_gles();
+   } else {
+      vrend_build_format_list();
+   }
 
    /* disable for format testing */
    if (vrend_state.have_debug_cb) {
diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
index b9eeb71..e6131d1 100644
--- a/src/vrend_renderer.h
+++ b/src/vrend_renderer.h
@@ -312,6 +312,7 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
 GLint64 vrend_renderer_get_timestamp(void);
 
 void vrend_build_format_list(void);
+void vrend_build_format_list_gles(void);
 
 int vrend_renderer_resource_attach_iov(int res_handle, struct iovec *iov,
                                        int num_iovs);
-- 
2.11.0



More information about the virglrenderer-devel mailing list