[Mesa-dev] [PATCH 2/6] i965: Add a RGBX->RGBA fallback for glEGLImageTextureTarget2D()
Chad Versace
chadversary at chromium.org
Tue Jun 6 20:36:56 UTC 2017
This enables support for importing RGBX8888 EGLImage textures on
Skylake.
Chrome OS needs support for RGBX8888 EGLImage textures because because
the Android framework produces HAL_PIXEL_FORMAT_RGBX8888 winsys
surfaces, which the Chrome OS compositor consumes as dma_bufs. On
hardware for which RGBX is unsupported or disabled, normally core Mesa
provides the RGBX->RGBA fallback during glTexStorage. But the DRIimage
code bypasses core Mesa, so we must do the fallback in i965.
---
src/mesa/drivers/dri/i965/intel_tex_image.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 649b3907d1..92c6c15c72 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -5,6 +5,7 @@
#include "main/bufferobj.h"
#include "main/context.h"
#include "main/formats.h"
+#include "main/format_fallback.h"
#include "main/glformats.h"
#include "main/image.h"
#include "main/pbo.h"
@@ -254,8 +255,22 @@ create_mt_for_dri_image(struct brw_context *brw,
struct gl_context *ctx = &brw->ctx;
struct intel_mipmap_tree *mt;
uint32_t draw_x, draw_y;
+ mesa_format format = image->format;
+
+ if (!ctx->TextureFormatSupported[format]) {
+ /* The texture storage paths in core Mesa detect if the driver does not
+ * support the user-requested format, and then searches for a
+ * fallback format. The DRIimage code bypasses core Mesa, though. So we
+ * do the fallbacks here for important formats.
+ *
+ * We must support DRM_FOURCC_XBGR8888 textures because the Android
+ * framework produces HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces, which
+ * the Chrome OS compositor consumes as dma_buf EGLImages.
+ */
+ format = _mesa_format_fallback_rgbx_to_rgba(format);
+ }
- if (!ctx->TextureFormatSupported[image->format])
+ if (!ctx->TextureFormatSupported[format])
return NULL;
/* Disable creation of the texture's aux buffers because the driver exposes
@@ -263,7 +278,7 @@ create_mt_for_dri_image(struct brw_context *brw,
* buffer's content to the main buffer nor for invalidating the aux buffer's
* content.
*/
- mt = intel_miptree_create_for_bo(brw, image->bo, image->format,
+ mt = intel_miptree_create_for_bo(brw, image->bo, format,
0, image->width, image->height, 1,
image->pitch,
MIPTREE_LAYOUT_DISABLE_AUX);
--
2.13.0
More information about the mesa-dev
mailing list