Files
NX2navi/tools/xlate/patches/0033-cas-loop-expected-value.patch
chrg6 e7f6a00407 Translate every shader, keep atomic loops from spinning on stale values, harden pool teardown, and update the README.
Shaders: a switch whose index is clamped against a register that a MOV of an immediate set before it now finds its
jump table (AmpereLowering.cs BrxTargets), so all 36,031 of the game's shader variants translate and no draw is skipped
for a failed one. The compare-and-swap loop behind storage-buffer atomics (patch 0033) takes the value a failed swap
returns as its next expected value instead of loading the word again, which on some drivers kept returning a stale
copy.

Memory: an unused physical pool outlives the submission being recorded, as virtual pages may still reach it through
device addresses; an image whose creation failed is not tried again for 2 s.

The installer and Linux texts name this game.
The README has the project icon, the current status, features, requirements and known issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 18:03:20 -05:00

29 lines
1.4 KiB
Diff

--- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
+++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
@@ -960,11 +960,16 @@
private static Operand GenerateAtomicCasLoop(EmitterContext context, Operand wordOffset, int binding, Func<Operand, Operand> opCallback)
{
+ // NX2NAVI: the word is loaded once; a failed compare-and-swap returns the word's current value, which becomes
+ // the next attempt's expected value. A plain load in every attempt could keep returning a stale cached copy
+ // (seen on AMD), so an invocation that lost the race never matched again and the loop did not end.
Operand lblLoopHead = Label();
+ Operand oldValue = Local();
+ context.Copy(oldValue, context.Load(StorageKind.StorageBuffer, binding, Const(0), wordOffset));
+
context.MarkLabel(lblLoopHead);
- Operand oldValue = context.Load(StorageKind.StorageBuffer, binding, Const(0), wordOffset);
Operand newValue = opCallback(oldValue);
Operand casResult = context.AtomicCompareAndSwap(
@@ -977,6 +982,7 @@
Operand casFail = context.ICompareNotEqual(casResult, oldValue);
+ context.Copy(oldValue, casResult);
context.BranchIfTrue(lblLoopHead, casFail);
return oldValue;