From b2daaaec81b020653400cafa336d27560c037079 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 10 Dec 2025 16:46:25 -0800 Subject: [PATCH] gallium/aux: Add debug option to force u_upload rollover Triggering the rollover where the old upload buffer is released is a good way to catch bugs with a releasebuf being dropped too soon (ie. while the frontend still needs a reference). This makes it easy to reproduce firefox crashes in any driver where pipe->const_uploader == pipe->stream_uploader. Signed-off-by: Rob Clark Part-of: --- src/gallium/auxiliary/util/u_upload_mgr.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index b2cbbe6fb37..bd2afdd1a07 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -215,6 +215,20 @@ u_upload_alloc_buffer(struct u_upload_mgr *upload, unsigned min_size, struct pip return size; } +#if MESA_DEBUG +DEBUG_GET_ONCE_BOOL_OPTION(force_reallocate, "U_UPLOAD_FORCE_REALLOCATE", false) +#endif + +static inline bool +force_reallocate(void) +{ +#if MESA_DEBUG + return debug_get_option_force_reallocate(); +#else + return false; +#endif +} + void u_upload_alloc(struct u_upload_mgr *upload, unsigned min_out_offset, @@ -233,7 +247,7 @@ u_upload_alloc(struct u_upload_mgr *upload, /* Make sure we have enough space in the upload buffer * for the sub-allocation. */ - if (unlikely(offset + size > buffer_size)) { + if (force_reallocate() || unlikely(offset + size > buffer_size)) { /* Allocate a new buffer and set the offset to the smallest one. */ offset = align(min_out_offset, alignment); buffer_size = u_upload_alloc_buffer(upload, offset + size, releasebuf);