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 <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32431>
This commit is contained in:
Erik Faye-Lund 2024-11-29 21:40:51 +01:00 committed by Marge Bot
parent d195e411fa
commit 0f13a42657

View file

@ -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;
}