diff options
| author | 2021-05-18 02:04:22 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:32 -0400 | |
| commit | 9bb3e008c9f4bbdd35c095b506c3a3312d17e383 (patch) | |
| tree | 320cc594970b6ef658d8bed88ceabded0f84caea /src/shader_recompiler/backend | |
| parent | glasm: Implement InstanceId and VertexId (diff) | |
| download | yuzu-9bb3e008c9f4bbdd35c095b506c3a3312d17e383.tar.gz yuzu-9bb3e008c9f4bbdd35c095b506c3a3312d17e383.tar.xz yuzu-9bb3e008c9f4bbdd35c095b506c3a3312d17e383.zip | |
shader: Read branch conditions from an instruction
Fixes the identity removal pass.
Diffstat (limited to 'src/shader_recompiler/backend')
7 files changed, 20 insertions, 5 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp index d7a08e4b3..a893fa3fb 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp | |||
| @@ -200,7 +200,7 @@ void Precolor(EmitContext& ctx, const IR::Program& program) { | |||
| 200 | } | 200 | } |
| 201 | // Add reference to the phi node on the phi predecessor to avoid overwritting it | 201 | // Add reference to the phi node on the phi predecessor to avoid overwritting it |
| 202 | for (size_t i = 0; i < num_args; ++i) { | 202 | for (size_t i = 0; i < num_args; ++i) { |
| 203 | IR::IREmitter{*phi.PhiBlock(i)}.DummyReference(IR::Value{&phi}); | 203 | IR::IREmitter{*phi.PhiBlock(i)}.Reference(IR::Value{&phi}); |
| 204 | } | 204 | } |
| 205 | } | 205 | } |
| 206 | } | 206 | } |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp index cdbf6e93e..505378bfd 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp | |||
| @@ -22,6 +22,10 @@ void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) { | |||
| 22 | Alias(inst, value); | 22 | Alias(inst, value); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void EmitConditionRef(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 26 | Alias(inst, value); | ||
| 27 | } | ||
| 28 | |||
| 25 | void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) { | 29 | void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) { |
| 26 | Alias(inst, value); | 30 | Alias(inst, value); |
| 27 | } | 31 | } |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h index 54e7fab3c..df0933a3f 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h +++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h | |||
| @@ -22,7 +22,8 @@ class EmitContext; | |||
| 22 | void EmitPhi(EmitContext& ctx, IR::Inst& inst); | 22 | void EmitPhi(EmitContext& ctx, IR::Inst& inst); |
| 23 | void EmitVoid(EmitContext& ctx); | 23 | void EmitVoid(EmitContext& ctx); |
| 24 | void EmitIdentity(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); | 24 | void EmitIdentity(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); |
| 25 | void EmitDummyReference(EmitContext&); | 25 | void EmitConditionRef(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); |
| 26 | void EmitReference(EmitContext&); | ||
| 26 | void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value); | 27 | void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value); |
| 27 | void EmitJoin(EmitContext& ctx); | 28 | void EmitJoin(EmitContext& ctx); |
| 28 | void EmitDemoteToHelperInvocation(EmitContext& ctx); | 29 | void EmitDemoteToHelperInvocation(EmitContext& ctx); |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp index a4c1ca481..015cb5576 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp | |||
| @@ -21,7 +21,7 @@ void EmitPhi(EmitContext&, IR::Inst&) {} | |||
| 21 | 21 | ||
| 22 | void EmitVoid(EmitContext&) {} | 22 | void EmitVoid(EmitContext&) {} |
| 23 | 23 | ||
| 24 | void EmitDummyReference(EmitContext&) {} | 24 | void EmitReference(EmitContext&) {} |
| 25 | 25 | ||
| 26 | void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value) { | 26 | void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value) { |
| 27 | if (phi == value) { | 27 | if (phi == value) { |
diff --git a/src/shader_recompiler/backend/glasm/reg_alloc.cpp b/src/shader_recompiler/backend/glasm/reg_alloc.cpp index 707b22247..1a88331b4 100644 --- a/src/shader_recompiler/backend/glasm/reg_alloc.cpp +++ b/src/shader_recompiler/backend/glasm/reg_alloc.cpp | |||
| @@ -139,6 +139,7 @@ void RegAlloc::Free(Id id) { | |||
| 139 | /*static*/ bool RegAlloc::IsAliased(const IR::Inst& inst) { | 139 | /*static*/ bool RegAlloc::IsAliased(const IR::Inst& inst) { |
| 140 | switch (inst.GetOpcode()) { | 140 | switch (inst.GetOpcode()) { |
| 141 | case IR::Opcode::Identity: | 141 | case IR::Opcode::Identity: |
| 142 | case IR::Opcode::ConditionRef: | ||
| 142 | case IR::Opcode::BitCastU16F16: | 143 | case IR::Opcode::BitCastU16F16: |
| 143 | case IR::Opcode::BitCastU32F32: | 144 | case IR::Opcode::BitCastU32F32: |
| 144 | case IR::Opcode::BitCastU64F64: | 145 | case IR::Opcode::BitCastU64F64: |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 9ed2af991..3e20ac3b9 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -469,7 +469,15 @@ Id EmitIdentity(EmitContext& ctx, const IR::Value& value) { | |||
| 469 | return id; | 469 | return id; |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | void EmitDummyReference(EmitContext&) {} | 472 | Id EmitConditionRef(EmitContext& ctx, const IR::Value& value) { |
| 473 | const Id id{ctx.Def(value)}; | ||
| 474 | if (!Sirit::ValidId(id)) { | ||
| 475 | throw NotImplementedException("Forward identity declaration"); | ||
| 476 | } | ||
| 477 | return id; | ||
| 478 | } | ||
| 479 | |||
| 480 | void EmitReference(EmitContext&) {} | ||
| 473 | 481 | ||
| 474 | void EmitPhiMove(EmitContext&) { | 482 | void EmitPhiMove(EmitContext&) { |
| 475 | throw LogicError("Unreachable instruction"); | 483 | throw LogicError("Unreachable instruction"); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 22260d2a9..1181e7b4f 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -23,7 +23,8 @@ class EmitContext; | |||
| 23 | Id EmitPhi(EmitContext& ctx, IR::Inst* inst); | 23 | Id EmitPhi(EmitContext& ctx, IR::Inst* inst); |
| 24 | void EmitVoid(EmitContext& ctx); | 24 | void EmitVoid(EmitContext& ctx); |
| 25 | Id EmitIdentity(EmitContext& ctx, const IR::Value& value); | 25 | Id EmitIdentity(EmitContext& ctx, const IR::Value& value); |
| 26 | void EmitDummyReference(EmitContext&); | 26 | Id EmitConditionRef(EmitContext& ctx, const IR::Value& value); |
| 27 | void EmitReference(EmitContext&); | ||
| 27 | void EmitPhiMove(EmitContext&); | 28 | void EmitPhiMove(EmitContext&); |
| 28 | void EmitJoin(EmitContext& ctx); | 29 | void EmitJoin(EmitContext& ctx); |
| 29 | void EmitDemoteToHelperInvocation(EmitContext& ctx); | 30 | void EmitDemoteToHelperInvocation(EmitContext& ctx); |