[Mesa-dev] [RFC 03/13] intel: support for creating planar external image textures

Topi Pohjolainen topi.pohjolainen at intel.com
Tue Feb 26 05:18:54 PST 2013


One needs to check here if the shader compiler backend is capable of
producing the extra instructions for the given format. One is not
allowed to fail in the code generation phase anymore and it is
probably better from the shader author point of view also to know as
soon as possible.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/intel/intel_tex_image.c |   21 +++++++++++++++++++++
 src/mesa/drivers/dri/intel/intel_tex_obj.h   |    8 ++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index d227ee5..270672c 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -410,6 +410,27 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
                                   image->format, image->offset,
                                   image->width,  image->height,
                                   image->tile_x, image->tile_y);
+
+   if (image->planar_format) {
+      struct intel_texture_image *intel_image = intel_texture_image(texImage);
+      const struct intel_image_format *f = image->planar_format;
+      unsigned i, index;
+
+      /* Check for sampling support here - shader compile time is too late. */
+      if (f->fourcc != __DRI_IMAGE_FOURCC_YUV420 &&
+          f->fourcc != __DRI_IMAGE_FOURCC_YVU420 &&
+          f->fourcc != __DRI_IMAGE_FOURCC_NV12) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, __func__);
+         return;
+      }
+      
+      intel_image->ext_format = f;
+      for (i = 0; i < f->nplanes; i++) {
+         index = f->planes[i].buffer_index;
+         intel_image->ext_offsets[index] = image->offsets[index];
+         intel_image->ext_strides[index] = image->strides[index];
+      }
+   }
 }
 
 void
diff --git a/src/mesa/drivers/dri/intel/intel_tex_obj.h b/src/mesa/drivers/dri/intel/intel_tex_obj.h
index 8c166b4..c724dbb 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_obj.h
+++ b/src/mesa/drivers/dri/intel/intel_tex_obj.h
@@ -71,6 +71,14 @@ struct intel_texture_image
     * Else there is no image data.
     */
    struct intel_mipmap_tree *mt;
+
+   /* If ext_format != NULL, the image represents an external buffer. Depending
+    * on the format the details for the individual components of planar formats
+    * (such as NV12) are set in ext_strides and ext_offsets.
+    */
+   const struct intel_image_format *ext_format;
+   uint32_t ext_strides[3];
+   uint32_t ext_offsets[3];
 };
 
 static INLINE struct intel_texture_object *
-- 
1.7.9.5



More information about the mesa-dev mailing list