[virglrenderer-devel] [PATCH 7/8] vrend: Support BGRX & BGRA formats v2
Jakob Bornecrantz
jakob.bornecrantz at collabora.com
Tue Feb 13 14:27:29 UTC 2018
These two formats are required by DRI in the guest and as such
Wayland, X11, GBM or any API built on top if DRI. The format
GL_BGRA_EXT is not supported on Desktop OpenGL.
v2: Better documentation.
Signed-off-by: Jakob Bornecrantz <jakob.bornecrantz at collabora.com>
---
src/vrend_formats.c | 17 +++++++++++++++++
src/vrend_renderer.c | 6 +++++-
src/vrend_renderer.h | 1 +
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/vrend_formats.c b/src/vrend_formats.c
index ce72c12..1a16fe2 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,15 @@ 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. But the
+ * GL_BGRA_EXT format is not supported by OpenGL Desktop.
+ */
+ add_formats(gles_bgra_formats);
+}
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index d944c34..7bea8c4 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -4074,7 +4074,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 9bbd9dd..71d14c4 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.14.1
More information about the virglrenderer-devel
mailing list