mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 15:59:59 -04:00
The float atomic add's compare-and-swap loop (patch 0033) carried its expected value round the loop in a local, but the pass runs on SSA form and the optimizer's copy propagation takes every value as assigned once, so the loop compared against a stale value and the froxel fog added up wrong: Kokiri Forest was washed out white. Each attempt now reads the word with an atomic OR of 0, which also cannot return a stale cached copy. Writes through the device address table go to the guest copy for stores only (patch 0034). An atomic on the guest copy started from its stale value, so a counter the GPU reset with a buffer fill kept counting there, and the page's next sync copied the wrong count into the mirror: culled foliage drew garbage for a frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
1.2 KiB
Diff
20 lines
1.2 KiB
Diff
--- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
|
|
@@ -960,11 +960,15 @@
|
|
|
|
private static Operand GenerateAtomicCasLoop(EmitterContext context, Operand wordOffset, int binding, Func<Operand, Operand> opCallback)
|
|
{
|
|
+ // NX2NAVI: each attempt reads the word with an atomic OR of 0, which returns its current value; a plain load
|
|
+ // 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. The read stays inside the loop: this pass runs on SSA form, and the
|
|
+ // optimizer's copy propagation takes every value as assigned once, so no local can carry a value round it.
|
|
Operand lblLoopHead = Label();
|
|
|
|
context.MarkLabel(lblLoopHead);
|
|
|
|
- Operand oldValue = context.Load(StorageKind.StorageBuffer, binding, Const(0), wordOffset);
|
|
+ Operand oldValue = context.AtomicOr(StorageKind.StorageBuffer, binding, Const(0), wordOffset, Const(0));
|
|
Operand newValue = opCallback(oldValue);
|
|
|
|
Operand casResult = context.AtomicCompareAndSwap(
|