mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 13:00:09 +01:00
nir/print: group hex and float vectors together
Vectors are much easier to follow in this format, because developer cares either about hex or float values, never both. Before/after: -vec4 32 ssa_222 = load_const (0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */, 0x3f800000 /* 1.000000 */) +vec4 32 ssa_222 = load_const (0x00000000, 0x00000000, 0x3f800000, 0x3f800000) = (0.000000, 0.000000, 1.000000, 1.000000) -vec1 32 ssa_174 = load_const (0xbf800000 /* -1.000000 */) +vec1 32 ssa_174 = load_const (0xbf800000 = -1.000000) Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
This commit is contained in:
parent
d2b4051ea9
commit
23f8f836e0
1 changed files with 35 additions and 11 deletions
|
|
@ -119,27 +119,25 @@ print_load_const_instr(nir_load_const_instr *instr, print_state *state)
|
|||
|
||||
fprintf(fp, " = load_const (");
|
||||
|
||||
/*
|
||||
* we don't really know the type of the constant (if it will be used as a
|
||||
* float or an int), so just print the raw constant in hex for fidelity
|
||||
* and then print in float again for readability.
|
||||
*/
|
||||
|
||||
for (unsigned i = 0; i < instr->def.num_components; i++) {
|
||||
if (i != 0)
|
||||
fprintf(fp, ", ");
|
||||
|
||||
/*
|
||||
* we don't really know the type of the constant (if it will be used as a
|
||||
* float or an int), so just print the raw constant in hex for fidelity
|
||||
* and then print the float in a comment for readability.
|
||||
*/
|
||||
|
||||
switch (instr->def.bit_size) {
|
||||
case 64:
|
||||
fprintf(fp, "0x%016" PRIx64 " /* %f */", instr->value[i].u64,
|
||||
instr->value[i].f64);
|
||||
fprintf(fp, "0x%016" PRIx64, instr->value[i].u64);
|
||||
break;
|
||||
case 32:
|
||||
fprintf(fp, "0x%08x /* %f */", instr->value[i].u32, instr->value[i].f32);
|
||||
fprintf(fp, "0x%08x", instr->value[i].u32);
|
||||
break;
|
||||
case 16:
|
||||
fprintf(fp, "0x%04x /* %f */", instr->value[i].u16,
|
||||
_mesa_half_to_float(instr->value[i].u16));
|
||||
fprintf(fp, "0x%04x", instr->value[i].u16);
|
||||
break;
|
||||
case 8:
|
||||
fprintf(fp, "0x%02x", instr->value[i].u8);
|
||||
|
|
@ -150,6 +148,32 @@ print_load_const_instr(nir_load_const_instr *instr, print_state *state)
|
|||
}
|
||||
}
|
||||
|
||||
if (instr->def.bit_size > 8) {
|
||||
if (instr->def.num_components > 1)
|
||||
fprintf(fp, ") = (");
|
||||
else
|
||||
fprintf(fp, " = ");
|
||||
|
||||
for (unsigned i = 0; i < instr->def.num_components; i++) {
|
||||
if (i != 0)
|
||||
fprintf(fp, ", ");
|
||||
|
||||
switch (instr->def.bit_size) {
|
||||
case 64:
|
||||
fprintf(fp, "%f", instr->value[i].f64);
|
||||
break;
|
||||
case 32:
|
||||
fprintf(fp, "%f", instr->value[i].f32);
|
||||
break;
|
||||
case 16:
|
||||
fprintf(fp, "%f", _mesa_half_to_float(instr->value[i].u16));
|
||||
break;
|
||||
default:
|
||||
unreachable("unhandled bit size");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fp, ")");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue