switch (inst->dst.file) {
case QFILE_TLBU:
return true;
+ case QFILE_MAGIC:
+ switch (inst->dst.index) {
+ case V3D_QPU_WADDR_TLBU:
+ case V3D_QPU_WADDR_TMUAU:
+ case V3D_QPU_WADDR_SYNCU:
+ return true;
+ default:
+ break;
+ }
+ break;
default:
return inst->has_implicit_uniform;
}
return false;
}
-bool
-vir_is_float_input(struct qinst *inst)
-{
- /* XXX: More instrs */
- switch (inst->qpu.type) {
- case V3D_QPU_INSTR_TYPE_BRANCH:
- return false;
- case V3D_QPU_INSTR_TYPE_ALU:
- switch (inst->qpu.alu.add.op) {
- case V3D_QPU_A_FADD:
- case V3D_QPU_A_FSUB:
- case V3D_QPU_A_FMIN:
- case V3D_QPU_A_FMAX:
- case V3D_QPU_A_FTOIN:
- return true;
- default:
- break;
- }
-
- switch (inst->qpu.alu.mul.op) {
- case V3D_QPU_M_FMOV:
- case V3D_QPU_M_VFMUL:
- case V3D_QPU_M_FMUL:
- return true;
- default:
- break;
- }
- }
-
- return false;
-}
-
bool
vir_is_raw_mov(struct qinst *inst)
{
inst->qpu.branch.ub = true;
inst->qpu.branch.bdu = V3D_QPU_BRANCH_DEST_REL;
- inst->dst = vir_reg(QFILE_NULL, 0);
+ inst->dst = vir_nop_reg();
inst->src[0] = src;
inst->uniform = ~0;
{
struct nir_lower_tex_options tex_options = {
.lower_txd = true,
+ .lower_tg4_broadcom_swizzle = true,
+
.lower_rect = false, /* XXX: Use this on V3D 3.x */
.lower_txp = ~0,
/* Apply swizzles to all samplers. */
tex_options.saturate_t |= 1 << i;
if (c->key->tex[i].clamp_r)
tex_options.saturate_r |= 1 << i;
+ if (c->key->tex[i].return_size == 16) {
+ tex_options.lower_tex_packing[i] =
+ nir_lower_tex_packing_16;
+ }
}
NIR_PASS_V(c->s, nir_lower_tex, &tex_options);
+ NIR_PASS_V(c->s, nir_lower_system_values);
}
static void
struct v3d_fs_prog_data *prog_data)
{
v3d_set_fs_prog_data_inputs(c, prog_data);
- prog_data->writes_z = (c->s->info.outputs_written &
- (1 << FRAG_RESULT_DEPTH));
- prog_data->discard = (c->s->info.fs.uses_discard ||
- c->fs_key->sample_alpha_to_coverage);
+ prog_data->writes_z = c->writes_z;
+ prog_data->disable_ez = !c->s->info.fs.early_fragment_tests;
prog_data->uses_center_w = c->uses_center_w;
}
{
if (c->fs_key->int_color_rb || c->fs_key->uint_color_rb)
v3d_fixup_fs_output_types(c);
+
+ /* If the shader has no non-TLB side effects, we can promote it to
+ * enabling early_fragment_tests even if the user didn't.
+ */
+ if (!(c->s->info.num_images ||
+ c->s->info.num_ssbos ||
+ c->s->info.num_abos)) {
+ c->s->info.fs.early_fragment_tests = true;
+ }
}
static void
NIR_PASS_V(c->s, v3d_nir_lower_io, c);
NIR_PASS_V(c->s, v3d_nir_lower_txf_ms, c);
+ NIR_PASS_V(c->s, v3d_nir_lower_image_load_store);
NIR_PASS_V(c->s, nir_lower_idiv);
v3d_optimize_nir(c->s);
return vir_reg(QFILE_UNIF, uniform);
}
-static bool
-vir_can_set_flags(struct v3d_compile *c, struct qinst *inst)
-{
- if (c->devinfo->ver >= 40 && (v3d_qpu_reads_vpm(&inst->qpu) ||
- v3d_qpu_uses_sfu(&inst->qpu))) {
- return false;
- }
-
- if (inst->qpu.type != V3D_QPU_INSTR_TYPE_ALU ||
- (inst->qpu.alu.add.op == V3D_QPU_A_NOP &&
- inst->qpu.alu.mul.op == V3D_QPU_M_NOP)) {
- return false;
- }
-
- return true;
-}
-
-void
-vir_PF(struct v3d_compile *c, struct qreg src, enum v3d_qpu_pf pf)
-{
- struct qinst *last_inst = NULL;
-
- if (!list_empty(&c->cur_block->instructions)) {
- last_inst = (struct qinst *)c->cur_block->instructions.prev;
-
- /* Can't stuff the PF into the last last inst if our cursor
- * isn't pointing after it.
- */
- struct vir_cursor after_inst = vir_after_inst(last_inst);
- if (c->cursor.mode != after_inst.mode ||
- c->cursor.link != after_inst.link)
- last_inst = NULL;
- }
-
- if (src.file != QFILE_TEMP ||
- !c->defs[src.index] ||
- last_inst != c->defs[src.index] ||
- !vir_can_set_flags(c, last_inst)) {
- /* XXX: Make the MOV be the appropriate type */
- last_inst = vir_MOV_dest(c, vir_reg(QFILE_NULL, 0), src);
- }
-
- vir_set_pf(last_inst, pf);
-}
-
#define OPTPASS(func) \
do { \
bool stage_progress = func(c); \