util/math: Add ROUND_DOWN_TO_NPOT

The default ROUND_DOWN_TO only handles POT alignment values, so
an additional variant was added which handles NPOT alignment too.

Signed-off-by: Dhruv Mark Collins <mark@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37802>
This commit is contained in:
Dhruv Mark Collins 2025-10-09 13:56:30 +00:00
parent fac705ab8a
commit dde478ce98

View file

@ -705,6 +705,12 @@ ROUND_DOWN_TO(uint64_t value, uint32_t alignment)
return ((value) & ~(uint64_t)(alignment - 1));
}
static inline uint64_t
ROUND_DOWN_TO_NPOT(uint64_t value, uint32_t alignment)
{
return value - (value % alignment);
}
/**
* Align a value, only works pot alignemnts.
*/