[PATCH 5/7] wined3d: Copy channel info for typed formats from typeless formats.

Henri Verbeet hverbeet at gmail.com
Wed Feb 10 09:20:10 CST 2016


On 10 February 2016 at 02:14, Józef Kucia <jkucia at codeweavers.com> wrote:
> @@ -1436,8 +1408,7 @@ static inline int getFmtIdx(enum wined3d_format_id format_id)
>  {
>      /* First check if the format is at the position of its value.
>       * This will catch the argb formats before the loop is entered. */
> -    if (format_id < (sizeof(formats) / sizeof(*formats))
> -            && formats[format_id].id == format_id)
> +    if (format_id < ARRAY_SIZE(formats) && formats[format_id].id == format_id)
>      {
>          return format_id;
>      }
> @@ -1445,10 +1416,10 @@ static inline int getFmtIdx(enum wined3d_format_id format_id)
>      {
>          unsigned int i;
>
> -        for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i)
> -        {
> +        for (i = 0; i < ARRAY_SIZE(formats); ++i)
>              if (formats[i].id == format_id) return i;
> -        }
> +        for (i = 0; i < ARRAY_SIZE(typed_formats); ++i)
> +            if (typed_formats[i].id == format_id) return ARRAY_SIZE(formats) + i;
>      }
>      return -1;
>  }
I'm not sure this is really the way to go. I'd prefer to just reorder
things in such a way that the format id is the index in all cases
except for FourCC formats. Patch 7/7 goes a long way in that
direction, but to me it looks more complicated than just having a
small table to remap the FourCC formats to an index. One additional
advantage would be that we could then also remap e.g. DXT2 and DXT3 to
BC2. E.g.:

struct
{
    enum wined3d_format_id id;
    unsigned int idx;
}
remap[] =
{
    {UYVY, FOURCC_BASE}
    {YUY2, FOURCC_BASE + 1}
    {YV12, FOURCC_BASE + 2}
    {DXT1, BC1},
    {DXT2, BC2},
    {DXT3, BC2},
    {DXT4, BC3},
    {DXT5, BC3},
};



More information about the wine-devel mailing list