diff options
| author | 2021-02-24 18:31:32 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:22 -0400 | |
| commit | 7496bbf7584049fb9c99cf705e9cc16aee61a55a (patch) | |
| tree | 8aeb8a37fa2efda20e05238041c1d54dae073949 /src/shader_recompiler | |
| parent | shader: Fix control flow (diff) | |
| download | yuzu-7496bbf7584049fb9c99cf705e9cc16aee61a55a.tar.gz yuzu-7496bbf7584049fb9c99cf705e9cc16aee61a55a.tar.xz yuzu-7496bbf7584049fb9c99cf705e9cc16aee61a55a.zip | |
spirv: Add support for self-referencing phi nodes
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index f3aca90d0..bcd6bda28 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -217,9 +217,16 @@ Id EmitPhi(EmitContext& ctx, IR::Inst* inst) { | |||
| 217 | IR::Inst* const arg_inst{arg.Inst()}; | 217 | IR::Inst* const arg_inst{arg.Inst()}; |
| 218 | def = arg_inst->Definition<Id>(); | 218 | def = arg_inst->Definition<Id>(); |
| 219 | if (!Sirit::ValidId(def)) { | 219 | if (!Sirit::ValidId(def)) { |
| 220 | // If it hasn't been defined, get a forward declaration | 220 | if (arg_inst == inst) { |
| 221 | def = ctx.ForwardDeclarationId(); | 221 | // This is a self referencing phi node |
| 222 | arg_inst->SetDefinition<Id>(def); | 222 | def = ctx.CurrentId(); |
| 223 | // Self-referencing definition will be set by the caller | ||
| 224 | } else { | ||
| 225 | // If it hasn't been defined and it's not a self reference, | ||
| 226 | // get a forward declaration | ||
| 227 | def = ctx.ForwardDeclarationId(); | ||
| 228 | arg_inst->SetDefinition<Id>(def); | ||
| 229 | } | ||
| 223 | } | 230 | } |
| 224 | } | 231 | } |
| 225 | IR::Block* const phi_block{inst->PhiBlock(index)}; | 232 | IR::Block* const phi_block{inst->PhiBlock(index)}; |