#define PAGE_SIZE 4096
#endif
-static inline uint32_t
-ilog2_round_up(uint32_t value)
-{
- assert(value != 0);
- return 32 - __builtin_clz(value - 1);
-}
-
-static inline uint32_t
-round_to_power_of_two(uint32_t value)
-{
- return 1 << ilog2_round_up(value);
-}
-
struct anv_state_table_cleanup {
void *map;
size_t size;
static uint32_t
anv_state_pool_get_bucket(uint32_t size)
{
- unsigned size_log2 = ilog2_round_up(size);
+ unsigned size_log2 = util_logbase2_ceil(size);
assert(size_log2 <= ANV_MAX_STATE_SIZE_LOG2);
if (size_log2 < ANV_MIN_STATE_SIZE_LOG2)
size_log2 = ANV_MIN_STATE_SIZE_LOG2;
if (offset + size > stream->block.alloc_size) {
uint32_t block_size = stream->block_size;
if (block_size < size)
- block_size = round_to_power_of_two(size);
+ block_size = util_next_power_of_two(size);
stream->block = anv_state_pool_alloc_no_vg(stream->state_pool,
block_size, PAGE_SIZE);
anv_bo_pool_alloc(struct anv_bo_pool *pool, uint32_t size,
struct anv_bo **bo_out)
{
- const unsigned size_log2 = size < 4096 ? 12 : ilog2_round_up(size);
+ const unsigned size_log2 = size < 4096 ? 12 : util_logbase2_ceil(size);
const unsigned pow2_size = 1 << size_log2;
const unsigned bucket = size_log2 - 12;
assert(bucket < ARRAY_SIZE(pool->free_list));
VG(VALGRIND_MEMPOOL_FREE(pool, bo->map));
assert(util_is_power_of_two_or_zero(bo->size));
- const unsigned size_log2 = ilog2_round_up(bo->size);
+ const unsigned size_log2 = util_logbase2_ceil(bo->size);
const unsigned bucket = size_log2 - 12;
assert(bucket < ARRAY_SIZE(pool->free_list));
cmd_buffer->state.push_constants_dirty |= mesa_to_vk_shader_stage(stage);
}
-static inline uint32_t
-ilog2_round_up(uint32_t value)
-{
- assert(value != 0);
- return 32 - __builtin_clz(value - 1);
-}
-
static void
anv_cmd_buffer_set_ray_query_buffer(struct anv_cmd_buffer *cmd_buffer,
struct anv_cmd_pipeline_state *pipeline_state,
if (ray_shadow_size > 0 &&
(!cmd_buffer->state.ray_query_shadow_bo ||
cmd_buffer->state.ray_query_shadow_bo->size < ray_shadow_size)) {
- unsigned shadow_size_log2 = MAX2(ilog2_round_up(ray_shadow_size), 16);
+ unsigned shadow_size_log2 = MAX2(util_logbase2_ceil(ray_shadow_size), 16);
unsigned bucket = shadow_size_log2 - 16;
assert(bucket < ARRAY_SIZE(device->ray_query_shadow_bos));
uint32_t stack_ids_per_dss = 2048; /* TODO */
- unsigned stack_size_log2 = ilog2_round_up(pipelineStackSize);
+ unsigned stack_size_log2 = util_logbase2_ceil(pipelineStackSize);
if (stack_size_log2 < 10)
stack_size_log2 = 10;