intel/isl: Fix isl_format_is_valid

The format enum space isn't necessarily contiguous so we can't assume
that if it's in the table it's valid.  We need to check something.

Fixes: ed6e586562 "intel: properly constify isl_format_layouts"
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11191>
This commit is contained in:
Jason Ekstrand 2021-06-04 15:15:30 -05:00
parent 90a5fef85c
commit b742f73913

View file

@ -105,7 +105,12 @@ isl_format_is_valid(enum isl_format format)
{
if (format >= sizeof(isl_format_layouts) / sizeof(isl_format_layouts[0]))
return false;
return true;
/* Only ISL_FORMAT_R32G32B32A32_FLOAT == 0 but that's a valid format.
* For all others, if this doesn't match then the entry in the table
* must not exist.
*/
return isl_format_layouts[format].format == format;
}
enum isl_format