Mesa (main): iris: More gracefully fail in resource_from_user_memory

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 13 19:43:43 UTC 2022


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

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Tue Apr 12 13:34:26 2022 -0500

iris: More gracefully fail in resource_from_user_memory

rusticl (and clover) would like to get a graceful fail here so they can
fall back to a shadow copy instead of us asserting.  We also start
rejecting arrayed surface because isl doesn't allow selecting a QPitch
yet.  Even if it did, QPitch is horribly restrictive, even for linear
surfaces, that it likely wouldn't be that useful.

Fixes: e81f3edf76b0 ("iris: Allow userptr on 1D and 2D images")
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15903>

---

 src/gallium/drivers/iris/iris_resource.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index a690c2bec0e..b5a80c62fa4 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -1175,9 +1175,13 @@ iris_resource_from_user_memory(struct pipe_screen *pscreen,
    if (!res)
       return NULL;
 
-   assert(templ->target == PIPE_BUFFER ||
-          templ->target == PIPE_TEXTURE_1D ||
-          templ->target == PIPE_TEXTURE_2D);
+   if (templ->target != PIPE_BUFFER &&
+       templ->target != PIPE_TEXTURE_1D &&
+       templ->target != PIPE_TEXTURE_2D)
+      return NULL;
+
+   if (templ->array_size > 1)
+      return NULL;
 
    size_t res_size = templ->width0;
    if (templ->target != PIPE_BUFFER) {



More information about the mesa-commit mailing list