[Mesa-dev] [PATCH] i965: verify intermediate steps when converting format

Lionel Landwerlin lionel.g.landwerlin at intel.com
Tue Jun 5 16:39:22 UTC 2018


An invalid format could be computed through the
modifier_is_supported() helper. Better verify each step.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=10664
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c |  4 ++++
 src/mesa/drivers/dri/i965/intel_screen.c      | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 69024c0678b..cf39d91246f 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -265,6 +265,8 @@ format_ccs_e_compat_with_miptree(const struct gen_device_info *devinfo,
 
    mesa_format linear_format = _mesa_get_srgb_format_linear(mt->format);
    enum isl_format isl_format = brw_isl_format_for_mesa_format(linear_format);
+   if (isl_format == ISL_FORMAT_UNSUPPORTED)
+      return false;
    return isl_formats_are_ccs_e_compatible(devinfo, isl_format, access_format);
 }
 
@@ -296,6 +298,8 @@ intel_miptree_supports_ccs_e(struct brw_context *brw,
     */
    mesa_format linear_format = _mesa_get_srgb_format_linear(mt->format);
    enum isl_format isl_format = brw_isl_format_for_mesa_format(linear_format);
+   if (isl_format == ISL_FORMAT_UNSUPPORTED)
+      return false;
    return isl_format_supports_ccs_e(&brw->screen->devinfo, isl_format);
 }
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 935711106c0..9f20347d512 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -342,8 +342,14 @@ modifier_is_supported(const struct gen_device_info *devinfo,
 
       mesa_format format = driImageFormatToGLFormat(dri_format);
       format = _mesa_get_srgb_format_linear(format);
-      if (!isl_format_supports_ccs_e(devinfo,
-                                     brw_isl_format_for_mesa_format(format)))
+      if (format == MESA_FORMAT_NONE)
+         return false;
+
+      enum isl_format isl_format = brw_isl_format_for_mesa_format(format);
+      if (isl_format == ISL_FORMAT_UNSUPPORTED)
+         return false;
+
+      if (!isl_format_supports_ccs_e(devinfo, isl_format))
          return false;
    }
 
-- 
2.17.1



More information about the mesa-dev mailing list