From 83d820973c16d2b1500731fc60439247f315832b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 15 Jul 2022 07:31:49 -0400 Subject: [PATCH] util/u_threaded: fix a CPU storage crash due to an invalid codepath taken Fixes: 3df9d8ed807 - gallium/u_threaded: implement pipelined partial buffer uploads using CPU storage Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6837 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6594 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6613 Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index a9f69b46580..74d39f8da9b 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -2370,8 +2370,14 @@ tc_transfer_flush_region(struct pipe_context *_pipe, tc_buffer_do_flush_region(tc, ttrans, &box); } - /* Staging transfers don't send the call to the driver. */ - if (ttrans->staging) + /* Staging transfers don't send the call to the driver. + * + * Transfers using the CPU storage shouldn't call transfer_flush_region + * in the driver because the buffer is not really mapped on the driver + * side and the CPU storage always re-uploads everything (flush_region + * makes no difference). + */ + if (ttrans->staging || ttrans->cpu_storage_mapped) return; }