From 55d8baa285524e01eb241aa70057fb8e637fa14e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 23 Jan 2020 20:40:35 -0500 Subject: [PATCH] gallium/u_upload_mgr: don't do align twice in the u_upload_alloc fast path Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/auxiliary/util/u_upload_mgr.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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)) { -- 2.7.4