From beb3819d66e50d9c74cf1277ae915efdebefeb54 Mon Sep 17 00:00:00 2001 From: Diogo Ivo Date: Fri, 23 Sep 2022 14:40:34 +0100 Subject: [PATCH] nouveau: treat DRM_FORMAT_INVALID as implicit modifier 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 Reviewed-by: Thierry Reding Part-of: (cherry picked from commit 941c70a28a8db3a852ca5245354effa2bf1e7cf8) --- .pick_status.json | 2 +- src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 67404d8ad51..60ee6743b14 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -922,7 +922,7 @@ "description": "nouveau: treat DRM_FORMAT_INVALID as implicit modifier", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "129d83cac2accc4a66eae50c19ac245b864dc98c" }, diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c index e0a9d48249f..e93d66c71b6 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c @@ -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; + } } } }