diff options
| author | 2019-10-05 12:02:51 -0400 | |
|---|---|---|
| committer | 2019-10-05 12:02:51 -0400 | |
| commit | 47ccfabe18db3691a09f211fc4aec465ee186c2a (patch) | |
| tree | 8bd02e8d5e16dee8522e29d21c711ef98282bb52 /src/video_core/shader/expr.h | |
| parent | Merge pull request #2888 from FernandoS27/decompiler2 (diff) | |
| parent | video_core/control_flow: Eliminate variable shadowing warnings (diff) | |
| download | yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.gz yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.xz yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.zip | |
Merge pull request #2944 from lioncash/ast
video_core/shader: Minor changes
Diffstat (limited to 'src/video_core/shader/expr.h')
| -rw-r--r-- | src/video_core/shader/expr.h | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/video_core/shader/expr.h b/src/video_core/shader/expr.h index 4c399cef9..d3dcd00ec 100644 --- a/src/video_core/shader/expr.h +++ b/src/video_core/shader/expr.h | |||
| @@ -15,12 +15,12 @@ using Tegra::Shader::ConditionCode; | |||
| 15 | using Tegra::Shader::Pred; | 15 | using Tegra::Shader::Pred; |
| 16 | 16 | ||
| 17 | class ExprAnd; | 17 | class ExprAnd; |
| 18 | class ExprOr; | 18 | class ExprBoolean; |
| 19 | class ExprCondCode; | ||
| 19 | class ExprNot; | 20 | class ExprNot; |
| 21 | class ExprOr; | ||
| 20 | class ExprPredicate; | 22 | class ExprPredicate; |
| 21 | class ExprCondCode; | ||
| 22 | class ExprVar; | 23 | class ExprVar; |
| 23 | class ExprBoolean; | ||
| 24 | 24 | ||
| 25 | using ExprData = | 25 | using ExprData = |
| 26 | std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>; | 26 | std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>; |
| @@ -28,9 +28,10 @@ using Expr = std::shared_ptr<ExprData>; | |||
| 28 | 28 | ||
| 29 | class ExprAnd final { | 29 | class ExprAnd final { |
| 30 | public: | 30 | public: |
| 31 | explicit ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {} | 31 | explicit ExprAnd(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {} |
| 32 | 32 | ||
| 33 | bool operator==(const ExprAnd& b) const; | 33 | bool operator==(const ExprAnd& b) const; |
| 34 | bool operator!=(const ExprAnd& b) const; | ||
| 34 | 35 | ||
| 35 | Expr operand1; | 36 | Expr operand1; |
| 36 | Expr operand2; | 37 | Expr operand2; |
| @@ -38,9 +39,10 @@ public: | |||
| 38 | 39 | ||
| 39 | class ExprOr final { | 40 | class ExprOr final { |
| 40 | public: | 41 | public: |
| 41 | explicit ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {} | 42 | explicit ExprOr(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {} |
| 42 | 43 | ||
| 43 | bool operator==(const ExprOr& b) const; | 44 | bool operator==(const ExprOr& b) const; |
| 45 | bool operator!=(const ExprOr& b) const; | ||
| 44 | 46 | ||
| 45 | Expr operand1; | 47 | Expr operand1; |
| 46 | Expr operand2; | 48 | Expr operand2; |
| @@ -48,9 +50,10 @@ public: | |||
| 48 | 50 | ||
| 49 | class ExprNot final { | 51 | class ExprNot final { |
| 50 | public: | 52 | public: |
| 51 | explicit ExprNot(Expr a) : operand1{a} {} | 53 | explicit ExprNot(Expr a) : operand1{std::move(a)} {} |
| 52 | 54 | ||
| 53 | bool operator==(const ExprNot& b) const; | 55 | bool operator==(const ExprNot& b) const; |
| 56 | bool operator!=(const ExprNot& b) const; | ||
| 54 | 57 | ||
| 55 | Expr operand1; | 58 | Expr operand1; |
| 56 | }; | 59 | }; |
| @@ -63,6 +66,10 @@ public: | |||
| 63 | return var_index == b.var_index; | 66 | return var_index == b.var_index; |
| 64 | } | 67 | } |
| 65 | 68 | ||
| 69 | bool operator!=(const ExprVar& b) const { | ||
| 70 | return !operator==(b); | ||
| 71 | } | ||
| 72 | |||
| 66 | u32 var_index; | 73 | u32 var_index; |
| 67 | }; | 74 | }; |
| 68 | 75 | ||
| @@ -74,6 +81,10 @@ public: | |||
| 74 | return predicate == b.predicate; | 81 | return predicate == b.predicate; |
| 75 | } | 82 | } |
| 76 | 83 | ||
| 84 | bool operator!=(const ExprPredicate& b) const { | ||
| 85 | return !operator==(b); | ||
| 86 | } | ||
| 87 | |||
| 77 | u32 predicate; | 88 | u32 predicate; |
| 78 | }; | 89 | }; |
| 79 | 90 | ||
| @@ -85,6 +96,10 @@ public: | |||
| 85 | return cc == b.cc; | 96 | return cc == b.cc; |
| 86 | } | 97 | } |
| 87 | 98 | ||
| 99 | bool operator!=(const ExprCondCode& b) const { | ||
| 100 | return !operator==(b); | ||
| 101 | } | ||
| 102 | |||
| 88 | ConditionCode cc; | 103 | ConditionCode cc; |
| 89 | }; | 104 | }; |
| 90 | 105 | ||
| @@ -96,6 +111,10 @@ public: | |||
| 96 | return value == b.value; | 111 | return value == b.value; |
| 97 | } | 112 | } |
| 98 | 113 | ||
| 114 | bool operator!=(const ExprBoolean& b) const { | ||
| 115 | return !operator==(b); | ||
| 116 | } | ||
| 117 | |||
| 99 | bool value; | 118 | bool value; |
| 100 | }; | 119 | }; |
| 101 | 120 | ||
| @@ -105,9 +124,9 @@ Expr MakeExpr(Args&&... args) { | |||
| 105 | return std::make_shared<ExprData>(T(std::forward<Args>(args)...)); | 124 | return std::make_shared<ExprData>(T(std::forward<Args>(args)...)); |
| 106 | } | 125 | } |
| 107 | 126 | ||
| 108 | bool ExprAreEqual(Expr first, Expr second); | 127 | bool ExprAreEqual(const Expr& first, const Expr& second); |
| 109 | 128 | ||
| 110 | bool ExprAreOpposite(Expr first, Expr second); | 129 | bool ExprAreOpposite(const Expr& first, const Expr& second); |
| 111 | 130 | ||
| 112 | Expr MakeExprNot(Expr first); | 131 | Expr MakeExprNot(Expr first); |
| 113 | 132 | ||
| @@ -115,6 +134,6 @@ Expr MakeExprAnd(Expr first, Expr second); | |||
| 115 | 134 | ||
| 116 | Expr MakeExprOr(Expr first, Expr second); | 135 | Expr MakeExprOr(Expr first, Expr second); |
| 117 | 136 | ||
| 118 | bool ExprIsTrue(Expr first); | 137 | bool ExprIsTrue(const Expr& first); |
| 119 | 138 | ||
| 120 | } // namespace VideoCommon::Shader | 139 | } // namespace VideoCommon::Shader |