asahi: Refuse to transfer out-of-bounds mip levels
authorAsahi Lina <lina@asahilina.net>
Fri, 9 Dec 2022 11:16:28 +0000 (20:16 +0900)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Feb 2023 07:45:12 +0000 (07:45 +0000)
Fixes ail asserts on a pile of dEQP3 tests.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21063>

src/gallium/drivers/asahi/agx_pipe.c

index 5b39955..689b66f 100644 (file)
@@ -742,6 +742,10 @@ agx_transfer_map(struct pipe_context *pctx, struct pipe_resource *resource,
    if ((usage & PIPE_MAP_DIRECTLY) && rsrc->modifier != DRM_FORMAT_MOD_LINEAR)
       return NULL;
 
+   /* Can't transfer out of bounds mip levels */
+   if (level >= rsrc->layout.levels)
+      return NULL;
+
    agx_prepare_for_map(ctx, rsrc, level, usage, box);
 
    struct agx_transfer *transfer = CALLOC_STRUCT(agx_transfer);