diff options
| author | 2019-10-26 16:56:13 -0300 | |
|---|---|---|
| committer | 2019-10-26 16:56:13 -0300 | |
| commit | 26f3e18c5cb882d48af702aa33519f4a2c74fa75 (patch) | |
| tree | f17b70de1e1bca10e67a4f1076691a580f717f56 /src/video_core/shader/decode.cpp | |
| parent | Merge pull request #3027 from lioncash/lookup (diff) | |
| parent | Shader_IR: Address Feedback. (diff) | |
| download | yuzu-26f3e18c5cb882d48af702aa33519f4a2c74fa75.tar.gz yuzu-26f3e18c5cb882d48af702aa33519f4a2c74fa75.tar.xz yuzu-26f3e18c5cb882d48af702aa33519f4a2c74fa75.zip | |
Merge pull request #2976 from FernandoS27/cache-fast-brx-rebased
Implement Fast BRX, fix TXQ and addapt the Shader Cache for it
Diffstat (limited to 'src/video_core/shader/decode.cpp')
| -rw-r--r-- | src/video_core/shader/decode.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp index 2626b1616..21fb9cb83 100644 --- a/src/video_core/shader/decode.cpp +++ b/src/video_core/shader/decode.cpp | |||
| @@ -33,7 +33,7 @@ constexpr bool IsSchedInstruction(u32 offset, u32 main_offset) { | |||
| 33 | return (absolute_offset % SchedPeriod) == 0; | 33 | return (absolute_offset % SchedPeriod) == 0; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | } // namespace | 36 | } // Anonymous namespace |
| 37 | 37 | ||
| 38 | class ASTDecoder { | 38 | class ASTDecoder { |
| 39 | public: | 39 | public: |
| @@ -102,7 +102,7 @@ void ShaderIR::Decode() { | |||
| 102 | std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); | 102 | std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); |
| 103 | 103 | ||
| 104 | decompiled = false; | 104 | decompiled = false; |
| 105 | auto info = ScanFlow(program_code, program_size, main_offset, settings); | 105 | auto info = ScanFlow(program_code, main_offset, settings, locker); |
| 106 | auto& shader_info = *info; | 106 | auto& shader_info = *info; |
| 107 | coverage_begin = shader_info.start; | 107 | coverage_begin = shader_info.start; |
| 108 | coverage_end = shader_info.end; | 108 | coverage_end = shader_info.end; |
| @@ -155,7 +155,7 @@ void ShaderIR::Decode() { | |||
| 155 | [[fallthrough]]; | 155 | [[fallthrough]]; |
| 156 | case CompileDepth::BruteForce: { | 156 | case CompileDepth::BruteForce: { |
| 157 | coverage_begin = main_offset; | 157 | coverage_begin = main_offset; |
| 158 | const u32 shader_end = static_cast<u32>(program_size / sizeof(u64)); | 158 | const std::size_t shader_end = program_code.size(); |
| 159 | coverage_end = shader_end; | 159 | coverage_end = shader_end; |
| 160 | for (u32 label = main_offset; label < shader_end; label++) { | 160 | for (u32 label = main_offset; label < shader_end; label++) { |
| 161 | basic_blocks.insert({label, DecodeRange(label, label + 1)}); | 161 | basic_blocks.insert({label, DecodeRange(label, label + 1)}); |
| @@ -198,24 +198,39 @@ void ShaderIR::InsertControlFlow(NodeBlock& bb, const ShaderBlock& block) { | |||
| 198 | } | 198 | } |
| 199 | return result; | 199 | return result; |
| 200 | }; | 200 | }; |
| 201 | if (block.branch.address < 0) { | 201 | if (std::holds_alternative<SingleBranch>(*block.branch)) { |
| 202 | if (block.branch.kills) { | 202 | auto branch = std::get_if<SingleBranch>(block.branch.get()); |
| 203 | Node n = Operation(OperationCode::Discard); | 203 | if (branch->address < 0) { |
| 204 | n = apply_conditions(block.branch.cond, n); | 204 | if (branch->kill) { |
| 205 | Node n = Operation(OperationCode::Discard); | ||
| 206 | n = apply_conditions(branch->condition, n); | ||
| 207 | bb.push_back(n); | ||
| 208 | global_code.push_back(n); | ||
| 209 | return; | ||
| 210 | } | ||
| 211 | Node n = Operation(OperationCode::Exit); | ||
| 212 | n = apply_conditions(branch->condition, n); | ||
| 205 | bb.push_back(n); | 213 | bb.push_back(n); |
| 206 | global_code.push_back(n); | 214 | global_code.push_back(n); |
| 207 | return; | 215 | return; |
| 208 | } | 216 | } |
| 209 | Node n = Operation(OperationCode::Exit); | 217 | Node n = Operation(OperationCode::Branch, Immediate(branch->address)); |
| 210 | n = apply_conditions(block.branch.cond, n); | 218 | n = apply_conditions(branch->condition, n); |
| 211 | bb.push_back(n); | 219 | bb.push_back(n); |
| 212 | global_code.push_back(n); | 220 | global_code.push_back(n); |
| 213 | return; | 221 | return; |
| 214 | } | 222 | } |
| 215 | Node n = Operation(OperationCode::Branch, Immediate(block.branch.address)); | 223 | auto multi_branch = std::get_if<MultiBranch>(block.branch.get()); |
| 216 | n = apply_conditions(block.branch.cond, n); | 224 | Node op_a = GetRegister(multi_branch->gpr); |
| 217 | bb.push_back(n); | 225 | for (auto& branch_case : multi_branch->branches) { |
| 218 | global_code.push_back(n); | 226 | Node n = Operation(OperationCode::Branch, Immediate(branch_case.address)); |
| 227 | Node op_b = Immediate(branch_case.cmp_value); | ||
| 228 | Node condition = | ||
| 229 | GetPredicateComparisonInteger(Tegra::Shader::PredCondition::Equal, false, op_a, op_b); | ||
| 230 | auto result = Conditional(condition, {n}); | ||
| 231 | bb.push_back(result); | ||
| 232 | global_code.push_back(result); | ||
| 233 | } | ||
| 219 | } | 234 | } |
| 220 | 235 | ||
| 221 | u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) { | 236 | u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) { |