From 8eb1398f8d90fb2813f438b9fffac716b6ec51d2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Oct 2019 08:17:32 -0400 Subject: video_core/{ast, expr}: Use std::move where applicable Avoids unnecessary atomic reference count increments and decrements. --- src/video_core/shader/expr.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/video_core/shader/expr.h') diff --git a/src/video_core/shader/expr.h b/src/video_core/shader/expr.h index 4c399cef9..1f1638520 100644 --- a/src/video_core/shader/expr.h +++ b/src/video_core/shader/expr.h @@ -28,7 +28,7 @@ using Expr = std::shared_ptr; class ExprAnd final { public: - explicit ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {} + explicit ExprAnd(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {} bool operator==(const ExprAnd& b) const; @@ -38,7 +38,7 @@ public: class ExprOr final { public: - explicit ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {} + explicit ExprOr(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {} bool operator==(const ExprOr& b) const; @@ -48,7 +48,7 @@ public: class ExprNot final { public: - explicit ExprNot(Expr a) : operand1{a} {} + explicit ExprNot(Expr a) : operand1{std::move(a)} {} bool operator==(const ExprNot& b) const; @@ -105,9 +105,9 @@ Expr MakeExpr(Args&&... args) { return std::make_shared(T(std::forward(args)...)); } -bool ExprAreEqual(Expr first, Expr second); +bool ExprAreEqual(const Expr& first, const Expr& second); -bool ExprAreOpposite(Expr first, Expr second); +bool ExprAreOpposite(const Expr& first, const Expr& second); Expr MakeExprNot(Expr first); @@ -115,6 +115,6 @@ Expr MakeExprAnd(Expr first, Expr second); Expr MakeExprOr(Expr first, Expr second); -bool ExprIsTrue(Expr first); +bool ExprIsTrue(const Expr& first); } // namespace VideoCommon::Shader -- cgit v1.2.3 From 50ad74558566af897db6d7a999101e40ee544108 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Oct 2019 08:37:39 -0400 Subject: video_core/expr: Supply operator!= along with operator== Provides logical symmetry to the interface. --- src/video_core/shader/expr.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/video_core/shader/expr.h') diff --git a/src/video_core/shader/expr.h b/src/video_core/shader/expr.h index 1f1638520..45695c0ed 100644 --- a/src/video_core/shader/expr.h +++ b/src/video_core/shader/expr.h @@ -31,6 +31,7 @@ public: explicit ExprAnd(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {} bool operator==(const ExprAnd& b) const; + bool operator!=(const ExprAnd& b) const; Expr operand1; Expr operand2; @@ -41,6 +42,7 @@ public: explicit ExprOr(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {} bool operator==(const ExprOr& b) const; + bool operator!=(const ExprOr& b) const; Expr operand1; Expr operand2; @@ -51,6 +53,7 @@ public: explicit ExprNot(Expr a) : operand1{std::move(a)} {} bool operator==(const ExprNot& b) const; + bool operator!=(const ExprNot& b) const; Expr operand1; }; @@ -63,6 +66,10 @@ public: return var_index == b.var_index; } + bool operator!=(const ExprVar& b) const { + return !operator==(b); + } + u32 var_index; }; @@ -74,6 +81,10 @@ public: return predicate == b.predicate; } + bool operator!=(const ExprPredicate& b) const { + return !operator==(b); + } + u32 predicate; }; @@ -85,6 +96,10 @@ public: return cc == b.cc; } + bool operator!=(const ExprCondCode& b) const { + return !operator==(b); + } + ConditionCode cc; }; @@ -96,6 +111,10 @@ public: return value == b.value; } + bool operator!=(const ExprBoolean& b) const { + return !operator==(b); + } + bool value; }; -- cgit v1.2.3 From 43503a69bf730125b380601a919e81ca09afeb74 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Oct 2019 08:40:24 -0400 Subject: video_core/{ast, expr}: Organize forward declaration Keeps them alphabetically sorted for readability. --- src/video_core/shader/expr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/video_core/shader/expr.h') diff --git a/src/video_core/shader/expr.h b/src/video_core/shader/expr.h index 45695c0ed..d3dcd00ec 100644 --- a/src/video_core/shader/expr.h +++ b/src/video_core/shader/expr.h @@ -15,12 +15,12 @@ using Tegra::Shader::ConditionCode; using Tegra::Shader::Pred; class ExprAnd; -class ExprOr; +class ExprBoolean; +class ExprCondCode; class ExprNot; +class ExprOr; class ExprPredicate; -class ExprCondCode; class ExprVar; -class ExprBoolean; using ExprData = std::variant; -- cgit v1.2.3