"Dump resulting callable shader after each successful lowering/optimization call" },
{ "print_ks", NIR_DEBUG_PRINT_KS,
"Dump resulting kernel shader after each successful lowering/optimization call" },
+ { "print_consts", NIR_DEBUG_PRINT_CONSTS,
+ "Print const value near each use of const SSA variable" },
{ NULL }
};
#define NIR_DEBUG_PRINT_IS (1u << 17)
#define NIR_DEBUG_PRINT_CBS (1u << 18)
#define NIR_DEBUG_PRINT_KS (1u << 19)
+#define NIR_DEBUG_PRINT_CONSTS (1u << 20)
#define NIR_DEBUG_PRINT (NIR_DEBUG_PRINT_VS | \
NIR_DEBUG_PRINT_TCS | \
}
static void
-print_load_const_instr(nir_load_const_instr *instr, print_state *state)
+print_const_from_load(nir_load_const_instr *instr, print_state *state)
{
FILE *fp = state->fp;
- print_ssa_def(&instr->def, 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.
*/
+ fprintf(fp, "(");
+
for (unsigned i = 0; i < instr->def.num_components; i++) {
if (i != 0)
fprintf(fp, ", ");
}
static void
+print_load_const_instr(nir_load_const_instr *instr, print_state *state)
+{
+ FILE *fp = state->fp;
+
+ print_ssa_def(&instr->def, state);
+
+ fprintf(fp, " = load_const ");
+
+ print_const_from_load(instr, state);
+}
+
+static void
print_ssa_use(nir_ssa_def *def, print_state *state)
{
FILE *fp = state->fp;
fprintf(fp, "ssa_%u", def->index);
+ nir_instr *instr = def->parent_instr;
+ if (instr->type == nir_instr_type_load_const && NIR_DEBUG(PRINT_CONSTS)) {
+ fprintf(fp, " /*");
+ print_const_from_load(nir_instr_as_load_const(instr), state);
+ fprintf(fp, "*/");
+ }
}
static void print_src(const nir_src *src, print_state *state);