Karmjit Mahil
3f18c91a0b
util/idalloc: Minor refactor of util_idalloc_foreach()
...
Changes the `for` loop code to be similar to
`util_idalloc_forach_no_zero_safe()` for cohesion.
Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32546 >
2024-12-10 08:29:00 +00:00
Karmjit Mahil
af346cd77f
util/idalloc: Fix util_idalloc_foreach() build issue
...
Currently `util_idalloc_foreach()` isn't being used in the codebase
but if used it causes a build error as `num_used` doesn't exist.
Fix that by using `num_set_elements`.
Fixes: 0589dfe4e2 ("util/idalloc: optimize foreach by tracking the greatest non-zero element")
Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32546 >
2024-12-10 08:29:00 +00:00
Marek Olšák
d4085aaf56
util: add util_idalloc_sparse, solving the excessive virtual memory usage
...
The code comment in the header file describes how it works.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30106 >
2024-07-17 10:29:12 +00:00
Marek Olšák
ace7c32333
util: don't use variable names that can appear in args of idalloc foreach macros
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30106 >
2024-07-17 10:29:12 +00:00
Marek Olšák
287ed620d0
util: make util_idalloc_exists private
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30106 >
2024-07-17 10:29:12 +00:00
Marek Olšák
0589dfe4e2
util/idalloc: optimize foreach by tracking the greatest non-zero element
...
also add util_idalloc_foreach_no_zero_safe.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27494 >
2024-02-21 16:04:51 +00:00
Marek Olšák
b48998926c
util/idalloc: add util_idalloc_alloc_range
...
v2: fixed infinite loop (Pierre-Eric)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
f29823df66
util/idalloc: add exists and foreach helpers
...
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
730014bd81
util/idalloc: hide or remove unused public functions
...
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
6ede24cf31
util/idalloc: fold the size call into init
...
It's required, otherwise idalloc would fail.
v2: renamed util_idalloc_(mt_)init param initial_num_ids (Pierre-Eric)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
995f6cbd74
util/idalloc: change num_elements to units of elements instead of bits
...
and use memset in resize().
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
3828081c92
util: add thread-safe version of idalloc
...
For buffer IDs in u_threaded_context.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10662 >
2021-05-17 10:37:24 +00:00
Pierre-Eric Pelloux-Prayer
553d371933
util/idalloc: add lowest_free_idx to avoid iterating from 0
...
lowest_free_idx is a conservative estimation of the lowest index
where a free id can be found.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600 >
2020-09-10 09:07:11 +02:00
Pierre-Eric Pelloux-Prayer
e808d38299
util/idalloc: add util_idalloc_reserve
...
Can be used to mark an id as used (if it was reclaimed without using
util_idalloc_alloc).
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600 >
2020-09-10 09:07:11 +02:00
Pierre-Eric Pelloux-Prayer
87ef970ee6
mesa: move u_idalloc from gallium/aux/util to util
...
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600 >
2020-09-10 09:07:03 +02:00