Mesa (main): i965: Don't advertise Y-tiled modifiers for scanout buffers on Gfx8-

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 21 01:39:35 UTC 2021


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu May 20 13:04:15 2021 -0700

i965: Don't advertise Y-tiled modifiers for scanout buffers on Gfx8-

According to isl_gfx7.c:264, the display engine does not support Y
tiled buffers prior to Skylake.  But we exposed I915_FORMAT_MOD_Y_TILED
even when querying for a list of modifiers with __DRI_IMAGE_USE_SCANOUT
set, which we can't support.  That led to crashes later when we tried
to create such an image, and isl rightly denied it.

This duplicates a bit of code from ISL, but the isl_gfx6_filter_tiling
function that we ought to use to filter things relies on surf_info,
which we don't have at this stage.  This is probably good enough.

Fixes crashes in wflinfo since c03e79d7831f, but the bug exists before
that and it's probably worth a stable backport even without that patch.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4815
Fixes: c03e79d7831 ("loader/dri: hook up createImageWithModifiers2")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10907>

---

 src/mesa/drivers/dri/i965/brw_screen.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_screen.c b/src/mesa/drivers/dri/i965/brw_screen.c
index 835b711729f..32f220c0611 100644
--- a/src/mesa/drivers/dri/i965/brw_screen.c
+++ b/src/mesa/drivers/dri/i965/brw_screen.c
@@ -357,7 +357,7 @@ static const struct {
 static bool
 modifier_is_supported(const struct intel_device_info *devinfo,
                       const struct brw_image_format *fmt, int dri_format,
-                      uint64_t modifier)
+                      unsigned use, uint64_t modifier)
 {
    const struct isl_drm_modifier_info *modinfo =
       isl_drm_modifier_get_info(modifier);
@@ -367,6 +367,11 @@ modifier_is_supported(const struct intel_device_info *devinfo,
    if (!modinfo)
       return false;
 
+   if (devinfo->ver < 9 && (use & __DRI_IMAGE_USE_SCANOUT) &&
+       !(modinfo->tiling == ISL_TILING_LINEAR ||
+         modinfo->tiling == ISL_TILING_X))
+      return false;
+
    if (modinfo->aux_usage == ISL_AUX_USAGE_CCS_E) {
       /* If INTEL_DEBUG=norbc is set, don't support any CCS_E modifiers */
       if (INTEL_DEBUG & DEBUG_NO_RBC)
@@ -687,13 +692,14 @@ const uint64_t priority_to_modifier[] = {
 static uint64_t
 select_best_modifier(struct intel_device_info *devinfo,
                      int dri_format,
+                     unsigned use,
                      const uint64_t *modifiers,
                      const unsigned count)
 {
    enum modifier_priority prio = MODIFIER_PRIORITY_INVALID;
 
    for (int i = 0; i < count; i++) {
-      if (!modifier_is_supported(devinfo, NULL, dri_format, modifiers[i]))
+      if (!modifier_is_supported(devinfo, NULL, dri_format, use, modifiers[i]))
          continue;
 
       switch (modifiers[i]) {
@@ -743,7 +749,7 @@ brw_create_image_common(__DRIscreen *dri_screen,
    if (modifier == DRM_FORMAT_MOD_INVALID) {
       if (modifiers) {
          /* User requested specific modifiers */
-         modifier = select_best_modifier(&screen->devinfo, format,
+         modifier = select_best_modifier(&screen->devinfo, format, use,
                                          modifiers, count);
          if (modifier == DRM_FORMAT_MOD_INVALID)
             return NULL;
@@ -992,7 +998,7 @@ brw_query_format_modifier_attribs(__DRIscreen *dri_screen,
    struct brw_screen *screen = dri_screen->driverPrivate;
    const struct brw_image_format *f = brw_image_format_lookup(fourcc);
 
-   if (!modifier_is_supported(&screen->devinfo, f, 0, modifier))
+   if (!modifier_is_supported(&screen->devinfo, f, 0, 0, modifier))
       return false;
 
    switch (attrib) {
@@ -1108,7 +1114,7 @@ brw_create_image_from_fds_common(__DRIscreen *dri_screen,
       return NULL;
 
    if (modifier != DRM_FORMAT_MOD_INVALID &&
-       !modifier_is_supported(&screen->devinfo, f, 0, modifier))
+       !modifier_is_supported(&screen->devinfo, f, 0, 0, modifier))
       return NULL;
 
    if (f->nplanes == 1)
@@ -1420,7 +1426,7 @@ brw_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
 
    for (i = 0; i < ARRAY_SIZE(supported_modifiers); i++) {
       uint64_t modifier = supported_modifiers[i].modifier;
-      if (!modifier_is_supported(&screen->devinfo, f, 0, modifier))
+      if (!modifier_is_supported(&screen->devinfo, f, 0, 0, modifier))
          continue;
 
       num_mods++;



More information about the mesa-commit mailing list