From 3bc09aaf1ab142292ba7fe669dec1443e55f4e41 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Fri, 1 Sep 2023 11:52:50 +0200 Subject: [PATCH] asahi: gracefully handle allocating linear images Frontends might try to allocate linear textures or images, we should gracefully return NULL so frontends can do fallback paths. Signed-off-by: Karol Herbst Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 162bb54..8fa5006 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -499,8 +499,10 @@ agx_select_best_modifier(const struct agx_resource *pres) return DRM_FORMAT_MOD_APPLE_TWIDDLED; } - assert(agx_linear_allowed(pres)); - return DRM_FORMAT_MOD_LINEAR; + if (agx_linear_allowed(pres)) + return DRM_FORMAT_MOD_LINEAR; + else + return DRM_FORMAT_MOD_INVALID; } static struct pipe_resource * @@ -521,16 +523,14 @@ agx_resource_create_with_modifiers(struct pipe_screen *screen, if (modifiers) { nresource->modifier = agx_select_modifier_from_list(nresource, modifiers, count); - - /* There may not be a matching modifier, bail if so */ - if (nresource->modifier == DRM_FORMAT_MOD_INVALID) { - free(nresource); - return NULL; - } } else { nresource->modifier = agx_select_best_modifier(nresource); + } - assert(nresource->modifier != DRM_FORMAT_MOD_INVALID); + /* There may not be a matching modifier, bail if so */ + if (nresource->modifier == DRM_FORMAT_MOD_INVALID) { + free(nresource); + return NULL; } /* If there's only 1 layer and there's no compression, there's no harm in -- 2.7.4