amd: replace most u_bit_consecutive* with BITFIELD_MASK/RANGE
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35346>
This commit is contained in:
@@ -2602,5 +2602,5 @@ uint32_t ac_gfx103_get_cu_mask_ps(const struct radeon_info *info)
|
||||
* increase clocks for busy CUs. In the future, we might disable or enable this
|
||||
* tweak only for certain apps.
|
||||
*/
|
||||
return u_bit_consecutive(0, info->min_good_cu_per_sa);
|
||||
return BITFIELD_MASK(info->min_good_cu_per_sa);
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,7 @@ static int gfx6_surface_settings(ADDR_HANDLE addrlib, const struct radeon_info *
|
||||
return r;
|
||||
|
||||
assert(AddrBaseSwizzleOut.tileSwizzle <=
|
||||
u_bit_consecutive(0, sizeof(surf->tile_swizzle) * 8));
|
||||
BITFIELD_MASK(sizeof(surf->tile_swizzle) * 8));
|
||||
surf->tile_swizzle = AddrBaseSwizzleOut.tileSwizzle;
|
||||
}
|
||||
return 0;
|
||||
@@ -1691,7 +1691,7 @@ static int gfx6_compute_surface(ADDR_HANDLE addrlib, const struct radeon_info *i
|
||||
if (r != ADDR_OK)
|
||||
return r;
|
||||
|
||||
assert(xout.tileSwizzle <= u_bit_consecutive(0, sizeof(surf->tile_swizzle) * 8));
|
||||
assert(xout.tileSwizzle <= BITFIELD_MASK(sizeof(surf->tile_swizzle) * 8));
|
||||
surf->fmask_tile_swizzle = xout.tileSwizzle;
|
||||
}
|
||||
}
|
||||
@@ -2260,7 +2260,7 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
|
||||
if (ret != ADDR_OK)
|
||||
return ret;
|
||||
|
||||
assert(xout.pipeBankXor <= u_bit_consecutive(0, sizeof(surf->tile_swizzle) * 8));
|
||||
assert(xout.pipeBankXor <= BITFIELD_MASK(sizeof(surf->tile_swizzle) * 8));
|
||||
surf->tile_swizzle = xout.pipeBankXor;
|
||||
|
||||
/* Gfx11 should shift it by 10 bits instead of 8, and drivers already shift it by 8 bits,
|
||||
@@ -2462,7 +2462,7 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_
|
||||
if (ret != ADDR_OK)
|
||||
return ret;
|
||||
|
||||
assert(xout.pipeBankXor <= u_bit_consecutive(0, sizeof(surf->fmask_tile_swizzle) * 8));
|
||||
assert(xout.pipeBankXor <= BITFIELD_MASK(sizeof(surf->fmask_tile_swizzle) * 8));
|
||||
surf->fmask_tile_swizzle = xout.pipeBankXor;
|
||||
}
|
||||
}
|
||||
@@ -3305,7 +3305,7 @@ static bool gfx12_compute_miptree(struct ac_addrlib *addrlib, const struct radeo
|
||||
if (ret != ADDR_OK)
|
||||
return false;
|
||||
|
||||
assert(xout.pipeBankXor <= u_bit_consecutive(0, sizeof(surf->tile_swizzle) * 8 + 2));
|
||||
assert(xout.pipeBankXor <= BITFIELD_MASK(sizeof(surf->tile_swizzle) * 8 + 2));
|
||||
surf->tile_swizzle = xout.pipeBankXor;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ ms_store_arrayed_output(nir_builder *b,
|
||||
bool hi_16b = io_sem.high_16bits;
|
||||
bool lo_16b = !hi_16b && store_val->bit_size == 16;
|
||||
|
||||
unsigned mapped_location = util_bitcount64(out->mask & u_bit_consecutive64(0, io_sem.location));
|
||||
unsigned mapped_location = util_bitcount64(out->mask & BITFIELD64_MASK(io_sem.location));
|
||||
unsigned num_outputs = util_bitcount64(out->mask);
|
||||
unsigned const_off = out->addr + component_offset * 4 + (hi_16b ? 2 : 0);
|
||||
|
||||
@@ -414,7 +414,7 @@ ms_load_arrayed_output(nir_builder *b,
|
||||
unsigned const_off = out->addr + component_offset * 4;
|
||||
|
||||
/* Use compacted location instead of the original semantic location. */
|
||||
unsigned mapped_location = util_bitcount64(out->mask & u_bit_consecutive64(0, location));
|
||||
unsigned mapped_location = util_bitcount64(out->mask & BITFIELD64_MASK(location));
|
||||
|
||||
nir_def *base_addr = ms_arrayed_output_base_addr(b, arr_index, mapped_location, num_outputs);
|
||||
nir_def *base_addr_off = nir_imul_imm(b, base_offset, 16);
|
||||
|
||||
@@ -1180,7 +1180,7 @@ static bool visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
|
||||
case nir_op_insert_u16: {
|
||||
unsigned size = instr->op == nir_op_insert_u8 ? 8 : 16;
|
||||
LLVMValueRef offset = LLVMConstInt(LLVMTypeOf(src[0]), nir_src_as_uint(instr->src[1].src) * size, false);
|
||||
LLVMValueRef mask = LLVMConstInt(LLVMTypeOf(src[0]), u_bit_consecutive(0, size), false);
|
||||
LLVMValueRef mask = LLVMConstInt(LLVMTypeOf(src[0]), BITFIELD_MASK(size), false);
|
||||
result = LLVMBuildShl(ctx->ac.builder, LLVMBuildAnd(ctx->ac.builder, src[0], mask, ""), offset, "");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1183,14 +1183,14 @@ gfx8_get_fast_clear_parameters(struct radv_device *device, const struct radv_ima
|
||||
|
||||
if (desc->channel[i].pure_integer && desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
|
||||
/* Use the maximum value for clamping the clear color. */
|
||||
int max = u_bit_consecutive(0, desc->channel[i].size - 1);
|
||||
int max = BITFIELD_MASK(desc->channel[i].size - 1);
|
||||
|
||||
values[i] = clear_value->int32[i] != 0;
|
||||
if (clear_value->int32[i] != 0 && MIN2(clear_value->int32[i], max) != max)
|
||||
return;
|
||||
} else if (desc->channel[i].pure_integer && desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) {
|
||||
/* Use the maximum value for clamping the clear color. */
|
||||
unsigned max = u_bit_consecutive(0, desc->channel[i].size);
|
||||
unsigned max = BITFIELD_MASK(desc->channel[i].size);
|
||||
|
||||
values[i] = clear_value->uint32[i] != 0U;
|
||||
if (clear_value->uint32[i] != 0U && MIN2(clear_value->uint32[i], max) != max)
|
||||
|
||||
@@ -225,7 +225,7 @@ lower_load_vs_input(nir_builder *b, nir_intrinsic_instr *intrin, lower_vs_inputs
|
||||
const struct ac_vtx_format_info *vtx_info =
|
||||
ac_get_vtx_format_info(s->gpu_info->gfx_level, s->gpu_info->family, attrib_format);
|
||||
const unsigned binding_index = s->info->vs.use_per_attribute_vb_descs ? location : attrib_binding;
|
||||
const unsigned desc_index = util_bitcount(s->info->vs.vb_desc_usage_mask & u_bit_consecutive(0, binding_index));
|
||||
const unsigned desc_index = util_bitcount(s->info->vs.vb_desc_usage_mask & BITFIELD_MASK(binding_index));
|
||||
|
||||
nir_def *vertex_buffers_arg = ac_nir_load_arg(b, &s->args->ac, s->args->ac.vertex_buffers);
|
||||
nir_def *vertex_buffers = nir_pack_64_2x32_split(b, vertex_buffers_arg, nir_imm_int(b, s->gpu_info->address32_hi));
|
||||
|
||||
@@ -219,7 +219,7 @@ radv_device_init_vs_prologs(struct radv_device *device)
|
||||
for (unsigned num_attributes = 1; num_attributes <= 16; num_attributes++) {
|
||||
for (unsigned count = 1; count <= num_attributes; count++) {
|
||||
for (unsigned start = 0; start <= (num_attributes - count); start++) {
|
||||
key.instance_rate_inputs = u_bit_consecutive(start, count);
|
||||
key.instance_rate_inputs = BITFIELD_RANGE(start, count);
|
||||
key.num_attributes = num_attributes;
|
||||
|
||||
struct radv_shader_part *prolog = radv_create_vs_prolog(device, &key);
|
||||
|
||||
@@ -206,7 +206,7 @@ gather_push_constant_info(const nir_shader *nir, const nir_intrinsic_instr *inst
|
||||
uint32_t size = instr->num_components * (instr->def.bit_size / 32u);
|
||||
|
||||
if (start + size <= (MAX_PUSH_CONSTANTS_SIZE / 4u)) {
|
||||
info->inline_push_constant_mask |= u_bit_consecutive64(start, size);
|
||||
info->inline_push_constant_mask |= BITFIELD64_RANGE(start, size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user