aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/maxwell/control_flow.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-02 01:17:47 -0300
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:25 -0400
commitb4a5e767d0a60d44c77460bd3a4062c5f69fb6c7 (patch)
treee365fabb301fba40c7a8e25b072ce59d15105e1d /src/shader_recompiler/frontend/maxwell/control_flow.cpp
parentd0a529683a2e5a693b53c6f24f6816c06f8f7e65 (diff)
shader: Fix branches to visited virtual blocks
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/control_flow.cpp')
-rw-r--r--src/shader_recompiler/frontend/maxwell/control_flow.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp
index 784f9df8a5..ac8707847f 100644
--- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp
+++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp
@@ -486,6 +486,16 @@ Block* CFG::AddLabel(Block* block, Stack stack, Location pc, FunctionId function
}
if (const auto it{function.blocks.find(pc, Compare{})}; it != function.blocks.end()) {
// Block already exists and it has been visited
+ if (function.blocks.begin() != it) {
+ // Check if the previous node is the virtual variant of the label
+ // This won't exist if a virtual node is not needed or it hasn't been visited
+ // If it hasn't been visited and a virtual node is needed, this will still behave as
+ // expected because the node impersonated with its virtual node.
+ const auto prev{std::prev(it)};
+ if (it->begin.Virtual() == prev->begin) {
+ return &*prev;
+ }
+ }
return &*it;
}
Block* const new_block{block_pool.Create(Block{