mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +01:00
pan/mdg: Avoid division in printing helpers
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5154>
This commit is contained in:
parent
4f5b3802dc
commit
2b9f6d30f8
3 changed files with 16 additions and 4 deletions
|
|
@ -498,6 +498,7 @@ uint16_t mir_bytemask(midgard_instruction *ins);
|
|||
uint16_t mir_round_bytemask_up(uint16_t mask, unsigned bits);
|
||||
void mir_set_bytemask(midgard_instruction *ins, uint16_t bytemask);
|
||||
signed mir_upper_override(midgard_instruction *ins, unsigned inst_size);
|
||||
unsigned mir_components_for_type(nir_alu_type T);
|
||||
|
||||
/* MIR printing */
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ mir_print_mask(unsigned mask)
|
|||
static void
|
||||
mir_print_swizzle(unsigned *swizzle, nir_alu_type T)
|
||||
{
|
||||
unsigned sz = nir_alu_type_get_type_size(T);
|
||||
unsigned comps = 128 / sz;
|
||||
unsigned comps = mir_components_for_type(T);
|
||||
|
||||
printf(".");
|
||||
|
||||
|
|
@ -230,7 +229,6 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
|
|||
static void
|
||||
mir_print_embedded_constant(midgard_instruction *ins, unsigned src_idx)
|
||||
{
|
||||
unsigned type_size = nir_alu_type_get_type_size(ins->dest_type);
|
||||
midgard_vector_alu_src src;
|
||||
|
||||
assert(src_idx <= 1);
|
||||
|
|
@ -242,7 +240,7 @@ mir_print_embedded_constant(midgard_instruction *ins, unsigned src_idx)
|
|||
unsigned *swizzle = ins->swizzle[src_idx];
|
||||
unsigned comp_mask = effective_writemask(&ins->alu, ins->mask);
|
||||
unsigned num_comp = util_bitcount(comp_mask);
|
||||
unsigned max_comp = 64 / type_size;
|
||||
unsigned max_comp = mir_components_for_type(ins->dest_type) >> 1;
|
||||
bool first = true;
|
||||
|
||||
printf("#");
|
||||
|
|
|
|||
|
|
@ -145,6 +145,19 @@ mir_nontrivial_outmod(midgard_instruction *ins)
|
|||
return mod != midgard_outmod_none;
|
||||
}
|
||||
|
||||
/* 128 / sz = exp2(log2(128 / sz))
|
||||
* = exp2(log2(128) - log2(sz))
|
||||
* = exp2(7 - log2(sz))
|
||||
* = 1 << (7 - log2(sz))
|
||||
*/
|
||||
|
||||
unsigned
|
||||
mir_components_for_type(nir_alu_type T)
|
||||
{
|
||||
unsigned sz = nir_alu_type_get_type_size(T);
|
||||
return 1 << (7 - util_logbase2(sz));
|
||||
}
|
||||
|
||||
uint16_t
|
||||
mir_from_bytemask(uint16_t bytemask, unsigned bits)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue