mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 06:59:57 -04:00
A census of every NVN2 program in the RomFS shader packages found 31 that failed in the SM86 lowering, none met in play yet. Each form was checked with nvdisasm. MUFU.F16 (the upscaler's colour decode: a half lane widened, the F32 function, rounded back to a half) in 11 upscaler programs. ATOMS.POPC.INC with the X16 index stride, the luminance histograms' three counters per 16-byte bin, in 8 programs. LDG and STG .STRONG.GPU, read as plain accesses, in 2. TLD.LZ.MS, a 2x MSAA resolve that reads samples 0 and 1, in 3. ATOMG.CAS for the foliage programs' slot claims in 4, through Maxwell ATOM.CAS, which the translator only logged as not implemented: patch 0037 emits a global compare-and-swap for it. SUATOM.D on a 1D image, the post-effect append counters, in 2. ISBERD.O, a task program reading back its own payload, in 1. HighestGpr also counts the registers these forms read beyond the base fields. All 31 now pass spirv-val, and the other 42,146 programs give SPIR-V byte-identical to the previous translator. tensor_lowering_check passes 29 of 29, with four new MUFU.F16 cases checked against a model of the lowering (the warp emulator gains MUFU); a wrong half select fails all four. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.9 KiB
Diff
44 lines
1.9 KiB
Diff
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmit.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmit.cs
|
|
@@ -5,13 +5,6 @@
|
|
{
|
|
static partial class InstEmit
|
|
{
|
|
- public static void AtomCas(EmitterContext context)
|
|
- {
|
|
- context.GetOp<InstAtomCas>();
|
|
-
|
|
- context.TranslatorContext.GpuAccessor.Log("Shader instruction AtomCas is not implemented.");
|
|
- }
|
|
-
|
|
public static void AtomsCas(EmitterContext context)
|
|
{
|
|
context.GetOp<InstAtomsCas>();
|
|
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
|
|
@@ -24,6 +24,24 @@
|
|
context.Copy(GetDest(op.Dest), res);
|
|
}
|
|
|
|
+ // NX2NAVI: ATOM.E.CAS Rd, [Ra], Rb, Rb + 1 (32-bit): the word at the address is replaced by Rb + 1 where it
|
|
+ // equals Rb, and Rd gets its old value. tools/xlate/AmpereLowering.cs AtomgCas lowers SM86 ATOMG.CAS to it.
|
|
+ // BcRz 1 and 2 read the compare and the new value as zero.
|
|
+ public static void AtomCas(EmitterContext context)
|
|
+ {
|
|
+ InstAtomCas op = context.GetOp<InstAtomCas>();
|
|
+
|
|
+ (Operand addrLow, Operand addrHigh) = Get40BitsAddress(context, new Register(op.SrcA, RegisterType.Gpr), op.E, 0);
|
|
+
|
|
+ bool rz = op.SrcB == RegisterConsts.RegisterZeroIndex;
|
|
+ Operand compare = rz || op.BcRz == 1 ? Const(0) : GetSrcReg(context, op.SrcB);
|
|
+ Operand value = rz || op.BcRz == 2 ? Const(0) : GetSrcReg(context, op.SrcB + 1);
|
|
+
|
|
+ Operand res = context.AtomicCompareAndSwap(StorageKind.GlobalMemory, addrLow, addrHigh, compare, value);
|
|
+
|
|
+ context.Copy(GetDest(op.Dest), res);
|
|
+ }
|
|
+
|
|
public static void Atoms(EmitterContext context)
|
|
{
|
|
if (context.TranslatorContext.Definitions.Stage != ShaderStage.Compute)
|