Mesa (main): intel/isl: Fix isl_format_is_valid

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 4 21:36:11 UTC 2021


Module: Mesa
Branch: main
Commit: b742f7391351696d51adbfdf2c7b9b1a7bd5ef7d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b742f7391351696d51adbfdf2c7b9b1a7bd5ef7d

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Jun  4 15:15:30 2021 -0500

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: ed6e586562f4 "intel: properly constify isl_format_layouts"
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11191>

---

 src/intel/isl/gen_format_layout.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/intel/isl/gen_format_layout.py b/src/intel/isl/gen_format_layout.py
index 540c0537e27..9b23414f29e 100644
--- a/src/intel/isl/gen_format_layout.py
+++ b/src/intel/isl/gen_format_layout.py
@@ -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



More information about the mesa-commit mailing list