summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/control_flow.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-06-25 01:46:49 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-07-09 14:14:36 +0200
commit8af6e6a05207b1c9736bd80a89ec3aed1f96dfea (patch)
tree963d5d4d7e0f2ca7762e410f7c400ddd9d8ec3ba /src/video_core/shader/control_flow.h
parentMerge pull request #2661 from ogniK5377/audren-loop (diff)
downloadyuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.tar
yuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.tar.gz
yuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.tar.bz2
yuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.tar.lz
yuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.tar.xz
yuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.tar.zst
yuzu-8af6e6a05207b1c9736bd80a89ec3aed1f96dfea.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/control_flow.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/video_core/shader/control_flow.h b/src/video_core/shader/control_flow.h
new file mode 100644
index 000000000..16736d57a
--- /dev/null
+++ b/src/video_core/shader/control_flow.h
@@ -0,0 +1,55 @@
+#pragma once
+
+#include <cstring>
+#include <list>
+#include <optional>
+#include <vector>
+
+#include "video_core/engines/shader_bytecode.h"
+#include "video_core/shader/shader_ir.h"
+
+namespace VideoCommon::Shader {
+
+using Tegra::Shader::ConditionCode;
+using Tegra::Shader::Pred;
+
+constexpr s32 exit_branch = -1;
+
+struct Condition {
+ Pred predicate{Pred::UnusedIndex};
+ ConditionCode cc{ConditionCode::T};
+
+ bool IsUnconditional() const {
+ return (predicate == Pred::UnusedIndex) && (cc == ConditionCode::T);
+ }
+};
+
+struct ShaderBlock {
+ ShaderBlock() {}
+ ShaderBlock(const ShaderBlock& sb) = default;
+ u32 start{};
+ u32 end{};
+ struct Branch {
+ Condition cond{};
+ bool kills{};
+ s32 address{};
+ bool operator==(const Branch& b) const {
+ return std::memcmp(this, &b, sizeof(Branch)) == 0;
+ }
+ } branch;
+ bool operator==(const ShaderBlock& sb) const {
+ return std::memcmp(this, &sb, sizeof(ShaderBlock)) == 0;
+ }
+};
+
+struct ShaderCharacteristics {
+ std::list<ShaderBlock> blocks;
+ bool decompilable{};
+ u32 start;
+ u32 end;
+};
+
+bool ScanFlow(const ProgramCode& program_code, u32 program_size, u32 start_address,
+ ShaderCharacteristics& result_out);
+
+} // namespace VideoCommon::Shader