[Mesa-dev] [PATCH v2] intel: set dri_format field for all images
Kristian Hoegsberg
hoegsberg at gmail.com
Mon Apr 30 10:25:10 PDT 2012
On Mon, Apr 30, 2012 at 12:32:45PM +0300, Ander Conselvan de Oliveira wrote:
> Only images created with intel_create_image() had the field properly
> set. Set it also on intel_dup_image(), intel_create_image_from_name()
> and intel_create_image_from_renderbuffer().
> ---
> Changed patch to also handle format 565 in
> intel_create_image_from_renderbuffer().
>
> I'm not sure where would be the best place to add helper functions for
> converting between the formats, but I can send a follow up patch if
> someone points me in the right direction.
I think we could just fold the common parts of
intel_create_image_from_name and intel_create_image into a helper
function. The helper function would allocate the __DRIimage, do that
switch on the dri format code and set image->dri_format and image->data.
Kristian
> Thanks,
> Ander
>
> src/mesa/drivers/dri/intel/intel_screen.c | 18 ++++++++++++++++++
> 1 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
> index ac21e96..ac6b22f 100644
> --- a/src/mesa/drivers/dri/intel/intel_screen.c
> +++ b/src/mesa/drivers/dri/intel/intel_screen.c
> @@ -188,6 +188,8 @@ intel_create_image_from_name(__DRIscreen *screen,
> if (image == NULL)
> return NULL;
>
> + image->dri_format = format;
> +
> switch (format) {
> case __DRI_IMAGE_FORMAT_RGB565:
> image->format = MESA_FORMAT_RGB565;
> @@ -255,6 +257,21 @@ intel_create_image_from_renderbuffer(__DRIcontext *context,
> image->data = loaderPrivate;
> intel_region_reference(&image->region, irb->mt->region);
>
> + switch (image->format) {
> + case MESA_FORMAT_RGB565:
> + image->dri_format = __DRI_IMAGE_FORMAT_RGB565;
> + break;
> + case MESA_FORMAT_XRGB8888:
> + image->dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
> + break;
> + case MESA_FORMAT_ARGB8888:
> + image->dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
> + break;
> + case MESA_FORMAT_RGBA8888_REV:
> + image->dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
> + break;
> + }
> +
> return image;
> }
>
> @@ -365,6 +382,7 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
> }
>
> image->internal_format = orig_image->internal_format;
> + image->dri_format = orig_image->dri_format;
> image->format = orig_image->format;
> image->data_type = orig_image->data_type;
> image->data = loaderPrivate;
> --
> 1.7.4.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list