From 6c0c2dfabce6ebef401321c2fa7879e291690b39 Mon Sep 17 00:00:00 2001 From: Nguyen Dac Nam Date: Fri, 28 Feb 2020 11:59:05 +0700 Subject: [PATCH] shader_decode: Fix LD, LDG when track constant buffer --- src/video_core/shader/track.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index face8c9438..a113a58680 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp @@ -159,11 +159,19 @@ std::tuple ShaderIR::TrackCbuf(Node tracked, const NodeBlock& co } // Reduce the cursor in one to avoid infinite loops when the instruction sets the same // register that it uses as operand - const auto [source, new_cursor] = TrackRegister(gpr, code, cursor - 1); - if (!source) { - return {}; + s64 current_cursor = cursor; + while (current_cursor > 0) { + const auto [source, new_cursor] = TrackRegister(gpr, code, current_cursor - 1); + current_cursor = new_cursor; + if (!source) { + continue; + } + const auto [base_address, index, offset] = TrackCbuf(source, code, current_cursor); + if (base_address != nullptr) { + return {base_address, index, offset}; + } } - return TrackCbuf(source, code, new_cursor); + return {}; } if (const auto operation = std::get_if(&*tracked)) { for (std::size_t i = operation->GetOperandsCount(); i > 0; --i) {