Skip to content

Commit

Permalink
shader_recompiler: Ignore exec mask for scalar instructions. (shadps4…
Browse files Browse the repository at this point in the history
  • Loading branch information
squidbus authored Jan 8, 2025
1 parent 0eee36c commit 65f9bbb
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/shader_recompiler/frontend/control_flow_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,26 @@ static IR::Condition MakeCondition(const GcnInst& inst) {
}
}

static bool IgnoresExecMask(Opcode opcode) {
switch (opcode) {
static bool IgnoresExecMask(const GcnInst& inst) {
// EXEC mask does not affect scalar instructions or branches.
switch (inst.category) {
case InstCategory::ScalarALU:
case InstCategory::ScalarMemory:
case InstCategory::FlowControl:
return true;
default:
break;
}
// Read/Write Lane instructions are not affected either.
switch (inst.opcode) {
case Opcode::V_READLANE_B32:
case Opcode::V_WRITELANE_B32:
case Opcode::V_READFIRSTLANE_B32:
return true;
default:
return false;
break;
}
return false;
}

static constexpr size_t LabelReserveSize = 32;
Expand Down Expand Up @@ -147,8 +160,7 @@ void CFG::EmitDivergenceLabels() {
// If all instructions in the scope ignore exec masking, we shouldn't insert a
// scope.
const auto start = inst_list.begin() + curr_begin + 1;
if (!std::ranges::all_of(start, inst_list.begin() + index, IgnoresExecMask,
&GcnInst::opcode)) {
if (!std::ranges::all_of(start, inst_list.begin() + index, IgnoresExecMask)) {
// Add a label to the instruction right after the open scope call.
// It is the start of a new basic block.
const auto& save_inst = inst_list[curr_begin];
Expand Down

0 comments on commit 65f9bbb

Please sign in to comment.