intel/isl: Add isl_format_is_valid
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 27 Feb 2018 01:57:19 +0000 (17:57 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Mon, 5 Mar 2018 17:51:01 +0000 (09:51 -0800)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/intel/isl/gen_format_layout.py
src/intel/isl/isl.h

index 0ca42dbab8dfa9ebbb241ace37142903ff033dbe..53cdd3b8110917b1a43c9cac523ad2791b68977b 100644 (file)
@@ -89,6 +89,14 @@ isl_format_layouts[] = {
 % endfor
 };
 
+bool
+isl_format_is_valid(enum isl_format format)
+{
+    if (format >= sizeof(isl_format_layouts) / sizeof(isl_format_layouts[0]))
+        return false;
+    return isl_format_layouts[format].name;
+}
+
 enum isl_format
 isl_format_srgb_to_linear(enum isl_format format)
 {
index 863b6e4befae8602719663fd42be3bce29b11389..0da6abb71d44cd5adbeb165ae94ca1ca0a9e038b 100644 (file)
@@ -1410,6 +1410,8 @@ isl_format_get_layout(enum isl_format fmt)
    return &isl_format_layouts[fmt];
 }
 
+bool isl_format_is_valid(enum isl_format);
+
 static inline const char * ATTRIBUTE_CONST
 isl_format_get_name(enum isl_format fmt)
 {