diff options
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/attribute.cpp | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/attribute.h | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 14 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.h | 4 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 3 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.inc | 11 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/program.h | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/reg.h | 4 |
8 files changed, 34 insertions, 8 deletions
diff --git a/src/shader_recompiler/frontend/ir/attribute.cpp b/src/shader_recompiler/frontend/ir/attribute.cpp index 2fb7d576f..4811242ea 100644 --- a/src/shader_recompiler/frontend/ir/attribute.cpp +++ b/src/shader_recompiler/frontend/ir/attribute.cpp | |||
| @@ -13,7 +13,7 @@ bool IsGeneric(Attribute attribute) noexcept { | |||
| 13 | return attribute >= Attribute::Generic0X && attribute <= Attribute::Generic31X; | 13 | return attribute >= Attribute::Generic0X && attribute <= Attribute::Generic31X; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | int GenericAttributeIndex(Attribute attribute) { | 16 | u32 GenericAttributeIndex(Attribute attribute) { |
| 17 | if (!IsGeneric(attribute)) { | 17 | if (!IsGeneric(attribute)) { |
| 18 | throw InvalidArgument("Attribute is not generic {}", attribute); | 18 | throw InvalidArgument("Attribute is not generic {}", attribute); |
| 19 | } | 19 | } |
diff --git a/src/shader_recompiler/frontend/ir/attribute.h b/src/shader_recompiler/frontend/ir/attribute.h index bb2cad6af..34ec7e0cd 100644 --- a/src/shader_recompiler/frontend/ir/attribute.h +++ b/src/shader_recompiler/frontend/ir/attribute.h | |||
| @@ -224,7 +224,7 @@ enum class Attribute : u64 { | |||
| 224 | 224 | ||
| 225 | [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; | 225 | [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; |
| 226 | 226 | ||
| 227 | [[nodiscard]] int GenericAttributeIndex(Attribute attribute); | 227 | [[nodiscard]] u32 GenericAttributeIndex(Attribute attribute); |
| 228 | 228 | ||
| 229 | [[nodiscard]] std::string NameOf(Attribute attribute); | 229 | [[nodiscard]] std::string NameOf(Attribute attribute); |
| 230 | 230 | ||
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index 958282160..672836c0b 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -82,6 +82,12 @@ void IREmitter::Return() { | |||
| 82 | Inst(Opcode::Return); | 82 | Inst(Opcode::Return); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | void IREmitter::DemoteToHelperInvocation(Block* continue_label) { | ||
| 86 | block->SetBranch(continue_label); | ||
| 87 | continue_label->AddImmediatePredecessor(block); | ||
| 88 | Inst(Opcode::DemoteToHelperInvocation, continue_label); | ||
| 89 | } | ||
| 90 | |||
| 85 | U32 IREmitter::GetReg(IR::Reg reg) { | 91 | U32 IREmitter::GetReg(IR::Reg reg) { |
| 86 | return Inst<U32>(Opcode::GetRegister, reg); | 92 | return Inst<U32>(Opcode::GetRegister, reg); |
| 87 | } | 93 | } |
| @@ -248,6 +254,14 @@ void IREmitter::SetAttribute(IR::Attribute attribute, const F32& value) { | |||
| 248 | Inst(Opcode::SetAttribute, attribute, value); | 254 | Inst(Opcode::SetAttribute, attribute, value); |
| 249 | } | 255 | } |
| 250 | 256 | ||
| 257 | void IREmitter::SetFragColor(u32 index, u32 component, const F32& value) { | ||
| 258 | Inst(Opcode::SetFragColor, Imm32(index), Imm32(component), value); | ||
| 259 | } | ||
| 260 | |||
| 261 | void IREmitter::SetFragDepth(const F32& value) { | ||
| 262 | Inst(Opcode::SetFragDepth, value); | ||
| 263 | } | ||
| 264 | |||
| 251 | U32 IREmitter::WorkgroupIdX() { | 265 | U32 IREmitter::WorkgroupIdX() { |
| 252 | return U32{CompositeExtract(Inst(Opcode::WorkgroupId), 0)}; | 266 | return U32{CompositeExtract(Inst(Opcode::WorkgroupId), 0)}; |
| 253 | } | 267 | } |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 05263fe8b..72af5db37 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -36,6 +36,7 @@ public: | |||
| 36 | void LoopMerge(Block* merge_block, Block* continue_target); | 36 | void LoopMerge(Block* merge_block, Block* continue_target); |
| 37 | void SelectionMerge(Block* merge_block); | 37 | void SelectionMerge(Block* merge_block); |
| 38 | void Return(); | 38 | void Return(); |
| 39 | void DemoteToHelperInvocation(Block* continue_label); | ||
| 39 | 40 | ||
| 40 | [[nodiscard]] U32 GetReg(IR::Reg reg); | 41 | [[nodiscard]] U32 GetReg(IR::Reg reg); |
| 41 | void SetReg(IR::Reg reg, const U32& value); | 42 | void SetReg(IR::Reg reg, const U32& value); |
| @@ -67,6 +68,9 @@ public: | |||
| 67 | [[nodiscard]] F32 GetAttribute(IR::Attribute attribute); | 68 | [[nodiscard]] F32 GetAttribute(IR::Attribute attribute); |
| 68 | void SetAttribute(IR::Attribute attribute, const F32& value); | 69 | void SetAttribute(IR::Attribute attribute, const F32& value); |
| 69 | 70 | ||
| 71 | void SetFragColor(u32 index, u32 component, const F32& value); | ||
| 72 | void SetFragDepth(const F32& value); | ||
| 73 | |||
| 70 | [[nodiscard]] U32 WorkgroupIdX(); | 74 | [[nodiscard]] U32 WorkgroupIdX(); |
| 71 | [[nodiscard]] U32 WorkgroupIdY(); | 75 | [[nodiscard]] U32 WorkgroupIdY(); |
| 72 | [[nodiscard]] U32 WorkgroupIdZ(); | 76 | [[nodiscard]] U32 WorkgroupIdZ(); |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 5946105d2..21b7d8a9f 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -55,8 +55,11 @@ bool Inst::MayHaveSideEffects() const noexcept { | |||
| 55 | case Opcode::LoopMerge: | 55 | case Opcode::LoopMerge: |
| 56 | case Opcode::SelectionMerge: | 56 | case Opcode::SelectionMerge: |
| 57 | case Opcode::Return: | 57 | case Opcode::Return: |
| 58 | case Opcode::DemoteToHelperInvocation: | ||
| 58 | case Opcode::SetAttribute: | 59 | case Opcode::SetAttribute: |
| 59 | case Opcode::SetAttributeIndexed: | 60 | case Opcode::SetAttributeIndexed: |
| 61 | case Opcode::SetFragColor: | ||
| 62 | case Opcode::SetFragDepth: | ||
| 60 | case Opcode::WriteGlobalU8: | 63 | case Opcode::WriteGlobalU8: |
| 61 | case Opcode::WriteGlobalS8: | 64 | case Opcode::WriteGlobalS8: |
| 62 | case Opcode::WriteGlobalU16: | 65 | case Opcode::WriteGlobalU16: |
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index 9052a4903..593faca52 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -13,6 +13,7 @@ OPCODE(BranchConditional, Void, U1, | |||
| 13 | OPCODE(LoopMerge, Void, Label, Label, ) | 13 | OPCODE(LoopMerge, Void, Label, Label, ) |
| 14 | OPCODE(SelectionMerge, Void, Label, ) | 14 | OPCODE(SelectionMerge, Void, Label, ) |
| 15 | OPCODE(Return, Void, ) | 15 | OPCODE(Return, Void, ) |
| 16 | OPCODE(DemoteToHelperInvocation, Void, Label, ) | ||
| 16 | 17 | ||
| 17 | // Context getters/setters | 18 | // Context getters/setters |
| 18 | OPCODE(GetRegister, U32, Reg, ) | 19 | OPCODE(GetRegister, U32, Reg, ) |
| @@ -28,10 +29,12 @@ OPCODE(GetCbufS16, U32, U32, | |||
| 28 | OPCODE(GetCbufU32, U32, U32, U32, ) | 29 | OPCODE(GetCbufU32, U32, U32, U32, ) |
| 29 | OPCODE(GetCbufF32, F32, U32, U32, ) | 30 | OPCODE(GetCbufF32, F32, U32, U32, ) |
| 30 | OPCODE(GetCbufU64, U64, U32, U32, ) | 31 | OPCODE(GetCbufU64, U64, U32, U32, ) |
| 31 | OPCODE(GetAttribute, U32, Attribute, ) | 32 | OPCODE(GetAttribute, F32, Attribute, ) |
| 32 | OPCODE(SetAttribute, Void, Attribute, U32, ) | 33 | OPCODE(SetAttribute, Void, Attribute, F32, ) |
| 33 | OPCODE(GetAttributeIndexed, U32, U32, ) | 34 | OPCODE(GetAttributeIndexed, F32, U32, ) |
| 34 | OPCODE(SetAttributeIndexed, Void, U32, U32, ) | 35 | OPCODE(SetAttributeIndexed, Void, U32, F32, ) |
| 36 | OPCODE(SetFragColor, Void, U32, U32, F32, ) | ||
| 37 | OPCODE(SetFragDepth, Void, F32, ) | ||
| 35 | OPCODE(GetZFlag, U1, Void, ) | 38 | OPCODE(GetZFlag, U1, Void, ) |
| 36 | OPCODE(GetSFlag, U1, Void, ) | 39 | OPCODE(GetSFlag, U1, Void, ) |
| 37 | OPCODE(GetCFlag, U1, Void, ) | 40 | OPCODE(GetCFlag, U1, Void, ) |
diff --git a/src/shader_recompiler/frontend/ir/program.h b/src/shader_recompiler/frontend/ir/program.h index bce8b19b3..733513c8b 100644 --- a/src/shader_recompiler/frontend/ir/program.h +++ b/src/shader_recompiler/frontend/ir/program.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "shader_recompiler/frontend/ir/basic_block.h" | 11 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 12 | #include "shader_recompiler/shader_info.h" | 12 | #include "shader_recompiler/shader_info.h" |
| 13 | #include "shader_recompiler/stage.h" | ||
| 13 | 14 | ||
| 14 | namespace Shader::IR { | 15 | namespace Shader::IR { |
| 15 | 16 | ||
| @@ -17,6 +18,7 @@ struct Program { | |||
| 17 | BlockList blocks; | 18 | BlockList blocks; |
| 18 | BlockList post_order_blocks; | 19 | BlockList post_order_blocks; |
| 19 | Info info; | 20 | Info info; |
| 21 | Stage stage{}; | ||
| 20 | }; | 22 | }; |
| 21 | 23 | ||
| 22 | [[nodiscard]] std::string DumpProgram(const Program& program); | 24 | [[nodiscard]] std::string DumpProgram(const Program& program); |
diff --git a/src/shader_recompiler/frontend/ir/reg.h b/src/shader_recompiler/frontend/ir/reg.h index 8fea05f7b..3845ec5fb 100644 --- a/src/shader_recompiler/frontend/ir/reg.h +++ b/src/shader_recompiler/frontend/ir/reg.h | |||
| @@ -293,12 +293,12 @@ constexpr size_t NUM_REGS = 256; | |||
| 293 | return reg + (-num); | 293 | return reg + (-num); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | [[nodiscard]] constexpr Reg operator++(Reg& reg) { | 296 | constexpr Reg operator++(Reg& reg) { |
| 297 | reg = reg + 1; | 297 | reg = reg + 1; |
| 298 | return reg; | 298 | return reg; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | [[nodiscard]] constexpr Reg operator++(Reg& reg, int) { | 301 | constexpr Reg operator++(Reg& reg, int) { |
| 302 | const Reg copy{reg}; | 302 | const Reg copy{reg}; |
| 303 | reg = reg + 1; | 303 | reg = reg + 1; |
| 304 | return copy; | 304 | return copy; |