diff options
| author | 2021-03-26 16:46:07 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | d9c5bd9509e82fcde72c18663989931f97ed6518 (patch) | |
| tree | d6575e66d66a8abc8ee8776c1c2536c052424787 /src/shader_recompiler/frontend/ir | |
| parent | shader: Add IR opcode for ImageFetch (diff) | |
| download | yuzu-d9c5bd9509e82fcde72c18663989931f97ed6518.tar.gz yuzu-d9c5bd9509e82fcde72c18663989931f97ed6518.tar.xz yuzu-d9c5bd9509e82fcde72c18663989931f97ed6518.zip | |
shader: Refactor PTP and other minor changes
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 12 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.h | 4 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/modifiers.h | 5 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.inc | 1 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.cpp | 14 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.h | 1 |
6 files changed, 6 insertions, 31 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index b8d36f362..0296f8773 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -398,16 +398,15 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2) { | |||
| 398 | if (e1.Type() != e2.Type()) { | 398 | if (e1.Type() != e2.Type()) { |
| 399 | throw InvalidArgument("Mismatching types {} and {}", e1.Type(), e2.Type()); | 399 | throw InvalidArgument("Mismatching types {} and {}", e1.Type(), e2.Type()); |
| 400 | } | 400 | } |
| 401 | CompositeDecoration decor{}; | ||
| 402 | switch (e1.Type()) { | 401 | switch (e1.Type()) { |
| 403 | case Type::U32: | 402 | case Type::U32: |
| 404 | return Inst(Opcode::CompositeConstructU32x2, Flags{decor}, e1, e2); | 403 | return Inst(Opcode::CompositeConstructU32x2, e1, e2); |
| 405 | case Type::F16: | 404 | case Type::F16: |
| 406 | return Inst(Opcode::CompositeConstructF16x2, Flags{decor}, e1, e2); | 405 | return Inst(Opcode::CompositeConstructF16x2, e1, e2); |
| 407 | case Type::F32: | 406 | case Type::F32: |
| 408 | return Inst(Opcode::CompositeConstructF32x2, Flags{decor}, e1, e2); | 407 | return Inst(Opcode::CompositeConstructF32x2, e1, e2); |
| 409 | case Type::F64: | 408 | case Type::F64: |
| 410 | return Inst(Opcode::CompositeConstructF64x2, Flags{decor}, e1, e2); | 409 | return Inst(Opcode::CompositeConstructF64x2, e1, e2); |
| 411 | default: | 410 | default: |
| 412 | ThrowInvalidType(e1.Type()); | 411 | ThrowInvalidType(e1.Type()); |
| 413 | } | 412 | } |
| @@ -437,7 +436,6 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2, const Valu | |||
| 437 | throw InvalidArgument("Mismatching types {}, {}, {}, and {}", e1.Type(), e2.Type(), | 436 | throw InvalidArgument("Mismatching types {}, {}, {}, and {}", e1.Type(), e2.Type(), |
| 438 | e3.Type(), e4.Type()); | 437 | e3.Type(), e4.Type()); |
| 439 | } | 438 | } |
| 440 | CompositeDecoration decor{}; | ||
| 441 | switch (e1.Type()) { | 439 | switch (e1.Type()) { |
| 442 | case Type::U32: | 440 | case Type::U32: |
| 443 | return Inst(Opcode::CompositeConstructU32x4, e1, e2, e3, e4); | 441 | return Inst(Opcode::CompositeConstructU32x4, e1, e2, e3, e4); |
| @@ -447,8 +445,6 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2, const Valu | |||
| 447 | return Inst(Opcode::CompositeConstructF32x4, e1, e2, e3, e4); | 445 | return Inst(Opcode::CompositeConstructF32x4, e1, e2, e3, e4); |
| 448 | case Type::F64: | 446 | case Type::F64: |
| 449 | return Inst(Opcode::CompositeConstructF64x4, e1, e2, e3, e4); | 447 | return Inst(Opcode::CompositeConstructF64x4, e1, e2, e3, e4); |
| 450 | case Type::U32x2: | ||
| 451 | return Inst(Opcode::CompositeConstructArrayU32x2, Flags{decor}, e1, e2, e3, e4); | ||
| 452 | default: | 448 | default: |
| 453 | ThrowInvalidType(e1.Type()); | 449 | ThrowInvalidType(e1.Type()); |
| 454 | } | 450 | } |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.h b/src/shader_recompiler/frontend/ir/microinstruction.h index 77296cfa4..6658dc674 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.h +++ b/src/shader_recompiler/frontend/ir/microinstruction.h | |||
| @@ -101,8 +101,8 @@ public: | |||
| 101 | 101 | ||
| 102 | template <typename FlagsType> | 102 | template <typename FlagsType> |
| 103 | requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) | 103 | requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) |
| 104 | [[nodiscard]] void SetFlags(FlagsType& new_val) noexcept { | 104 | [[nodiscard]] void SetFlags(FlagsType value) noexcept { |
| 105 | std::memcpy(&flags, &new_val, sizeof(new_val)); | 105 | std::memcpy(&flags, &value, sizeof(value)); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | /// Intrusively store the host definition of this instruction. | 108 | /// Intrusively store the host definition of this instruction. |
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.h index 20fb14fea..4f09a4b39 100644 --- a/src/shader_recompiler/frontend/ir/modifiers.h +++ b/src/shader_recompiler/frontend/ir/modifiers.h | |||
| @@ -32,11 +32,6 @@ struct FpControl { | |||
| 32 | }; | 32 | }; |
| 33 | static_assert(sizeof(FpControl) <= sizeof(u32)); | 33 | static_assert(sizeof(FpControl) <= sizeof(u32)); |
| 34 | 34 | ||
| 35 | struct CompositeDecoration { | ||
| 36 | bool is_constant{false}; | ||
| 37 | }; | ||
| 38 | static_assert(sizeof(CompositeDecoration) <= sizeof(u32)); | ||
| 39 | |||
| 40 | union TextureInstInfo { | 35 | union TextureInstInfo { |
| 41 | u32 raw; | 36 | u32 raw; |
| 42 | BitField<0, 8, TextureType> type; | 37 | BitField<0, 8, TextureType> type; |
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index 3dacd7b6b..e12b92c47 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -126,7 +126,6 @@ OPCODE(CompositeExtractF64x4, F64, F64x | |||
| 126 | OPCODE(CompositeInsertF64x2, F64x2, F64x2, F64, U32, ) | 126 | OPCODE(CompositeInsertF64x2, F64x2, F64x2, F64, U32, ) |
| 127 | OPCODE(CompositeInsertF64x3, F64x3, F64x3, F64, U32, ) | 127 | OPCODE(CompositeInsertF64x3, F64x3, F64x3, F64, U32, ) |
| 128 | OPCODE(CompositeInsertF64x4, F64x4, F64x4, F64, U32, ) | 128 | OPCODE(CompositeInsertF64x4, F64x4, F64x4, F64, U32, ) |
| 129 | OPCODE(CompositeConstructArrayU32x2, Opaque, U32x2, U32x2, U32x2, U32x2, ) | ||
| 130 | 129 | ||
| 131 | // Select operations | 130 | // Select operations |
| 132 | OPCODE(SelectU1, U1, U1, U1, U1, ) | 131 | OPCODE(SelectU1, U1, U1, U1, U1, ) |
diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp index 7671fc3d8..e8e4662e7 100644 --- a/src/shader_recompiler/frontend/ir/value.cpp +++ b/src/shader_recompiler/frontend/ir/value.cpp | |||
| @@ -44,20 +44,6 @@ bool Value::IsEmpty() const noexcept { | |||
| 44 | return type == Type::Void; | 44 | return type == Type::Void; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | bool Value::IsConstantContainer() const { | ||
| 48 | if (IsImmediate()) { | ||
| 49 | return true; | ||
| 50 | } | ||
| 51 | ValidateAccess(Type::Opaque); | ||
| 52 | auto num_args = inst->NumArgs(); | ||
| 53 | for (size_t i = 0; i < num_args; i++) { | ||
| 54 | if (!inst->Arg(i).IsConstantContainer()) { | ||
| 55 | return false; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | return true; | ||
| 59 | } | ||
| 60 | |||
| 61 | bool Value::IsImmediate() const noexcept { | 47 | bool Value::IsImmediate() const noexcept { |
| 62 | if (IsIdentity()) { | 48 | if (IsIdentity()) { |
| 63 | return inst->Arg(0).IsImmediate(); | 49 | return inst->Arg(0).IsImmediate(); |
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h index 5d6e74c14..b27601e70 100644 --- a/src/shader_recompiler/frontend/ir/value.h +++ b/src/shader_recompiler/frontend/ir/value.h | |||
| @@ -38,7 +38,6 @@ public: | |||
| 38 | [[nodiscard]] bool IsImmediate() const noexcept; | 38 | [[nodiscard]] bool IsImmediate() const noexcept; |
| 39 | [[nodiscard]] bool IsLabel() const noexcept; | 39 | [[nodiscard]] bool IsLabel() const noexcept; |
| 40 | [[nodiscard]] IR::Type Type() const noexcept; | 40 | [[nodiscard]] IR::Type Type() const noexcept; |
| 41 | [[nodiscard]] bool IsConstantContainer() const; | ||
| 42 | 41 | ||
| 43 | [[nodiscard]] IR::Inst* Inst() const; | 42 | [[nodiscard]] IR::Inst* Inst() const; |
| 44 | [[nodiscard]] IR::Block* Label() const; | 43 | [[nodiscard]] IR::Block* Label() const; |