From 67dd111dcc4991971376715bc10b480f54c4a6c7 Mon Sep 17 00:00:00 2001 From: Lander Gallastegi Date: Mon, 24 Mar 2025 00:14:44 +0100 Subject: [PATCH] Fix TrackSharp --- .../ir/passes/resource_tracking_pass.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index c5bfe5796..0f6b1a150 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -244,16 +244,20 @@ SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) { } return std::nullopt; }; + // We are not accounting for modifications to after the source. const auto result = IR::BreadthFirstSearch(inst, pred); ASSERT_MSG(result, "Unable to track sharp source"); inst = result.value(); if (inst->GetOpcode() == IR::Opcode::GetUserData) { return static_cast(inst->Arg(0).ScalarReg()); - } else { - ASSERT_MSG(inst->GetOpcode() == IR::Opcode::ReadConst, - "Sharp load not from constant memory"); - return inst->Flags(); + } else if (inst->GetOpcode() == IR::Opcode::ReadConst) { + // Sharp is stored in the offset argument. + // The vale is not inmediate if ReadConst is inside of a loop + // and the offset is different in each iteration. (we don't support this) + ASSERT(inst->Arg(1).IsImmediate()); + return inst->Arg(1).U32(); } + UNREACHABLE_MSG("Sharp load not from constant memory or user data"); } s32 TryHandleInlineCbuf(IR::Inst& inst, Info& info, Descriptors& descriptors,