From bd3392423ddc82f1e8fe63c10b673b1bb70decf3 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Mon, 26 Feb 2018 17:57:19 -0800 Subject: [PATCH] intel/isl: Add isl_format_is_valid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jordan Justen Reviewed-by: Samuel Iglesias Gonsálvez --- src/intel/isl/gen_format_layout.py | 8 ++++++++ src/intel/isl/isl.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/intel/isl/gen_format_layout.py b/src/intel/isl/gen_format_layout.py index 0ca42dbab8d..53cdd3b8110 100644 --- a/src/intel/isl/gen_format_layout.py +++ b/src/intel/isl/gen_format_layout.py @@ -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) { diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index 863b6e4befa..0da6abb71d4 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -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) { -- 2.30.2