From 49bdf046fe77d3a64af70fb737d86cc9132d617a Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 8 Nov 2023 17:54:48 +1100 Subject: [PATCH] [client] egl: partially fix RGB_24 support --- client/renderers/EGL/filter_bgr_bgra.c | 2 +- client/renderers/EGL/texture_util.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/client/renderers/EGL/filter_bgr_bgra.c b/client/renderers/EGL/filter_bgr_bgra.c index 83d816a2..85519ea3 100644 --- a/client/renderers/EGL/filter_bgr_bgra.c +++ b/client/renderers/EGL/filter_bgr_bgra.c @@ -111,7 +111,7 @@ static bool egl_filterBGRtoBGRASetup(EGL_Filter * filter, { EGL_FilterBGRtoBGRA * this = UPCAST(EGL_FilterBGRtoBGRA, filter); - if (pixFmt != EGL_PF_BGR_32 || pixFmt != EGL_PF_RGB_24) + if (pixFmt != EGL_PF_BGR_32 && pixFmt != EGL_PF_RGB_24) return false; if (this->useDMA != useDMA) diff --git a/client/renderers/EGL/texture_util.c b/client/renderers/EGL/texture_util.c index 941c826d..e82adde2 100644 --- a/client/renderers/EGL/texture_util.c +++ b/client/renderers/EGL/texture_util.c @@ -30,12 +30,17 @@ bool egl_texUtilGetFormat(const EGL_TexSetup * setup, EGL_TexFormat * fmt) { + fmt->pixFmt = setup->pixFmt; + fmt->width = setup->width; + fmt->height = setup->height; + fmt->stride = setup->stride; + fmt->pitch = setup->pitch; + switch(setup->pixFmt) { //EGL has no support for 24-bit formats, so we stuff it into a 32-bit //texture to unpack with a shader later case EGL_PF_BGR_32: - case EGL_PF_RGB_24: // fallthrough case EGL_PF_BGRA: @@ -70,17 +75,22 @@ bool egl_texUtilGetFormat(const EGL_TexSetup * setup, EGL_TexFormat * fmt) fmt->fourcc = DRM_FORMAT_ABGR16161616F; break; + case EGL_PF_RGB_24: + fmt->bpp = 3; + fmt->format = GL_BGRA_EXT; + fmt->intFormat = GL_BGRA_EXT; + fmt->dataType = GL_UNSIGNED_BYTE; + fmt->fourcc = DRM_FORMAT_ARGB8888; + + // adjust the width as the texture is 32bpp but our source is 24bpp + fmt->width = fmt->width / 4 * 3; + break; + default: DEBUG_ERROR("Unsupported pixel format"); return false; } - fmt->pixFmt = setup->pixFmt; - fmt->width = setup->width; - fmt->height = setup->height; - fmt->stride = setup->stride; - fmt->pitch = setup->pitch; - if (!fmt->stride) fmt->stride = setup->width;