mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-29 16:51:20 +00:00
shader: simplify invariant execution masks in descriptor proofs
This commit is contained in:
1 parent
4e16234d32
commit
19799b3079
2 files changed
+36
-14
No files matched your search
@@ -1151,7 +1151,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HasActiveLane(Value mask, const Block* use) const {
|
bool HasActiveLane(Value mask, const Block* use) const {
|
||||||
mask = mask.Resolve();
|
mask = SimplifyGuard(mask);
|
||||||
if (mask.IsImmediate()) return mask.GetType() == Type::U1 && mask.U1();
|
if (mask.IsImmediate()) return mask.GetType() == Type::U1 && mask.U1();
|
||||||
const auto incoming_is_nonempty = [&](const Block* from, const Block* to,
|
const auto incoming_is_nonempty = [&](const Block* from, const Block* to,
|
||||||
Value incoming, const Block* header) {
|
Value incoming, const Block* header) {
|
||||||
@@ -1186,7 +1186,7 @@ private:
|
|||||||
|
|
||||||
bool Implies(Value guard, Value required) const {
|
bool Implies(Value guard, Value required) const {
|
||||||
guard = SimplifyGuard(guard);
|
guard = SimplifyGuard(guard);
|
||||||
required = required.Resolve();
|
required = SimplifyGuard(required);
|
||||||
if (required == Value(true) || EquivalentValue(m_program, guard, required)) return true;
|
if (required == Value(true) || EquivalentValue(m_program, guard, required)) return true;
|
||||||
const auto* test = required.TryInstruction();
|
const auto* test = required.TryInstruction();
|
||||||
if (test != nullptr && test->GetOpcode() == ValueOpcode::INotEqual32) {
|
if (test != nullptr && test->GetOpcode() == ValueOpcode::INotEqual32) {
|
||||||
|
|||||||
@@ -2562,10 +2562,12 @@ void TestCountedRowImageSelector() {
|
|||||||
KeyStride, CountImmediate, KeyImmediate, DifferentBackedgeBound,
|
KeyStride, CountImmediate, KeyImmediate, DifferentBackedgeBound,
|
||||||
Masked, EmptyCountMask, VaryingRow,
|
Masked, EmptyCountMask, VaryingRow,
|
||||||
EmptyMask, UnprovenMask, WrongMask, AnyBound, MaskedStepTwo, Spilled,
|
EmptyMask, UnprovenMask, WrongMask, AnyBound, MaskedStepTwo, Spilled,
|
||||||
MergedInitial, MissingBound, PreviousIteration };
|
MergedInitial, MissingBound, PreviousIteration,
|
||||||
|
InvariantMask, PossiblyEmptyMask };
|
||||||
const auto make_plan = [](Variant variant = Variant::Valid, uint32_t capacity = 16u) {
|
const auto make_plan = [](Variant variant = Variant::Valid, uint32_t capacity = 16u) {
|
||||||
Fixture fixture;
|
Fixture fixture;
|
||||||
const bool masked = variant >= Variant::Masked;
|
const bool masked = variant >= Variant::Masked;
|
||||||
|
const bool cyclic_mask = variant >= Variant::InvariantMask;
|
||||||
const bool stable_index = variant == Variant::DifferentBackedgeBound;
|
const bool stable_index = variant == Variant::DifferentBackedgeBound;
|
||||||
auto *entry = fixture.block;
|
auto *entry = fixture.block;
|
||||||
auto *header = fixture.AddBlock();
|
auto *header = fixture.AddBlock();
|
||||||
@@ -2606,17 +2608,35 @@ void TestCountedRowImageSelector() {
|
|||||||
"wave-uniform workgroup data escaped the host evaluation boundary");
|
"wave-uniform workgroup data escaped the host evaluation boundary");
|
||||||
if (variant == Variant::VaryingRow)
|
if (variant == Variant::VaryingRow)
|
||||||
row = fixture.Emit(ValueOpcode::IAdd32, {row, local});
|
row = fixture.Emit(ValueOpcode::IAdd32, {row, local});
|
||||||
active = fixture.Emit(ValueOpcode::INotEqual32, {local, Value(0u)});
|
if (cyclic_mask) {
|
||||||
entry->condition = fixture.Emit(ValueOpcode::ConditionRef, {active},
|
branch(entry, preheader);
|
||||||
CFG::BranchCondition::ExecNonZero);
|
auto &mask = header->AppendNewInst(ValueOpcode::Phi, {}, uint64_t(Type::U1));
|
||||||
if (variant == Variant::UnprovenMask) {
|
auto *restore = fixture.AddBlock();
|
||||||
entry->condition = fixture.Emit(ValueOpcode::INotEqual32,
|
body->AddBranch(restore);
|
||||||
{fixture.UserData(13u), Value(0u)});
|
body->condition = fixture.Emit(ValueOpcode::INotEqual32,
|
||||||
|
{fixture.UserData(13u), Value(0u)}, 0, body);
|
||||||
|
body->terminator = {.kind = CFG::TerminatorKind::ConditionalBranch,
|
||||||
|
.true_block = latch, .false_block = restore};
|
||||||
|
branch(restore, latch);
|
||||||
|
auto &next = latch->AppendNewInst(ValueOpcode::Phi, {}, uint64_t(Type::U1));
|
||||||
|
next.AddPhiOperand(body, Value(&mask));
|
||||||
|
next.AddPhiOperand(restore, Value(variant == Variant::InvariantMask));
|
||||||
|
mask.AddPhiOperand(preheader, Value(true));
|
||||||
|
mask.AddPhiOperand(latch, Value(&next));
|
||||||
|
active = Value(&mask);
|
||||||
|
} else {
|
||||||
|
active = fixture.Emit(ValueOpcode::INotEqual32, {local, Value(0u)});
|
||||||
|
entry->condition = fixture.Emit(ValueOpcode::ConditionRef, {active},
|
||||||
|
CFG::BranchCondition::ExecNonZero);
|
||||||
|
if (variant == Variant::UnprovenMask) {
|
||||||
|
entry->condition = fixture.Emit(ValueOpcode::INotEqual32,
|
||||||
|
{fixture.UserData(13u), Value(0u)});
|
||||||
|
}
|
||||||
|
entry->AddBranch(prepare);
|
||||||
|
entry->AddBranch(exit);
|
||||||
|
entry->terminator = {.kind = CFG::TerminatorKind::ConditionalBranch,
|
||||||
|
.true_block = prepare, .false_block = exit};
|
||||||
}
|
}
|
||||||
entry->AddBranch(prepare);
|
|
||||||
entry->AddBranch(exit);
|
|
||||||
entry->terminator = {.kind = CFG::TerminatorKind::ConditionalBranch,
|
|
||||||
.true_block = prepare, .false_block = exit};
|
|
||||||
if (variant == Variant::EmptyMask) active = Value(false);
|
if (variant == Variant::EmptyMask) active = Value(false);
|
||||||
}
|
}
|
||||||
Value initial(0u);
|
Value initial(0u);
|
||||||
@@ -2741,7 +2761,7 @@ void TestCountedRowImageSelector() {
|
|||||||
const bool valid = variant == Variant::Valid || variant == Variant::Masked || variant == Variant::Spilled ||
|
const bool valid = variant == Variant::Valid || variant == Variant::Masked || variant == Variant::Spilled ||
|
||||||
variant == Variant::EmptyCountMask || variant == Variant::MergedInitial ||
|
variant == Variant::EmptyCountMask || variant == Variant::MergedInitial ||
|
||||||
variant == Variant::StepTwo || variant == Variant::MaskedStepTwo ||
|
variant == Variant::StepTwo || variant == Variant::MaskedStepTwo ||
|
||||||
variant == Variant::SkippedIteration || stable_index;
|
variant == Variant::SkippedIteration || variant == Variant::InvariantMask || stable_index;
|
||||||
Check((selector && selector->rows.has_value()) == valid,
|
Check((selector && selector->rows.has_value()) == valid,
|
||||||
"counted-row selector lost its proof or accepted mismatched row/induction bounds");
|
"counted-row selector lost its proof or accepted mismatched row/induction bounds");
|
||||||
if (valid)
|
if (valid)
|
||||||
@@ -2761,6 +2781,8 @@ void TestCountedRowImageSelector() {
|
|||||||
make_plan(Variant::Spilled);
|
make_plan(Variant::Spilled);
|
||||||
make_plan(Variant::EmptyCountMask);
|
make_plan(Variant::EmptyCountMask);
|
||||||
make_plan(Variant::DifferentBackedgeBound);
|
make_plan(Variant::DifferentBackedgeBound);
|
||||||
|
make_plan(Variant::InvariantMask);
|
||||||
|
make_plan(Variant::PossiblyEmptyMask);
|
||||||
for (const auto variant : {Variant::Signed, Variant::StepTwo, Variant::SkippedIteration,
|
for (const auto variant : {Variant::Signed, Variant::StepTwo, Variant::SkippedIteration,
|
||||||
Variant::WrongRow, Variant::CountStride, Variant::KeyStride,
|
Variant::WrongRow, Variant::CountStride, Variant::KeyStride,
|
||||||
Variant::CountImmediate, Variant::KeyImmediate, Variant::VaryingRow,
|
Variant::CountImmediate, Variant::KeyImmediate, Variant::VaryingRow,
|
||||||
|
|||||||
Reference in new issue
Block a user