Mesa (main): radeonsi: Check if modifier supports the image extent

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 11 12:24:32 UTC 2021


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

Author: Joshua Ashton <joshua at froggi.es>
Date:   Sun Sep 26 20:14:34 2021 +0100

radeonsi: Check if modifier supports the image extent

DCN only supports an extent < 4K on !64B && 128B.

Signed-off-by: Joshua Ashton <joshua at froggi.es>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13056>

---

 src/gallium/drivers/radeonsi/si_texture.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c
index 5205c719028..f17fe14309a 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -1384,6 +1384,18 @@ si_get_dmabuf_modifier_planes(struct pipe_screen *pscreen, uint64_t modifier,
    return planes;
 }
 
+static bool
+si_modifier_supports_resource(struct pipe_screen *screen,
+                              uint64_t modifier,
+                              const struct pipe_resource *templ)
+{
+   struct si_screen *sscreen = (struct si_screen *)screen;
+   uint32_t max_width, max_height;
+
+   ac_modifier_max_extent(&sscreen->info, modifier, &max_width, &max_height);
+   return templ->width0 <= max_width && templ->height0 <= max_height;
+}
+
 static struct pipe_resource *
 si_texture_create_with_modifiers(struct pipe_screen *screen,
                                  const struct pipe_resource *templ,
@@ -1413,7 +1425,7 @@ si_texture_create_with_modifiers(struct pipe_screen *screen,
    for (int i = 0; i < allowed_mod_count; ++i) {
       bool found = false;
       for (int j = 0; j < modifier_count && !found; ++j)
-         if (modifiers[j] == allowed_modifiers[i])
+         if (modifiers[j] == allowed_modifiers[i] && si_modifier_supports_resource(screen, modifiers[j], templ))
             found = true;
 
       if (found) {



More information about the mesa-commit mailing list