From 0f13a426576718b28b4bea4340153417b5af0553 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 29 Nov 2024 21:40:51 +0100 Subject: [PATCH] gallium/aux: do not assert on map-failures The texture_map functions can fail, due to for instance address-space exhaustion during mmap calls. Handling this by asserting turns this into a fatal error when doing debug builds, which might not be what users want. Instead, let's allow this to fail. This is alredy what we do for util_clear_color_texture and util_clear_render_target. While we're at it, let's add some breadcrumbs to applications here, by emitting an error at the same time. We should really consider returning a proper pipe_error here instead, but that requires changing a lot of function signatures, as this function are used as an implementation of p_context::resource_copy_region()... So let's save that for later. Reviewed-by: Adam Jackson Part-of: --- src/gallium/auxiliary/util/u_surface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index d0e94f2db2b..11b16e6f229 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -42,6 +42,7 @@ #include "util/u_surface.h" #include "util/u_pack_color.h" #include "util/u_memset.h" +#include "util/log.h" /** * Initialize a pipe_surface object. 'view' is considered to have @@ -294,8 +295,8 @@ util_resource_copy_region(struct pipe_context *pipe, src_level, PIPE_MAP_READ, &src_box, &src_trans); - assert(src_map); if (!src_map) { + mesa_loge("util_resource_copy_region: mapping src-buffer failed"); goto no_src_map_buf; } @@ -305,8 +306,8 @@ util_resource_copy_region(struct pipe_context *pipe, PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE, &dst_box, &dst_trans); - assert(dst_map); if (!dst_map) { + mesa_loge("util_resource_copy_region: mapping dst-buffer failed"); goto no_dst_map_buf; } @@ -325,8 +326,8 @@ util_resource_copy_region(struct pipe_context *pipe, src_level, PIPE_MAP_READ, &src_box, &src_trans); - assert(src_map); if (!src_map) { + mesa_loge("util_resource_copy_region: mapping src-texture failed"); goto no_src_map; } @@ -336,8 +337,8 @@ util_resource_copy_region(struct pipe_context *pipe, PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE, &dst_box, &dst_trans); - assert(dst_map); if (!dst_map) { + mesa_loge("util_resource_copy_region: mapping dst-texture failed"); goto no_dst_map; }