summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/expr.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-06-27 06:39:40 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:47 +0200
commitc17953978b16f82a3b2049f8b961275020c73dd0 (patch)
tree669f353dfa3e6a6198b404e326356ca1243a4e91 /src/video_core/shader/expr.h
parentMerge pull request #2941 from FernandoS27/fix-master (diff)
downloadyuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar
yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.gz
yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.bz2
yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.lz
yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.xz
yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.zst
yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.zip
Diffstat (limited to 'src/video_core/shader/expr.h')
-rw-r--r--src/video_core/shader/expr.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/video_core/shader/expr.h b/src/video_core/shader/expr.h
new file mode 100644
index 000000000..94678f09a
--- /dev/null
+++ b/src/video_core/shader/expr.h
@@ -0,0 +1,86 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <variant>
+#include <memory>
+
+#include "video_core/engines/shader_bytecode.h"
+
+namespace VideoCommon::Shader {
+
+using Tegra::Shader::ConditionCode;
+using Tegra::Shader::Pred;
+
+class ExprAnd;
+class ExprOr;
+class ExprNot;
+class ExprPredicate;
+class ExprCondCode;
+class ExprVar;
+class ExprBoolean;
+
+using ExprData =
+ std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>;
+using Expr = std::shared_ptr<ExprData>;
+
+class ExprAnd final {
+public:
+ ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {}
+
+ Expr operand1;
+ Expr operand2;
+};
+
+class ExprOr final {
+public:
+ ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {}
+
+ Expr operand1;
+ Expr operand2;
+};
+
+class ExprNot final {
+public:
+ ExprNot(Expr a) : operand1{a} {}
+
+ Expr operand1;
+};
+
+class ExprVar final {
+public:
+ ExprVar(u32 index) : var_index{index} {}
+
+ u32 var_index;
+};
+
+class ExprPredicate final {
+public:
+ ExprPredicate(Pred predicate) : predicate{predicate} {}
+
+ Pred predicate;
+};
+
+class ExprCondCode final {
+public:
+ ExprCondCode(ConditionCode cc) : cc{cc} {}
+
+ ConditionCode cc;
+};
+
+class ExprBoolean final {
+public:
+ ExprBoolean(bool val) : value{val} {}
+
+ bool value;
+};
+
+template <typename T, typename... Args>
+Expr MakeExpr(Args&&... args) {
+ static_assert(std::is_convertible_v<T, ExprData>);
+ return std::make_shared<ExprData>(T(std::forward<Args>(args)...));
+}
+
+} // namespace VideoCommon::Shader