#include "ir3_compiler.h"
static const struct debug_named_value shader_debug_options[] = {
- {"vs", IR3_DBG_SHADER_VS, "Print shader disasm for vertex shaders"},
- {"fs", IR3_DBG_SHADER_FS, "Print shader disasm for fragment shaders"},
- {"cs", IR3_DBG_SHADER_CS, "Print shader disasm for compute shaders"},
- {"disasm", IR3_DBG_DISASM, "Dump NIR and adreno shader disassembly"},
- {"optmsgs", IR3_DBG_OPTMSGS,"Enable optimizer debug messages"},
- DEBUG_NAMED_VALUE_END
+ {"vs", IR3_DBG_SHADER_VS, "Print shader disasm for vertex shaders"},
+ {"fs", IR3_DBG_SHADER_FS, "Print shader disasm for fragment shaders"},
+ {"cs", IR3_DBG_SHADER_CS, "Print shader disasm for compute shaders"},
+ {"disasm", IR3_DBG_DISASM, "Dump NIR and adreno shader disassembly"},
+ {"optmsgs", IR3_DBG_OPTMSGS, "Enable optimizer debug messages"},
+ {"forces2en", IR3_DBG_FORCES2EN, "Force s2en mode for tex sampler instructions"},
+ DEBUG_NAMED_VALUE_END
};
DEBUG_GET_ONCE_FLAGS_OPTION(ir3_shader_debug, "IR3_SHADER_DEBUG", shader_debug_options, 0)
break;
}
}
+
+ /* Handle converting a sam.s2en (taking samp/tex idx params via
+ * register) into a normal sam (encoding immediate samp/tex idx)
+ * if they are immediate. This saves some instructions and regs
+ * in the common case where we know samp/tex at compile time:
+ */
+ if (is_tex(instr) && (instr->flags & IR3_INSTR_S2EN) &&
+ !(ir3_shader_debug & IR3_DBG_FORCES2EN)) {
+ /* The first src will be a fan-in (collect), if both of it's
+ * two sources are mov from imm, then we can
+ */
+ struct ir3_instruction *samp_tex = ssa(instr->regs[1]);
+
+ debug_assert(samp_tex->opc == OPC_META_FI);
+
+ struct ir3_instruction *samp = ssa(samp_tex->regs[1]);
+ struct ir3_instruction *tex = ssa(samp_tex->regs[2]);
+
+ if ((samp->opc == OPC_MOV) &&
+ (samp->regs[1]->flags & IR3_REG_IMMED) &&
+ (tex->opc == OPC_MOV) &&
+ (tex->regs[1]->flags & IR3_REG_IMMED)) {
+ instr->flags &= ~IR3_INSTR_S2EN;
+ instr->cat5.samp = samp->regs[1]->iim_val;
+ instr->cat5.tex = tex->regs[1]->iim_val;
+ instr->regs[1]->instr = NULL;
+ }
+ }
}
void