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 <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38896>
This commit is contained in:
Rob Clark
2025-12-10 16:46:25 -08:00
committed by Marge Bot
parent bdacab49c7
commit b2daaaec81
+15 -1
View File
@@ -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);