Files
NX2navi/tools/xlate/patches/0020-storage-base-not-from-c1.patch
chrg6 77d0c0b84e Port Ocarina of Time (Switch 2) to the recomp host
The NVN2 front end and the SM86 to Maxwell shader lowering (tools/xlate/AmpereLowering.cs, mesh and task stages,
bindless texture pools, BRX jump tables, the NVN2 compute c0 layout) with four translator patches (0017-0020) bring the
opening of the game to 58-60 fps on the Vulkan renderer.

This round fixes the haze: SM86 IPA is lowered as a plain Maxwell IPA.PASS (texture coordinates were corrected for
perspective twice); LDSM, TXD, both F2IP byte forms, HMMA, MOVM and HFMA2.RELU are lowered and spill mode has eight
uniform register groups; conditional rendering keeps the newest counter report per address and treats a report as
pending until its value is in guest memory, so occlusion tests and the depth clears around the depth copy behave; and
the upscaler stand-in decodes the post pass's sRGB picture before writing the linear target. Tensor-core programs keep
the stand-in unless NX2NAVI_NATIVE_TENSOR=1, because their lowering does not match the hardware yet.

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

19 lines
1.2 KiB
Diff

--- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
+++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs
@@ -1046,6 +1046,15 @@
// because constant buffer are always encoded as the second operand,
// so the second operand will always be the one from the last instruction.
+ // NX2NAVI: c1 holds the compiler's constants (BRX jump tables, offsets), never a buffer address; an address
+ // that adds one of them to a pointer from another bank (Ocarina's NVN2 compute: a push-constant pointer in
+ // c0 plus the constant 12 from c1) has the pointer as its base. Taking c1 sent those stores to nothing.
+ if (src1.Type == OperandType.ConstantBuffer && src2.Type == OperandType.ConstantBuffer &&
+ src2.GetCbufSlot() == 1 && src1.GetCbufSlot() != 1)
+ {
+ return GetBaseAddressCbWithOffset(src1, src2, constOffset);
+ }
+
if (src1.Type != OperandType.ConstantBuffer ||
(src1.Type == OperandType.ConstantBuffer && src2.Type == OperandType.ConstantBuffer) ||
(src2.Type == OperandType.ConstantBuffer && src2.GetCbufSlot() == DriverReservedCb))