From: Marek Olšák Date: Fri, 24 Jan 2020 01:40:35 +0000 (-0500) Subject: gallium/u_upload_mgr: don't do align twice in the u_upload_alloc fast path X-Git-Tag: upstream/20.1.8~3437 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55d8baa285524e01eb241aa70057fb8e637fa14e;p=platform%2Fupstream%2Fmesa.git gallium/u_upload_mgr: don't do align twice in the u_upload_alloc fast path Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index c199ad0..375fad0 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -244,18 +244,17 @@ u_upload_alloc(struct u_upload_mgr *upload, void **ptr) { unsigned buffer_size = upload->buffer_size; - unsigned offset; + unsigned offset = MAX2(min_out_offset, upload->offset); - min_out_offset = align(min_out_offset, alignment); - - offset = align(upload->offset, alignment); - offset = MAX2(offset, min_out_offset); + offset = align(offset, alignment); /* Make sure we have enough space in the upload buffer * for the sub-allocation. */ if (unlikely(offset + size > buffer_size)) { - buffer_size = u_upload_alloc_buffer(upload, min_out_offset + 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); if (unlikely(!buffer_size)) { *out_offset = ~0; @@ -263,8 +262,6 @@ u_upload_alloc(struct u_upload_mgr *upload, *ptr = NULL; return; } - - offset = min_out_offset; } if (unlikely(!upload->map)) {