mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 12:59:58 -04:00
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>
This commit is contained in:
@@ -99,8 +99,8 @@ def prepare_sources() -> Path:
|
||||
for junk in list(src.glob("src/*/obj")) + list(src.glob("src/*/bin")):
|
||||
shutil.rmtree(junk)
|
||||
patches = sorted((XLATE / "patches").glob("*.patch"))
|
||||
if len(patches) != 31:
|
||||
sys.exit(f"expected 31 patches, found {len(patches)}")
|
||||
if len(patches) != 32:
|
||||
sys.exit(f"expected 32 patches, found {len(patches)}")
|
||||
for patch in patches:
|
||||
# git apply works outside a repository when given a directory; --check first so a failure names the patch.
|
||||
for extra in (["--check"], []):
|
||||
|
||||
@@ -12,7 +12,9 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
NVN_DIR = ROOT / "refs/MacNativeGames/games/<game>/third_party/d2r_gfx/gfx/nvn"
|
||||
# the game folder of the refs checkout that holds the NVN front end
|
||||
NVN_DIR = next((ROOT / "refs/MacNativeGames/games").glob("*/third_party/d2r_gfx/gfx/nvn"),
|
||||
ROOT / "refs/MacNativeGames/games/third_party/d2r_gfx/gfx/nvn")
|
||||
OUT = ROOT / "runtime/nvn_procs.inc"
|
||||
|
||||
NOT_LOADED = {"nvnDeviceApplyDeferredFinalizes", "nvnQueueAcquireTexture"}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""The shared shader list (PATH in the refs/MacNativeGames checkout; MIT, see THIRD_PARTY_NOTICES.md) as our tools
|
||||
"""The shared shader list (games/<game>/assets/shader_list.tsv in the refs/MacNativeGames checkout; MIT, see THIRD_PARTY_NOTICES.md) as our tools
|
||||
read it: every row of one revision, plus the V rows of every older revision that it dropped.
|
||||
|
||||
The list drops V rows its producer's runtime no longer needs: default variants, which that runtime translates for every
|
||||
@@ -10,7 +10,15 @@ our play meets: at 1340bee the list alone has 134 rows of 1.4.3 shaders, its his
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
PATH = 'games/<game>/assets/shader_list.tsv'
|
||||
TAIL = '/assets/shader_list.tsv' # under the checkout's game folder (see list_path)
|
||||
|
||||
|
||||
def list_path(repo, rev):
|
||||
"""The shader list's path at rev: the one games/<game>/assets/shader_list.tsv of the checkout."""
|
||||
for p in git(repo, 'ls-tree', '-r', '--name-only', rev, '--', 'games').splitlines():
|
||||
if p.endswith(TAIL) and p.count('/') == 3:
|
||||
return p
|
||||
raise SystemExit(f'shader_list.py: no games/*{TAIL} at {rev}')
|
||||
|
||||
|
||||
def git(repo, *args):
|
||||
@@ -22,6 +30,7 @@ def history(repo, rev='origin/HEAD'):
|
||||
if git(repo, 'rev-parse', '--is-shallow-repository').strip() == 'true':
|
||||
# a shallow clone has rev's list only: preparing from it skips most variants and shows only as stutter in play
|
||||
sys.exit(f'{repo} is a shallow clone without the shader list\'s history; run tools/fetch_refs.sh')
|
||||
PATH = list_path(repo, rev)
|
||||
lines = git(repo, 'show', f'{rev}:{PATH}').splitlines()
|
||||
seen = set(lines)
|
||||
for h in git(repo, 'log', '--format=%H', rev, '--', PATH).split()[1:]:
|
||||
|
||||
10
tools/vendor/macnativegames/README.md
vendored
10
tools/vendor/macnativegames/README.md
vendored
@@ -4,11 +4,11 @@ Unmodified copies from https://github.com/ly05010419/MacNativeGames at `b75be8cf
|
||||
|
||||
| File | Upstream path |
|
||||
|---|---|
|
||||
| `extract_exefs.py` | `games/<game>/scripts/extract_exefs.py` |
|
||||
| `extract_romfs.py` | `games/<game>/scripts/extract_romfs.py` |
|
||||
| `extract_update_romfs.py` | `games/<game>/scripts/extract_update_romfs.py` |
|
||||
| `extract_shared_fonts.py` | `games/<game>/scripts/extract_shared_fonts.py` |
|
||||
| `extract_exefs.py` | `scripts/extract_exefs.py` |
|
||||
| `extract_romfs.py` | `scripts/extract_romfs.py` |
|
||||
| `extract_update_romfs.py` | `scripts/extract_update_romfs.py` |
|
||||
| `extract_shared_fonts.py` | `scripts/extract_shared_fonts.py` |
|
||||
|
||||
`tools/data/expected-v*.json` come from `games/<game>/assets/` at the same commit.
|
||||
`tools/data/expected-v*.json` come from `assets/` at the same commit.
|
||||
|
||||
Keep these files byte-identical to upstream so they can be updated by copying. Windows-specific behaviour lives in `tools/extract.py` and `tools/extract_fonts.py`.
|
||||
|
||||
2
tools/vendor/macnativegames/extract_exefs.py
vendored
2
tools/vendor/macnativegames/extract_exefs.py
vendored
@@ -174,7 +174,7 @@ def program_nca(records, update=False):
|
||||
require(len(programs) == 1, 'Expected one base Program NCA; updates, DLC and combined packages are unsupported')
|
||||
record, hdr = programs[0]
|
||||
require(record['title_id'] == '0100F2C0115B6000',
|
||||
'Expected Ocarina of Time base game 1.0.0; updates, DLC and other games are unsupported')
|
||||
'Expected the supported base game 1.0.0; updates, DLC and other games are unsupported')
|
||||
return record, hdr
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Ryujinx.Common
|
||||
"01007ef00011e000", // The Legend of Zelda: Breath of the Wild
|
||||
"01006bb00c6f0000", // The Legend of Zelda: Link's Awakening
|
||||
"01002da013484000", // The Legend of Zelda: Skyward Sword HD
|
||||
"0100f2c0115b6000", // The Legend of Zelda: Ocarina of Time
|
||||
"0100f2c0115b6000",
|
||||
"01008cf01baac000", // The Legend of Zelda: Echoes of Wisdom
|
||||
|
||||
//Luigi Franchise
|
||||
|
||||
@@ -2306,6 +2306,18 @@ static class AmpereLowering
|
||||
// (the uniform switches: UISETP.GT P0, URx, bound; USEL URx, URx, bound, P0)
|
||||
uint mop = mn >= 0 ? _code[mn].Bits(0, 12) : 0, mb = mop & 0x7f;
|
||||
if (mn >= 0 && (mb == 0x17 || mb == 0x07) && _code[mn].Bits(9, 3) == 4) count = (int)_code[mn].W1 + 1;
|
||||
// the register form, the bound in a register a MOV (UMOV) of an immediate set before it: SEL Rx, Rx, Rb
|
||||
// under ISETP Rx, Rb, or IMNMX Rx, Rx, Rb; either source may be the bound, the other is the index
|
||||
else if (mn >= 0 && (mb == 0x17 || mb == 0x07) && _code[mn].Bits(9, 3) == 1)
|
||||
foreach (uint r in new[] { _code[mn].Bits(32, 8), _code[mn].Bits(24, 8) })
|
||||
{
|
||||
int mv = r == RZ ? -1 : Writer(mn - 1, r, uniform);
|
||||
if (mv >= 0 && _code[mv].Bits(0, 12) == (uniform ? 0x882u : 0x802u) && _code[mv].Bits(12, 4) == 7)
|
||||
{
|
||||
count = (int)_code[mv].W1 + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count <= 0 || count > 1024) throw Fail("BRX jump table without a bound");
|
||||
var t = new List<uint>();
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
+ // NX2NAVI: every render target with any component enabled takes four registers (the colour outputs above), then
|
||||
+ // the sample mask when written, then one register is skipped. The component count was used, which matches
|
||||
+ // only when every enabled target writes all four: Ocarina's depth downsample (targets 0 and 2, .x each) read
|
||||
+ // its depth from R3, never written, and wrote 0 (all its fog then sat at the near plane). As the hardware's
|
||||
+ // ExitFragment counts.
|
||||
+ // its depth from R3, never written, and wrote 0 (all its fog then sat at the near plane). This
|
||||
+ // counts the way the hardware's fragment exit does.
|
||||
+ int targets = 0;
|
||||
+
|
||||
+ for (int rtIndex = 0; rtIndex < 8; rtIndex++)
|
||||
|
||||
28
tools/xlate/patches/0033-cas-loop-expected-value.patch
Normal file
28
tools/xlate/patches/0033-cas-loop-expected-value.patch
Normal file
@@ -0,0 +1,28 @@
|
||||
--- 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;
|
||||
Reference in New Issue
Block a user