diff options
| author | 2019-05-19 04:10:32 -0400 | |
|---|---|---|
| committer | 2019-05-19 08:23:09 -0400 | |
| commit | e09ee0ff23bc70069277df87698f86cc07fb8785 (patch) | |
| tree | b33bf68596b3dcacc7301292173e27ca7741916d /src | |
| parent | shader/shader_ir: Place implementations of constructor and destructor in cpp ... (diff) | |
| download | yuzu-e09ee0ff23bc70069277df87698f86cc07fb8785.tar.gz yuzu-e09ee0ff23bc70069277df87698f86cc07fb8785.tar.xz yuzu-e09ee0ff23bc70069277df87698f86cc07fb8785.zip | |
shader/shader_ir: Mark tracking functions as const member functions
These don't actually modify instance state, so they can be marked as
const member functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 7 | ||||
| -rw-r--r-- | src/video_core/shader/track.cpp | 12 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 3fab404f4..02db2c087 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -811,11 +811,12 @@ private: | |||
| 811 | void WriteLop3Instruction(NodeBlock& bb, Tegra::Shader::Register dest, Node op_a, Node op_b, | 811 | void WriteLop3Instruction(NodeBlock& bb, Tegra::Shader::Register dest, Node op_a, Node op_b, |
| 812 | Node op_c, Node imm_lut, bool sets_cc); | 812 | Node op_c, Node imm_lut, bool sets_cc); |
| 813 | 813 | ||
| 814 | Node TrackCbuf(Node tracked, const NodeBlock& code, s64 cursor); | 814 | Node TrackCbuf(Node tracked, const NodeBlock& code, s64 cursor) const; |
| 815 | 815 | ||
| 816 | std::optional<u32> TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor); | 816 | std::optional<u32> TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor) const; |
| 817 | 817 | ||
| 818 | std::pair<Node, s64> TrackRegister(const GprNode* tracked, const NodeBlock& code, s64 cursor); | 818 | std::pair<Node, s64> TrackRegister(const GprNode* tracked, const NodeBlock& code, |
| 819 | s64 cursor) const; | ||
| 819 | 820 | ||
| 820 | std::tuple<Node, Node, GlobalMemoryBase> TrackAndGetGlobalMemory(NodeBlock& bb, | 821 | std::tuple<Node, Node, GlobalMemoryBase> TrackAndGetGlobalMemory(NodeBlock& bb, |
| 821 | Node addr_register, | 822 | Node addr_register, |
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index 4505667ff..19ede1eb9 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp | |||
| @@ -17,22 +17,24 @@ std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor, | |||
| 17 | for (; cursor >= 0; --cursor) { | 17 | for (; cursor >= 0; --cursor) { |
| 18 | const Node node = code.at(cursor); | 18 | const Node node = code.at(cursor); |
| 19 | if (const auto operation = std::get_if<OperationNode>(node)) { | 19 | if (const auto operation = std::get_if<OperationNode>(node)) { |
| 20 | if (operation->GetCode() == operation_code) | 20 | if (operation->GetCode() == operation_code) { |
| 21 | return {node, cursor}; | 21 | return {node, cursor}; |
| 22 | } | ||
| 22 | } | 23 | } |
| 23 | if (const auto conditional = std::get_if<ConditionalNode>(node)) { | 24 | if (const auto conditional = std::get_if<ConditionalNode>(node)) { |
| 24 | const auto& conditional_code = conditional->GetCode(); | 25 | const auto& conditional_code = conditional->GetCode(); |
| 25 | const auto [found, internal_cursor] = FindOperation( | 26 | const auto [found, internal_cursor] = FindOperation( |
| 26 | conditional_code, static_cast<s64>(conditional_code.size() - 1), operation_code); | 27 | conditional_code, static_cast<s64>(conditional_code.size() - 1), operation_code); |
| 27 | if (found) | 28 | if (found) { |
| 28 | return {found, cursor}; | 29 | return {found, cursor}; |
| 30 | } | ||
| 29 | } | 31 | } |
| 30 | } | 32 | } |
| 31 | return {}; | 33 | return {}; |
| 32 | } | 34 | } |
| 33 | } // namespace | 35 | } // namespace |
| 34 | 36 | ||
| 35 | Node ShaderIR::TrackCbuf(Node tracked, const NodeBlock& code, s64 cursor) { | 37 | Node ShaderIR::TrackCbuf(Node tracked, const NodeBlock& code, s64 cursor) const { |
| 36 | if (const auto cbuf = std::get_if<CbufNode>(tracked)) { | 38 | if (const auto cbuf = std::get_if<CbufNode>(tracked)) { |
| 37 | // Cbuf found, but it has to be immediate | 39 | // Cbuf found, but it has to be immediate |
| 38 | return std::holds_alternative<ImmediateNode>(*cbuf->GetOffset()) ? tracked : nullptr; | 40 | return std::holds_alternative<ImmediateNode>(*cbuf->GetOffset()) ? tracked : nullptr; |
| @@ -65,7 +67,7 @@ Node ShaderIR::TrackCbuf(Node tracked, const NodeBlock& code, s64 cursor) { | |||
| 65 | return nullptr; | 67 | return nullptr; |
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | std::optional<u32> ShaderIR::TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor) { | 70 | std::optional<u32> ShaderIR::TrackImmediate(Node tracked, const NodeBlock& code, s64 cursor) const { |
| 69 | // Reduce the cursor in one to avoid infinite loops when the instruction sets the same register | 71 | // Reduce the cursor in one to avoid infinite loops when the instruction sets the same register |
| 70 | // that it uses as operand | 72 | // that it uses as operand |
| 71 | const auto [found, found_cursor] = | 73 | const auto [found, found_cursor] = |
| @@ -80,7 +82,7 @@ std::optional<u32> ShaderIR::TrackImmediate(Node tracked, const NodeBlock& code, | |||
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | std::pair<Node, s64> ShaderIR::TrackRegister(const GprNode* tracked, const NodeBlock& code, | 84 | std::pair<Node, s64> ShaderIR::TrackRegister(const GprNode* tracked, const NodeBlock& code, |
| 83 | s64 cursor) { | 85 | s64 cursor) const { |
| 84 | for (; cursor >= 0; --cursor) { | 86 | for (; cursor >= 0; --cursor) { |
| 85 | const auto [found_node, new_cursor] = FindOperation(code, cursor, OperationCode::Assign); | 87 | const auto [found_node, new_cursor] = FindOperation(code, cursor, OperationCode::Assign); |
| 86 | if (!found_node) { | 88 | if (!found_node) { |