[Mesa-dev] [v4 03/10] intel: replace single region with a vector of regions

Chad Versace chad.versace at linux.intel.com
Tue May 21 22:11:17 PDT 2013


On 05/02/2013 12:08 AM, Topi Pohjolainen wrote:
> No functional change in preparation for supporting multiple planes
> per image each having its own region.
>
> Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
>   src/mesa/drivers/dri/intel/intel_fbo.c       |  6 +--
>   src/mesa/drivers/dri/intel/intel_regions.h   |  7 ++-
>   src/mesa/drivers/dri/intel/intel_screen.c    | 69 ++++++++++++++--------------
>   src/mesa/drivers/dri/intel/intel_tex_image.c |  2 +-
>   4 files changed, 45 insertions(+), 39 deletions(-)

[snip]

> diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
> index 1fb6b27..e610f6b 100644
> --- a/src/mesa/drivers/dri/intel/intel_regions.h
> +++ b/src/mesa/drivers/dri/intel/intel_regions.h
> @@ -129,8 +129,13 @@ struct intel_image_format {
>      } planes[3];
>   };
>
> +/**
> + * An image representing multiple planes may come in two flavours:
> + *  - all planes in single region but in different offsets or
> + *  - each plane in its own region.
> + */


In case (1), does image->regions contain a single image, or does
it contain 3 pointers to the same image?

More importantly, I don't understand a key point here. By examining a given instance
of __DRIimageRec, how can I determine if the image falls under case (1)
or case (2)?

Here is a concrete instance of the problem I don't know how to solve.
Suppose that I have an instance of __DRIimageRec and that I've determined
so far that its contents are as below, where image->planar_format was obtained
by a lookup in the intel_screen.c:intel_image_formats table.

   image = {
     // ...
     .planar_format = {
        .fourcc = __DRI_IMAGE_FOURCC_YUV422,
        .components = __DRI_IMAGE_COMPONENTS_Y_U_V,
        .nplanes = 3,
        . planes = {
          [0] = {
            .buffer_index = 0,
             .dri_format = __DRI_IMAGE_FORMAT_R8,
             // ...
           },
          [1] = {
            .buffer_index = 1,
            .dri_format = __DRI_IMAGE_FORMAT_R8,
            // ...
          },
          [2] = {
            .buffer_index = 2,
            .dri_format = __DRI_IMAGE_FORMAT_R8,
            // ...
           },
     };

With this information, how can I know if dereferencing image->regions[1]
will segfault or not? That is, how can I know if this image have one or
three images?

>   struct __DRIimageRec {
> -   struct intel_region *region;
> +   struct intel_region *regions[3];
>      GLenum internal_format;
>      uint32_t dri_format;
>      GLuint format;

[snip]



More information about the mesa-dev mailing list