diff options
| author | 2019-06-27 00:39:40 -0400 | |
|---|---|---|
| committer | 2019-10-04 18:52:47 -0400 | |
| commit | c17953978b16f82a3b2049f8b961275020c73dd0 (patch) | |
| tree | 669f353dfa3e6a6198b404e326356ca1243a4e91 /src/video_core/shader/expr.h | |
| parent | Merge pull request #2941 from FernandoS27/fix-master (diff) | |
| download | yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.gz yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.tar.xz yuzu-c17953978b16f82a3b2049f8b961275020c73dd0.zip | |
shader_ir: Initial Decompile Setup
Diffstat (limited to 'src/video_core/shader/expr.h')
| -rw-r--r-- | src/video_core/shader/expr.h | 86 |
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 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <variant> | ||
| 8 | #include <memory> | ||
| 9 | |||
| 10 | #include "video_core/engines/shader_bytecode.h" | ||
| 11 | |||
| 12 | namespace VideoCommon::Shader { | ||
| 13 | |||
| 14 | using Tegra::Shader::ConditionCode; | ||
| 15 | using Tegra::Shader::Pred; | ||
| 16 | |||
| 17 | class ExprAnd; | ||
| 18 | class ExprOr; | ||
| 19 | class ExprNot; | ||
| 20 | class ExprPredicate; | ||
| 21 | class ExprCondCode; | ||
| 22 | class ExprVar; | ||
| 23 | class ExprBoolean; | ||
| 24 | |||
| 25 | using ExprData = | ||
| 26 | std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>; | ||
| 27 | using Expr = std::shared_ptr<ExprData>; | ||
| 28 | |||
| 29 | class ExprAnd final { | ||
| 30 | public: | ||
| 31 | ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {} | ||
| 32 | |||
| 33 | Expr operand1; | ||
| 34 | Expr operand2; | ||
| 35 | }; | ||
| 36 | |||
| 37 | class ExprOr final { | ||
| 38 | public: | ||
| 39 | ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {} | ||
| 40 | |||
| 41 | Expr operand1; | ||
| 42 | Expr operand2; | ||
| 43 | }; | ||
| 44 | |||
| 45 | class ExprNot final { | ||
| 46 | public: | ||
| 47 | ExprNot(Expr a) : operand1{a} {} | ||
| 48 | |||
| 49 | Expr operand1; | ||
| 50 | }; | ||
| 51 | |||
| 52 | class ExprVar final { | ||
| 53 | public: | ||
| 54 | ExprVar(u32 index) : var_index{index} {} | ||
| 55 | |||
| 56 | u32 var_index; | ||
| 57 | }; | ||
| 58 | |||
| 59 | class ExprPredicate final { | ||
| 60 | public: | ||
| 61 | ExprPredicate(Pred predicate) : predicate{predicate} {} | ||
| 62 | |||
| 63 | Pred predicate; | ||
| 64 | }; | ||
| 65 | |||
| 66 | class ExprCondCode final { | ||
| 67 | public: | ||
| 68 | ExprCondCode(ConditionCode cc) : cc{cc} {} | ||
| 69 | |||
| 70 | ConditionCode cc; | ||
| 71 | }; | ||
| 72 | |||
| 73 | class ExprBoolean final { | ||
| 74 | public: | ||
| 75 | ExprBoolean(bool val) : value{val} {} | ||
| 76 | |||
| 77 | bool value; | ||
| 78 | }; | ||
| 79 | |||
| 80 | template <typename T, typename... Args> | ||
| 81 | Expr MakeExpr(Args&&... args) { | ||
| 82 | static_assert(std::is_convertible_v<T, ExprData>); | ||
| 83 | return std::make_shared<ExprData>(T(std::forward<Args>(args)...)); | ||
| 84 | } | ||
| 85 | |||
| 86 | } // namespace VideoCommon::Shader | ||