On 10 February 2016 at 02:14, Józef Kucia jkucia@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)
} return -1;if (typed_formats[i].id == format_id) return ARRAY_SIZE(formats) + i;
}
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}, };