uint8_t counters; /* use counter_type notion */
bool wait_on_read:1;
bool logical:1;
+ bool has_vmem_nosampler:1;
+ bool has_vmem_sampler:1;
wait_entry(wait_event event, wait_imm imm, bool logical, bool wait_on_read)
: imm(imm), events(event), counters(get_counters_for_event(event)),
- wait_on_read(wait_on_read), logical(logical) {}
+ wait_on_read(wait_on_read), logical(logical),
+ has_vmem_nosampler(false), has_vmem_sampler(false) {}
bool join(const wait_entry& other)
{
bool changed = (other.events & ~events) ||
(other.counters & ~counters) ||
- (other.wait_on_read && !wait_on_read);
+ (other.wait_on_read && !wait_on_read) ||
+ (other.has_vmem_nosampler && !has_vmem_nosampler) ||
+ (other.has_vmem_sampler && !has_vmem_sampler);
events |= other.events;
counters |= other.counters;
changed |= imm.combine(other.imm);
- wait_on_read = wait_on_read || other.wait_on_read;
+ wait_on_read |= other.wait_on_read;
+ has_vmem_nosampler |= other.has_vmem_nosampler;
+ has_vmem_sampler |= other.has_vmem_sampler;
assert(logical == other.logical);
return changed;
}
if (counter == counter_vm) {
imm.vm = wait_imm::unset_counter;
events &= ~event_vmem;
+ has_vmem_nosampler = false;
+ has_vmem_sampler = false;
}
if (counter == counter_exp) {
continue;
/* Vector Memory reads and writes return in the order they were issued */
- if (instr->isVMEM() && ((it->second.events & vm_events) == event_vmem))
+ bool has_sampler = instr->format == Format::MIMG && !instr->operands[1].isUndefined() && instr->operands[1].regClass() == s4;
+ if (instr->isVMEM() && ((it->second.events & vm_events) == event_vmem) &&
+ it->second.has_vmem_nosampler == !has_sampler && it->second.has_vmem_sampler == has_sampler)
continue;
/* LDS reads and writes return in the order they were issued. same for GDS */
ctx.pending_flat_vm = true;
}
-void insert_wait_entry(wait_ctx& ctx, PhysReg reg, RegClass rc, wait_event event, bool wait_on_read)
+void insert_wait_entry(wait_ctx& ctx, PhysReg reg, RegClass rc, wait_event event, bool wait_on_read,
+ bool has_sampler=false)
{
uint16_t counters = get_counters_for_event(event);
wait_imm imm;
imm.vs = 0;
wait_entry new_entry(event, imm, !rc.is_linear(), wait_on_read);
+ new_entry.has_vmem_nosampler = (event & event_vmem) && !has_sampler;
+ new_entry.has_vmem_sampler = (event & event_vmem) && has_sampler;
for (unsigned i = 0; i < rc.size(); i++) {
auto it = ctx.gpr_map.emplace(PhysReg{reg.reg()+i}, new_entry);
}
}
-void insert_wait_entry(wait_ctx& ctx, Operand op, wait_event event)
+void insert_wait_entry(wait_ctx& ctx, Operand op, wait_event event, bool has_sampler=false)
{
if (!op.isConstant() && !op.isUndefined())
- insert_wait_entry(ctx, op.physReg(), op.regClass(), event, false);
+ insert_wait_entry(ctx, op.physReg(), op.regClass(), event, false, has_sampler);
}
-void insert_wait_entry(wait_ctx& ctx, Definition def, wait_event event)
+void insert_wait_entry(wait_ctx& ctx, Definition def, wait_event event, bool has_sampler=false)
{
- insert_wait_entry(ctx, def.physReg(), def.regClass(), event, true);
+ insert_wait_entry(ctx, def.physReg(), def.regClass(), event, true, has_sampler);
}
void gen(Instruction* instr, wait_ctx& ctx)
wait_event ev = !instr->definitions.empty() || ctx.chip_class < GFX10 ? event_vmem : event_vmem_store;
update_counters(ctx, ev, get_barrier_interaction(instr));
+ bool has_sampler = instr->format == Format::MIMG && !instr->operands[1].isUndefined() && instr->operands[1].regClass() == s4;
+
if (!instr->definitions.empty())
- insert_wait_entry(ctx, instr->definitions[0], ev);
+ insert_wait_entry(ctx, instr->definitions[0], ev, has_sampler);
if (ctx.chip_class == GFX6 &&
instr->format != Format::MIMG &&