mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 15:48:36 +02:00
pan/midgard: Switch constants to uint32
Storing constants as float doesn't make sense when we have integer instructions; better to switch to be integer natively and coerce to/from float rather than the opposite. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
2e1be771e4
commit
0acb5c1774
3 changed files with 17 additions and 10 deletions
|
|
@ -109,7 +109,7 @@ typedef struct midgard_instruction {
|
|||
bool precede_break;
|
||||
|
||||
bool has_constants;
|
||||
float constants[4];
|
||||
uint32_t constants[4];
|
||||
uint16_t inline_constant;
|
||||
bool has_blend_constant;
|
||||
|
||||
|
|
|
|||
|
|
@ -1096,11 +1096,10 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
|
|||
ins.has_constants = true;
|
||||
|
||||
if (instr->op == nir_op_b2f32) {
|
||||
ins.constants[0] = 1.0f;
|
||||
float f = 1.0f;
|
||||
memcpy(&ins.constants, &f, sizeof(float));
|
||||
} else {
|
||||
/* Type pun it into place */
|
||||
uint32_t one = 0x1;
|
||||
memcpy(&ins.constants[0], &one, sizeof(uint32_t));
|
||||
ins.constants[0] = 1;
|
||||
}
|
||||
|
||||
ins.alu.src2 = vector_alu_srco_unsigned(blank_alu_src_xxxx);
|
||||
|
|
@ -1109,7 +1108,7 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
|
|||
ins.ssa_args.inline_constant = false;
|
||||
ins.ssa_args.src[1] = SSA_FIXED_REGISTER(REGISTER_CONSTANT);
|
||||
ins.has_constants = true;
|
||||
ins.constants[0] = 0.0f;
|
||||
ins.constants[0] = 0;
|
||||
ins.alu.src2 = vector_alu_srco_unsigned(blank_alu_src_xxxx);
|
||||
} else if (instr->op == nir_op_inot) {
|
||||
ins.invert = true;
|
||||
|
|
@ -2108,7 +2107,8 @@ embedded_to_inline_constant(compiler_context *ctx)
|
|||
if (scaled_constant != iconstants[component])
|
||||
continue;
|
||||
} else {
|
||||
float original = (float) ins->constants[component];
|
||||
float *f = (float *) ins->constants;
|
||||
float original = f[component];
|
||||
scaled_constant = _mesa_float_to_half(original);
|
||||
|
||||
/* Check for loss of precision. If this is
|
||||
|
|
@ -2135,7 +2135,7 @@ embedded_to_inline_constant(compiler_context *ctx)
|
|||
* vector by checking if all accessed values
|
||||
* (by the swizzle) are the same. */
|
||||
|
||||
uint32_t *cons = (uint32_t *) ins->constants;
|
||||
uint32_t *cons = ins->constants;
|
||||
uint32_t value = cons[component];
|
||||
|
||||
bool is_vector = false;
|
||||
|
|
|
|||
|
|
@ -148,8 +148,15 @@ mir_print_instruction(midgard_instruction *ins)
|
|||
printf(", ");
|
||||
mir_print_index(args->src[2]);
|
||||
|
||||
if (ins->has_constants)
|
||||
printf(" <%f, %f, %f, %f>", ins->constants[0], ins->constants[1], ins->constants[2], ins->constants[3]);
|
||||
if (ins->has_constants) {
|
||||
uint32_t *uc = ins->constants;
|
||||
float *fc = (float *) uc;
|
||||
|
||||
if (midgard_is_integer_op(ins->alu.op))
|
||||
printf(" <0x%X, 0x%X, 0x%X, 0x%x>", uc[0], uc[1], uc[2], uc[3]);
|
||||
else
|
||||
printf(" <%f, %f, %f, %f>", fc[0], fc[1], fc[2], fc[3]);
|
||||
}
|
||||
|
||||
if (ins->no_spill)
|
||||
printf(" /* no spill */");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue