diff options
| author | 2021-02-24 18:32:00 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:22 -0400 | |
| commit | 622d676202bad317a58529efc3c15d08fd04aad1 (patch) | |
| tree | dbcca62c06661ac133ff46a13dccea7e7a1f7d75 /src/shader_recompiler/frontend/maxwell/control_flow.cpp | |
| parent | spirv: Add support for self-referencing phi nodes (diff) | |
| download | yuzu-622d676202bad317a58529efc3c15d08fd04aad1.tar.gz yuzu-622d676202bad317a58529efc3c15d08fd04aad1.tar.xz yuzu-622d676202bad317a58529efc3c15d08fd04aad1.zip | |
shader: Fix conditional execution of exit instructions
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/control_flow.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/control_flow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp index 52be41b84..d0dc66330 100644 --- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp | |||
| @@ -322,12 +322,13 @@ CFG::AnalysisState CFG::AnalyzeInst(Block* block, FunctionId function_id, Locati | |||
| 322 | return AnalysisState::Continue; | 322 | return AnalysisState::Continue; |
| 323 | } | 323 | } |
| 324 | const IR::Condition cond{static_cast<IR::Pred>(pred.index), pred.negated}; | 324 | const IR::Condition cond{static_cast<IR::Pred>(pred.index), pred.negated}; |
| 325 | AnalyzeCondInst(block, function_id, pc, EndClass::Branch, cond); | 325 | AnalyzeCondInst(block, function_id, pc, EndClass::Branch, cond, true); |
| 326 | return AnalysisState::Branch; | 326 | return AnalysisState::Branch; |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc, | 329 | void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc, |
| 330 | EndClass insn_end_class, IR::Condition cond) { | 330 | EndClass insn_end_class, IR::Condition cond, |
| 331 | bool visit_conditional_inst) { | ||
| 331 | if (block->begin != pc) { | 332 | if (block->begin != pc) { |
| 332 | // If the block doesn't start in the conditional instruction | 333 | // If the block doesn't start in the conditional instruction |
| 333 | // mark it as a label to visit it later | 334 | // mark it as a label to visit it later |
| @@ -354,7 +355,7 @@ void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc, | |||
| 354 | // Impersonate the visited block with a virtual block | 355 | // Impersonate the visited block with a virtual block |
| 355 | *block = std::move(virtual_block); | 356 | *block = std::move(virtual_block); |
| 356 | // Set the end properties of the conditional instruction | 357 | // Set the end properties of the conditional instruction |
| 357 | conditional_block->end = pc + 1; | 358 | conditional_block->end = visit_conditional_inst ? (pc + 1) : pc; |
| 358 | conditional_block->end_class = insn_end_class; | 359 | conditional_block->end_class = insn_end_class; |
| 359 | // Add a label to the instruction after the conditional instruction | 360 | // Add a label to the instruction after the conditional instruction |
| 360 | Block* const endif_block{AddLabel(conditional_block, block->stack, pc + 1, function_id)}; | 361 | Block* const endif_block{AddLabel(conditional_block, block->stack, pc + 1, function_id)}; |
| @@ -423,7 +424,7 @@ CFG::AnalysisState CFG::AnalyzeEXIT(Block* block, FunctionId function_id, Locati | |||
| 423 | throw NotImplementedException("Conditional EXIT with PEXIT token"); | 424 | throw NotImplementedException("Conditional EXIT with PEXIT token"); |
| 424 | } | 425 | } |
| 425 | const IR::Condition cond{flow_test, static_cast<IR::Pred>(pred.index), pred.negated}; | 426 | const IR::Condition cond{flow_test, static_cast<IR::Pred>(pred.index), pred.negated}; |
| 426 | AnalyzeCondInst(block, function_id, pc, EndClass::Exit, cond); | 427 | AnalyzeCondInst(block, function_id, pc, EndClass::Exit, cond, false); |
| 427 | return AnalysisState::Branch; | 428 | return AnalysisState::Branch; |
| 428 | } | 429 | } |
| 429 | if (const std::optional<Location> exit_pc{block->stack.Peek(Token::PEXIT)}) { | 430 | if (const std::optional<Location> exit_pc{block->stack.Peek(Token::PEXIT)}) { |