nouveau: treat DRM_FORMAT_INVALID as implicit modifier
authorDiogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Fri, 23 Sep 2022 13:40:34 +0000 (14:40 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Oct 2022 13:35:52 +0000 (13:35 +0000)
Failing to allocate resources when DRM_FORMAT_INVALID
is passed as a modifier breaks tegra. Change this behaviour
so that this modifier is instead interpreted as a don't care,
allowing for the driver to choose an appropriate modifier internally.

v2: change nouveau instead of tegra (Thierry Rieding)

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6693
Fixes: 129d83cac2a ("nouveau: Use format modifiers in buffer allocation")
Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18649>

src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c

index e0a9d48..e93d66c 100644 (file)
@@ -423,9 +423,12 @@ nvc0_miptree_select_best_modifier(struct pipe_screen *pscreen,
 
    for (i = 0u; i < count; i++) {
       for (p = 0; p < ARRAY_SIZE(prio_supported_mods); p++) {
-         if (prio_supported_mods[p] == modifiers[i]) {
-            if (top_mod_slot > p) top_mod_slot = p;
-            break;
+         if (prio_supported_mods[p] != DRM_FORMAT_MOD_INVALID) {
+            if (modifiers[i] == DRM_FORMAT_MOD_INVALID ||
+                prio_supported_mods[p] == modifiers[i]) {
+               if (top_mod_slot > p) top_mod_slot = p;
+               break;
+            }
          }
       }
    }