From fed05b362916be10bd0155f29b4d7175fac0e938 Mon Sep 17 00:00:00 2001 From: David Kehoe Date: Mon, 4 May 2026 17:12:28 +1000 Subject: [PATCH 1/2] Update ShaderCache.cpp --- src/ShaderCache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ShaderCache.cpp b/src/ShaderCache.cpp index af0ffd5639..9eb0d91690 100644 --- a/src/ShaderCache.cpp +++ b/src/ShaderCache.cpp @@ -2966,7 +2966,12 @@ namespace SIE QueryPerformanceCounter(&end); const double elapsedMs = static_cast(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart; - const uint64_t remaining = compilationSet.totalTasks - compilationSet.completedTasks.load(std::memory_order_relaxed) - compilationSet.failedTasks.load(std::memory_order_relaxed); + // Use saturating math: without a lock, Clear() can zero totalTasks while completedTasks + // still reads high briefly, which would otherwise underflow uint64_t (logs as ~2^64-1). + const uint64_t total = compilationSet.totalTasks.load(std::memory_order_relaxed); + const uint64_t done = compilationSet.completedTasks.load(std::memory_order_relaxed) + + compilationSet.failedTasks.load(std::memory_order_relaxed); + const uint64_t remaining = (total > done) ? (total - done) : 0; // Proxy for permutation complexity: descriptor low 32 bits from GetId(); popcount = active defines. // Shader file size provides a secondary signal for source complexity. From 853cda7cfe3772660ebd82bae8dce3a2783a580f Mon Sep 17 00:00:00 2001 From: davo0411 Date: Mon, 4 May 2026 17:27:34 +1000 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/ShaderCache.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ShaderCache.cpp b/src/ShaderCache.cpp index 9eb0d91690..aa06340c38 100644 --- a/src/ShaderCache.cpp +++ b/src/ShaderCache.cpp @@ -2971,7 +2971,10 @@ namespace SIE const uint64_t total = compilationSet.totalTasks.load(std::memory_order_relaxed); const uint64_t done = compilationSet.completedTasks.load(std::memory_order_relaxed) + compilationSet.failedTasks.load(std::memory_order_relaxed); - const uint64_t remaining = (total > done) ? (total - done) : 0; + // This task has already finished running, but Complete(task) has not yet updated the counters. + // Include the current task in the local progress snapshot so the logged remaining count is accurate. + const uint64_t doneIncludingCurrent = (done < total) ? (done + 1) : total; + const uint64_t remaining = (total > doneIncludingCurrent) ? (total - doneIncludingCurrent) : 0; // Proxy for permutation complexity: descriptor low 32 bits from GetId(); popcount = active defines. // Shader file size provides a secondary signal for source complexity.