summaryrefslogtreecommitdiff
path: root/src/video_core/shader/expr.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-06-27 00:39:40 -0400
committerGravatar FernandoS272019-10-04 18:52:47 -0400
commitc17953978b16f82a3b2049f8b961275020c73dd0 (patch)
tree669f353dfa3e6a6198b404e326356ca1243a4e91 /src/video_core/shader/expr.h
parentMerge pull request #2941 from FernandoS27/fix-master (diff)
downloadyuzu-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.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 @@
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
12namespace VideoCommon::Shader {
13
14using Tegra::Shader::ConditionCode;
15using Tegra::Shader::Pred;
16
17class ExprAnd;
18class ExprOr;
19class ExprNot;
20class ExprPredicate;
21class ExprCondCode;
22class ExprVar;
23class ExprBoolean;
24
25using ExprData =
26 std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>;
27using Expr = std::shared_ptr<ExprData>;
28
29class ExprAnd final {
30public:
31 ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {}
32
33 Expr operand1;
34 Expr operand2;
35};
36
37class ExprOr final {
38public:
39 ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {}
40
41 Expr operand1;
42 Expr operand2;
43};
44
45class ExprNot final {
46public:
47 ExprNot(Expr a) : operand1{a} {}
48
49 Expr operand1;
50};
51
52class ExprVar final {
53public:
54 ExprVar(u32 index) : var_index{index} {}
55
56 u32 var_index;
57};
58
59class ExprPredicate final {
60public:
61 ExprPredicate(Pred predicate) : predicate{predicate} {}
62
63 Pred predicate;
64};
65
66class ExprCondCode final {
67public:
68 ExprCondCode(ConditionCode cc) : cc{cc} {}
69
70 ConditionCode cc;
71};
72
73class ExprBoolean final {
74public:
75 ExprBoolean(bool val) : value{val} {}
76
77 bool value;
78};
79
80template <typename T, typename... Args>
81Expr 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