[virglrenderer-devel] [PATCH 2/3] vrend: Add support for PIPE_FORMAT_A4B4G4R4_UNORM

Tomeu Vizoso tomeu.vizoso at collabora.com
Fri May 18 12:28:59 UTC 2018


and make sure that on GLES it it chosen for GL_RGBA4 over
VIRGL_FORMAT_B4G4R4A4_UNORM, by removing support for the latter.

This is needed because on GLES3 GL_BGRA isn't a supported format to pass
to glTexImage3D.

Fixes the test dEQP-GLES3.functional.texture.format.sized.3d.rgba4_pot
on GLES hosts.

v2: * Make more explicit the GL/GLES split (Gert Wollny)

Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
Suggested-by: Jakob Bornecrantz <jakob at collabora.com>
Reviewed-By: Gert Wollny <gert.wollny at collabora.com>
Tested-by: Jakob Bornecrantz <jakob at collabora.com>
---
 src/gallium/auxiliary/util/u_format.csv |  1 +
 src/virgl_hw.h                          |  2 +-
 src/vrend_formats.c                     | 21 +++++++++++++++++----
 src/vrend_renderer.c                    |  4 +++-
 src/vrend_renderer.h                    |  3 ++-
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv
index d409693ab0fc..e985d8761652 100644
--- a/src/gallium/auxiliary/util/u_format.csv
+++ b/src/gallium/auxiliary/util/u_format.csv
@@ -76,6 +76,7 @@ PIPE_FORMAT_B5G5R5X1_UNORM        , plain, 1, 1, un5 , un5 , un5 , x1  , zyx1, r
 PIPE_FORMAT_B5G5R5A1_UNORM        , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb, un1 , un5 , un5 , un5 , yzwx
 PIPE_FORMAT_B4G4R4A4_UNORM        , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb, un4 , un4 , un4 , un4 , yzwx
 PIPE_FORMAT_B4G4R4X4_UNORM        , plain, 1, 1, un4 , un4 , un4 , x4  , zyx1, rgb, x4  , un4 , un4 , un4 , yzw1
+PIPE_FORMAT_A4B4G4R4_UNORM        , plain, 1, 1, un4 , un4 , un4 , un4 , wzyx, rgb, un4 , un4 , un4 , un4 , xyzw
 PIPE_FORMAT_B5G6R5_UNORM          , plain, 1, 1, un5 , un6 , un5 ,     , zyx1, rgb, un5 , un6 , un5 ,     , xyz1
 PIPE_FORMAT_R10G10B10A2_UNORM     , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb, un2 , un10, un10, un10, wzyx
 PIPE_FORMAT_R10G10B10X2_UNORM     , plain, 1, 1, un10, un10, un10, x2,   xyz1, rgb, x2  , un10, un10, un10, wzy1
diff --git a/src/virgl_hw.h b/src/virgl_hw.h
index 3f1b40b589bb..4eac70c4e6ce 100644
--- a/src/virgl_hw.h
+++ b/src/virgl_hw.h
@@ -207,7 +207,7 @@ enum virgl_formats {
    VIRGL_FORMAT_BPTC_RGB_UFLOAT         = 258,
 
    VIRGL_FORMAT_R10G10B10X2_UNORM       = 308,
-
+   VIRGL_FORMAT_A4B4G4R4_UNORM          = 311,
    VIRGL_FORMAT_MAX,
 };
 
diff --git a/src/vrend_formats.c b/src/vrend_formats.c
index 3464c0665b23..e44790e1cbf9 100644
--- a/src/vrend_formats.c
+++ b/src/vrend_formats.c
@@ -47,8 +47,8 @@ static struct vrend_format_table base_rgba_formats[] =
 
     { VIRGL_FORMAT_A8B8G8R8_UNORM, GL_RGBA8, GL_ABGR_EXT, GL_UNSIGNED_BYTE, NO_SWIZZLE },
 
-    { VIRGL_FORMAT_B4G4R4A4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, NO_SWIZZLE },
     { VIRGL_FORMAT_B4G4R4X4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, RGB1_SWIZZLE },
+    { VIRGL_FORMAT_A4B4G4R4_UNORM, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, NO_SWIZZLE },
     { VIRGL_FORMAT_B5G5R5X1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, RGB1_SWIZZLE },
     { VIRGL_FORMAT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NO_SWIZZLE },
 
@@ -60,6 +60,11 @@ static struct vrend_format_table base_rgba_formats[] =
     { VIRGL_FORMAT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, NO_SWIZZLE },
   };
 
+static struct vrend_format_table gl_base_rgba_formats[] =
+  {
+    { VIRGL_FORMAT_B4G4R4A4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, NO_SWIZZLE },
+  };
+
 static struct vrend_format_table base_depth_formats[] =
   {
     { VIRGL_FORMAT_Z16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NO_SWIZZLE },
@@ -352,7 +357,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
 
 #define add_formats(x) vrend_add_formats((x), ARRAY_SIZE((x)))
 
-void vrend_build_format_list(void)
+void vrend_build_format_list_common(void)
 {
   add_formats(base_rgba_formats);
   add_formats(base_depth_formats);
@@ -394,10 +399,18 @@ void vrend_build_format_list(void)
   add_formats(bptc_formats);
 }
 
-void vrend_build_format_list_gles(void)
+
+void vrend_build_format_list_gl(void)
 {
-  vrend_build_format_list();
+  /* We don't want VIRGL_FORMAT_B4G4R4A4_UNORM to be supported on GLES because
+   * it's not as well supported as VIRGL_FORMAT_A4B4G4R4_UNORM in some
+   * operations.
+   */
+  add_formats(gl_base_rgba_formats);
+}
 
+void vrend_build_format_list_gles(void)
+{
   /* 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. But the
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index d20b411dc566..34c9ac180d4c 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -4240,10 +4240,12 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
       glDisable(GL_DEBUG_OUTPUT);
    }
 
+   vrend_build_format_list_common();
+
    if (vrend_state.use_gles) {
       vrend_build_format_list_gles();
    } else {
-      vrend_build_format_list();
+      vrend_build_format_list_gl();
    }
 
    /* disable for format testing */
diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
index 0a139c758e61..9bb428b9fd34 100644
--- a/src/vrend_renderer.h
+++ b/src/vrend_renderer.h
@@ -312,7 +312,8 @@ 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_common(void);
+void vrend_build_format_list_gl(void);
 void vrend_build_format_list_gles(void);
 
 int vrend_renderer_resource_attach_iov(int res_handle, struct iovec *iov,
-- 
2.17.0



More information about the virglrenderer-devel mailing list