recompiler: restored bfs in image instruction producers search
This commit is contained in:
parent
af3bbc33e9
commit
1de2ea960c
|
@ -253,15 +253,25 @@ IR::Value PatchCubeCoord(IR::IREmitter& ir, const IR::Value& s, const IR::Value&
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descriptors& descriptors) {
|
void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descriptors& descriptors) {
|
||||||
IR::Inst* producer = inst.Arg(0).InstRecursive();
|
std::deque<IR::Inst*> insts{&inst};
|
||||||
while (producer->GetOpcode() == IR::Opcode::Phi) {
|
const auto& pred = [](auto opcode) -> bool {
|
||||||
producer = producer->Arg(0).InstRecursive();
|
return (opcode == IR::Opcode::CompositeConstructU32x2 || // IMAGE_SAMPLE (image+sampler)
|
||||||
|
opcode == IR::Opcode::ReadConst || // IMAGE_LOAD (image only)
|
||||||
|
opcode == IR::Opcode::GetUserData);
|
||||||
|
};
|
||||||
|
|
||||||
|
IR::Inst* producer{};
|
||||||
|
while (!insts.empty() && (producer = insts.front(), !pred(producer->GetOpcode()))) {
|
||||||
|
for (auto arg_idx = 0u; arg_idx < producer->NumArgs(); ++arg_idx) {
|
||||||
|
const auto arg = producer->Arg(arg_idx);
|
||||||
|
if (arg.TryInstRecursive()) {
|
||||||
|
insts.push_back(arg.InstRecursive());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
insts.pop_front();
|
||||||
}
|
}
|
||||||
ASSERT(producer->GetOpcode() ==
|
ASSERT(pred(producer->GetOpcode()));
|
||||||
IR::Opcode::CompositeConstructU32x2 || // IMAGE_SAMPLE (image+sampler)
|
auto [tsharp_handle, ssharp_handle] = [&] -> std::pair<IR::Inst*, IR::Inst*> {
|
||||||
producer->GetOpcode() == IR::Opcode::ReadConst || // IMAGE_LOAD (image only)
|
|
||||||
producer->GetOpcode() == IR::Opcode::GetUserData);
|
|
||||||
const auto [tsharp_handle, ssharp_handle] = [&] -> std::pair<IR::Inst*, IR::Inst*> {
|
|
||||||
if (producer->GetOpcode() == IR::Opcode::CompositeConstructU32x2) {
|
if (producer->GetOpcode() == IR::Opcode::CompositeConstructU32x2) {
|
||||||
return std::make_pair(producer->Arg(0).InstRecursive(),
|
return std::make_pair(producer->Arg(0).InstRecursive(),
|
||||||
producer->Arg(1).InstRecursive());
|
producer->Arg(1).InstRecursive());
|
||||||
|
|
Loading…
Reference in New Issue