Re: [Mesa-dev] [PATCH 2/2] intel: Support new dri image interface v2

2012-08-31 Thread Pekka Paalanen
On Fri, 31 Aug 2012 15:22:04 +0200
Jakob Bornecrantz ja...@vmware.com wrote:

 Follow up to the previous patch, kept seperate for easier viewing,
 will be merged with previous patch before commiting.
 
 v2: Should fix YUV pitch/stride == 0.
 
 Signed-off-by: Jakob Bornecrantz ja...@vmware.com
 ---
  src/mesa/drivers/dri/intel/intel_regions.h |   26 ++
  src/mesa/drivers/dri/intel/intel_screen.c  |  135 
 ++--
  2 files changed, 153 insertions(+), 8 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/intel/intel_regions.h 
 b/src/mesa/drivers/dri/intel/intel_regions.h
 index 4ff0efe..c0fdc95 100644
 --- a/src/mesa/drivers/dri/intel/intel_regions.h
 +++ b/src/mesa/drivers/dri/intel/intel_regions.h
 @@ -141,12 +141,38 @@ uint32_t
  intel_region_get_aligned_offset(struct intel_region *region, uint32_t x,
  uint32_t y);
  
 +/**
 + * Used with images created with image_from_names
 + * to help support planar images.
 + */
 +typedef struct intel_image_format {
 +   int fourcc;
 +   int components;
 +   int nplanes;
 +   struct {
 +  int buffer_index;
 +  int width_shift;
 +  int height_shift;
 +  uint32_t dri_format;
 +  int cpp;
 +   } planes[3];
 +} intel_image_format_t;
 +
  struct __DRIimageRec {
 struct intel_region *region;
 GLenum internal_format;
 uint32_t dri_format;
 GLuint format;
 uint32_t offset;
 +
 +   /*
 +* Need to save these here between calls to
 +* image_from_names and calls to image_from_planar.
 +*/
 +   uint32_t strides[3];
 +   uint32_t offsets[3];
 +   struct intel_image_format *planar_format;
 +
 void *data;
  };
  
 diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
 b/src/mesa/drivers/dri/intel/intel_screen.c
 index 55cebac..f20b072 100644
 --- a/src/mesa/drivers/dri/intel/intel_screen.c
 +++ b/src/mesa/drivers/dri/intel/intel_screen.c
 @@ -190,6 +190,59 @@ static const struct __DRI2flushExtensionRec 
 intelFlushExtension = {
  dri2InvalidateDrawable,
  };
  
 +intel_image_format_t intel_image_formats[] = {
 +   { __DRI_IMAGE_FOURCC_ARGB, __DRI_IMAGE_COMPONENTS_RGBA, 1,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB, 4 } } },
 +
 +   { __DRI_IMAGE_FOURCC_XRGB, __DRI_IMAGE_COMPONENTS_RGB, 1,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB, 4 }, } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV411, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV444, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_NV12, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 1, __DRI_IMAGE_FORMAT_GR88, 2 } } },
 +
 +   { __DRI_IMAGE_FOURCC_NV16, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
 +
 +   /* For YUYV buffers, we set up two overlapping DRI images and treat
 +* them as planar buffers in the compositors.  Plane 0 is GR88 and
 +* samples YU or YV pairs and places Y into the R component, while
 +* plane 1 is ARGB and samples YUYV clusters and places pairs and
 +* places U into the G component and V into A.  This lets the
 +* texture sampler interpolate the Y components correctly when
 +* sampling from plane 0, and interpolate U and V correctly when
 +* sampling from plane 1. */
 +   { __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
 +   { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB, 4 } } }
 +};
 +
  static __DRIimage *
  intel_allocate_image(int dri_format, void *loaderPrivate)
  {
 @@ -249,7 +302,7 @@ intel_create_image_from_name(__DRIscreen *screen,
  
  image = intel_allocate_image(format, loaderPrivate);
  if (image-format == MESA_FORMAT_NONE)
 -   cpp = 0;
 +   cpp = 1;
  else
 cpp = _mesa_get_format_bytes(image-format);
  image-region = intel_region_alloc_for_handle(intelScreen,
 @@ -372,6 +425,11 @@ intel_query_image(__DRIimage *image, int attrib, int 
 *value)
 

Re: [Mesa-dev] [PATCH 2/2] intel: Support new dri image interface v2

2012-08-31 Thread Kristian Høgsberg
On Fri, Aug 31, 2012 at 9:22 AM, Jakob Bornecrantz ja...@vmware.com wrote:
 Follow up to the previous patch, kept seperate for easier viewing,
 will be merged with previous patch before commiting.

 v2: Should fix YUV pitch/stride == 0.

 Signed-off-by: Jakob Bornecrantz ja...@vmware.com

Works here too:

Tested-by: Kristian Høgsberg k...@bitplanet.net
Reviewed-by: Kristian Høgsberg k...@bitplanet.net

thanks,
Kristian


 ---
  src/mesa/drivers/dri/intel/intel_regions.h |   26 ++
  src/mesa/drivers/dri/intel/intel_screen.c  |  135 
 ++--
  2 files changed, 153 insertions(+), 8 deletions(-)

 diff --git a/src/mesa/drivers/dri/intel/intel_regions.h 
 b/src/mesa/drivers/dri/intel/intel_regions.h
 index 4ff0efe..c0fdc95 100644
 --- a/src/mesa/drivers/dri/intel/intel_regions.h
 +++ b/src/mesa/drivers/dri/intel/intel_regions.h
 @@ -141,12 +141,38 @@ uint32_t
  intel_region_get_aligned_offset(struct intel_region *region, uint32_t x,
  uint32_t y);

 +/**
 + * Used with images created with image_from_names
 + * to help support planar images.
 + */
 +typedef struct intel_image_format {
 +   int fourcc;
 +   int components;
 +   int nplanes;
 +   struct {
 +  int buffer_index;
 +  int width_shift;
 +  int height_shift;
 +  uint32_t dri_format;
 +  int cpp;
 +   } planes[3];
 +} intel_image_format_t;
 +
  struct __DRIimageRec {
 struct intel_region *region;
 GLenum internal_format;
 uint32_t dri_format;
 GLuint format;
 uint32_t offset;
 +
 +   /*
 +* Need to save these here between calls to
 +* image_from_names and calls to image_from_planar.
 +*/
 +   uint32_t strides[3];
 +   uint32_t offsets[3];
 +   struct intel_image_format *planar_format;
 +
 void *data;
  };

 diff --git a/src/mesa/drivers/dri/intel/intel_screen.c 
 b/src/mesa/drivers/dri/intel/intel_screen.c
 index 55cebac..f20b072 100644
 --- a/src/mesa/drivers/dri/intel/intel_screen.c
 +++ b/src/mesa/drivers/dri/intel/intel_screen.c
 @@ -190,6 +190,59 @@ static const struct __DRI2flushExtensionRec 
 intelFlushExtension = {
  dri2InvalidateDrawable,
  };

 +intel_image_format_t intel_image_formats[] = {
 +   { __DRI_IMAGE_FOURCC_ARGB, __DRI_IMAGE_COMPONENTS_RGBA, 1,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB, 4 } } },
 +
 +   { __DRI_IMAGE_FOURCC_XRGB, __DRI_IMAGE_COMPONENTS_RGB, 1,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB, 4 }, } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV411, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 2, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV420, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 1, 1, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV422, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 1, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_YUV444, __DRI_IMAGE_COMPONENTS_Y_U_V, 3,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 2, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 } } },
 +
 +   { __DRI_IMAGE_FOURCC_NV12, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 1, __DRI_IMAGE_FORMAT_GR88, 2 } } },
 +
 +   { __DRI_IMAGE_FOURCC_NV16, __DRI_IMAGE_COMPONENTS_Y_UV, 2,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
 +   { 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
 +
 +   /* For YUYV buffers, we set up two overlapping DRI images and treat
 +* them as planar buffers in the compositors.  Plane 0 is GR88 and
 +* samples YU or YV pairs and places Y into the R component, while
 +* plane 1 is ARGB and samples YUYV clusters and places pairs and
 +* places U into the G component and V into A.  This lets the
 +* texture sampler interpolate the Y components correctly when
 +* sampling from plane 0, and interpolate U and V correctly when
 +* sampling from plane 1. */
 +   { __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
 + { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
 +   { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB, 4 } } }
 +};
 +
  static __DRIimage *
  intel_allocate_image(int dri_format, void *loaderPrivate)
  {
 @@ -249,7 +302,7 @@ intel_create_image_from_name(__DRIscreen *screen,

  image = intel_allocate_image(format, loaderPrivate);
  if (image-format == MESA_FORMAT_NONE)
 -   cpp = 0;
 +   cpp = 1;
  else
 cpp = _mesa_get_format_bytes(image-format);
  image-region = 

Re: [Mesa-dev] [PATCH 2/2] intel: Support new dri image interface v2

2012-08-31 Thread Scott Moreau
On Fri, Aug 31, 2012 at 10:39 AM, Kristian Høgsberg k...@bitplanet.netwrote:

 On Fri, Aug 31, 2012 at 9:22 AM, Jakob Bornecrantz ja...@vmware.com
 wrote:
  Follow up to the previous patch, kept seperate for easier viewing,
  will be merged with previous patch before commiting.
 
  v2: Should fix YUV pitch/stride == 0.
 
  Signed-off-by: Jakob Bornecrantz ja...@vmware.com



Also works here.

Tested-by: Scott Moreau ore...@gmail.com


Scott
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev