diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-03-29 22:36:07 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-03-30 06:53:16 +0100 |
commit | cf4ecc1945acd7c26845f2083d2fc118f5dcac1c (patch) | |
tree | b79e6944459b73783f390fe91060211101ab72bb /src/video_core/shader/track.cpp | |
parent | Merge pull request #2266 from FernandoS27/arbitration (diff) | |
download | yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.tar yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.tar.gz yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.tar.bz2 yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.tar.lz yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.tar.xz yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.tar.zst yuzu-cf4ecc1945acd7c26845f2083d2fc118f5dcac1c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/shader/track.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index 33b071747..4505667ff 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp @@ -6,6 +6,7 @@ #include <utility> #include <variant> +#include "common/common_types.h" #include "video_core/shader/shader_ir.h" namespace VideoCommon::Shader { @@ -14,7 +15,7 @@ namespace { std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor, OperationCode operation_code) { for (; cursor >= 0; --cursor) { - const Node node = code[cursor]; + const Node node = code.at(cursor); if (const auto operation = std::get_if<OperationNode>(node)) { if (operation->GetCode() == operation_code) return {node, cursor}; @@ -64,6 +65,20 @@ Node ShaderIR::TrackCbuf(Node tracked, const NodeBlock& code, s64 cursor) { return nullptr; } +std::optional<u32> ShaderIR::TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor) { + // Reduce the cursor in one to avoid infinite loops when the instruction sets the same register + // that it uses as operand + const auto [found, found_cursor] = + TrackRegister(&std::get<GprNode>(*tracked), code, cursor - 1); + if (!found) { + return {}; + } + if (const auto immediate = std::get_if<ImmediateNode>(found)) { + return immediate->GetValue(); + } + return {}; +} + std::pair<Node, s64> ShaderIR::TrackRegister(const GprNode* tracked, const NodeBlock& code, s64 cursor) { for (; cursor >= 0; --cursor) { |