From 194579bc4f409ba9a232afc54f19d0610102954e Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 1 Nov 2021 22:26:17 +0100 Subject: ShaderCache: Fix Phi Nodes Type on OGL. --- src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp') diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index 5545f8197..87aa09358 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp @@ -14,6 +14,7 @@ // https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6 // +#include #include #include #include @@ -370,6 +371,26 @@ void VisitBlock(Pass& pass, IR::Block* block) { } pass.SealBlock(block); } + +IR::Type GetConcreteType(IR::Inst* inst) { + std::deque queue; + queue.push_back(inst); + while (!queue.empty()) { + IR::Inst* current = queue.front(); + queue.pop_front(); + const size_t num_args{current->NumArgs()}; + for (size_t i = 0; i < num_args; ++i) { + const auto set_type = current->Arg(i).Type(); + if (set_type != IR::Type::Opaque) { + return set_type; + } + if (!current->Arg(i).IsImmediate()) { + queue.push_back(current->Arg(i).Inst()); + } + } + } + return IR::Type::Opaque; +} } // Anonymous namespace void SsaRewritePass(IR::Program& program) { @@ -381,6 +402,9 @@ void SsaRewritePass(IR::Program& program) { for (auto block = program.post_order_blocks.rbegin(); block != end; ++block) { for (IR::Inst& inst : (*block)->Instructions()) { if (inst.GetOpcode() == IR::Opcode::Phi) { + if (inst.Type() == IR::Type::Opaque) { + inst.SetFlags(GetConcreteType(&inst)); + } inst.OrderPhiArgs(); } } -- cgit v1.2.3