shader: switch canonicalization: fix ordering
Some checks are pending
Formatting check / formatting-check (push) Waiting to run
Build RPCSX / build-linux (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.1-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.2-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.4-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.5-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv9-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv9.1-a) (push) Waiting to run
Build RPCSX / build-android (x86_64, x86-64) (push) Waiting to run

This commit is contained in:
DH 2025-12-04 21:37:16 +03:00
parent 06f86132c3
commit a70fecb111

View file

@ -2,6 +2,7 @@
#include "SpvConverter.hpp"
#include "analyze.hpp"
#include "dialect.hpp"
#include <algorithm>
#include <list>
#include <rx/die.hpp>
@ -316,6 +317,7 @@ toCanonicalSwitchSelectionConstruct(spv::Context &context,
return;
}
{
std::vector<ir::Block> workList;
for (auto &[target, caseInfo] : cases) {
@ -345,32 +347,31 @@ toCanonicalSwitchSelectionConstruct(spv::Context &context,
}
}
}
}
std::list<ir::Block> sortedCases;
std::list<std::pair<ir::Block, ir::Block>> workList;
for (auto &[target, caseInfo] : cases) {
if (caseInfo.fallthroughBlock == nullptr) {
sortedCases.push_back(target);
} else {
workList.emplace_back(target, caseInfo.fallthroughBlock);
}
}
assert(!sortedCases.empty());
for (auto &[target, caseInfo] : cases) {
if (caseInfo.fallthroughBlock == nullptr) {
continue;
}
while (!workList.empty()) {
auto [block, fallthroughBlock] = workList.front();
workList.pop_front();
auto it = sortedCases.begin();
while (it != sortedCases.end()) {
if (caseInfo.fallthroughBlock == *it) {
break;
if (auto it = std::ranges::find(sortedCases, fallthroughBlock);
it != sortedCases.end()) {
sortedCases.insert(it, block);
} else {
workList.emplace_back(block, fallthroughBlock);
}
++it;
}
sortedCases.insert(it, target);
}
for (auto target : sortedCases) {