[Mesa-dev] [PATCHv2 2/4] intel: add support for __DRI_IMAGE_FORMAT_ABGR8888

Chia-I Wu olvaffe at gmail.com
Sun Sep 4 00:02:00 PDT 2011


From: Chia-I Wu <olv at lunarg.com>

It maps to MESA_FORMAT_RGBA8888_REV.  Surfaces of the format can only be
sampled from but not render to.

Only i915 is tested.

Reviewed-by: Eric Anholt <eric at anholt.net>

[olv: add a check in intel_image_target_renderbuffer_storage]
---
 src/mesa/drivers/dri/i915/i915_texstate.c        |    2 ++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |    4 ++++
 src/mesa/drivers/dri/intel/intel_fbo.c           |   11 +++++++++++
 src/mesa/drivers/dri/intel/intel_screen.c        |   10 ++++++++++
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 7cd6820..5e789c4 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -60,6 +60,8 @@ translate_texture_format(gl_format mesa_format, GLenum DepthMode)
       return MAPSURF_32BIT | MT_32BIT_ARGB8888;
    case MESA_FORMAT_XRGB8888:
       return MAPSURF_32BIT | MT_32BIT_XRGB8888;
+   case MESA_FORMAT_RGBA8888_REV:
+      return MAPSURF_32BIT | MT_32BIT_ABGR8888;
    case MESA_FORMAT_YCBCR_REV:
       return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index ad90978..7528952 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -190,6 +190,10 @@ translate_tex_format(gl_format mesa_format,
       else if (srgb_decode == GL_SKIP_DECODE_EXT)
 	 return brw_format_for_mesa_format(_mesa_get_srgb_format_linear(mesa_format));
 
+   case MESA_FORMAT_RGBA8888_REV:
+      /* This format is not renderable? */
+      return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
+
    case MESA_FORMAT_RGBA_FLOAT32:
       /* The value of this BRW_SURFACEFORMAT is 0, which tricks the
        * assertion below.
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 754f9f2..22c5ac2 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -269,6 +269,17 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
    if (image == NULL)
       return;
 
+   /* __DRIimage is opaque to the core so it has to be checked here */
+   switch (image->format) {
+   case MESA_FORMAT_RGBA8888_REV:
+      _mesa_error(&intel->ctx, GL_INVALID_OPERATION,
+            "glEGLImageTargetRenderbufferStorage(unsupported image format");
+      return;
+      break;
+   default:
+      break;
+   }
+
    irb = intel_renderbuffer(rb);
    intel_region_reference(&irb->region, image->region);
 
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index bd8d574..2909486 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -152,6 +152,11 @@ intel_create_image_from_name(__DRIscreen *screen,
        image->internal_format = GL_RGBA;
        image->data_type = GL_UNSIGNED_BYTE;
        break;
+    case __DRI_IMAGE_FORMAT_ABGR8888:
+       image->format = MESA_FORMAT_RGBA8888_REV;
+       image->internal_format = GL_RGBA;
+       image->data_type = GL_UNSIGNED_BYTE;
+       break;
     default:
        free(image);
        return NULL;
@@ -246,6 +251,11 @@ intel_create_image(__DRIscreen *screen,
       image->internal_format = GL_RGBA;
       image->data_type = GL_UNSIGNED_BYTE;
       break;
+    case __DRI_IMAGE_FORMAT_ABGR8888:
+       image->format = MESA_FORMAT_RGBA8888_REV;
+       image->internal_format = GL_RGBA;
+       image->data_type = GL_UNSIGNED_BYTE;
+       break;
    default:
       free(image);
       return NULL;
-- 
1.7.5.4



More information about the mesa-dev mailing list