Mesa (master): gallium/u_upload_mgr: don't do align twice in the u_upload_alloc fast path
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Feb 14 23:52:33 UTC 2020
Module: Mesa
Branch: master
Commit: 55d8baa285524e01eb241aa70057fb8e637fa14e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=55d8baa285524e01eb241aa70057fb8e637fa14e
Author: Marek Olšák <marek.olsak at amd.com>
Date: Thu Jan 23 20:40:35 2020 -0500
gallium/u_upload_mgr: don't do align twice in the u_upload_alloc fast path
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3829>
---
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 c199ad0edf1..375fad005b4 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)) {
More information about the mesa-commit
mailing list