intel: add support for __DRI_IMAGE_FORMAT_ABGR8888
authorChia-I Wu <olv@lunarg.com>
Sun, 21 Aug 2011 13:36:40 +0000 (21:36 +0800)
committerChia-I Wu <olv@lunarg.com>
Fri, 9 Sep 2011 04:06:17 +0000 (12:06 +0800)
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@anholt.net>
[olv: add a check in intel_image_target_renderbuffer_storage]

src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_screen.c

index 7cd6820cd51cac60c7449dcfdaaac2c8c4529b9c..5e789c4ee91cf8099d366f71ec5d4929ce7d6d1a 100644 (file)
@@ -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:
index ad909789d827be0824d7e9eddcaf0c8ce507c75d..7528952f71d730bfc1ebd9c3f5cacb94716122c3 100644 (file)
@@ -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.
index 754f9f202d113d0cfeceaca13a5d58618753a572..22c5ac2d2fcb292bdc6f240139d8cb0f1fc5e3f7 100644 (file)
@@ -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);
 
index bd8d574a29e936493b8e7002d9dad0e505bc2a98..29094866622328b5fde7fe0c040365fd45d4b269 100644 (file)
@@ -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;