Skip to content

acphal: match the APU virtual address lookup ABI - #939

Open
Babyhamsta wants to merge 1 commit into
xcl-dev:mainfrom
Babyhamsta:fix/acp-virtual-address-abi
Open

Babyhamsta wants to merge 1 commit into
xcl-dev:mainfrom
Babyhamsta:fix/acp-virtual-address-abi

Conversation

@Babyhamsta

Copy link
Copy Markdown
Contributor

Correct the ACP virtual-address lookup ABI. Ordinary callers pass one virtual address and consume the returned 32-bit APU token. The old implementation expected an output pointer, an address and a length.

What is in it

  • In crates/xcl/src/hle/acphal.rs, resolve allocation interiors and return zero for unregistered addresses. Keep the bounded span helper internal and retain full-width 0/1 validity with alignment checking.
  • Add a test that checks the published export pointer against the caller's ABI, round-trips an interior token, and verifies that lookup leaves caller bytes unchanged. The range, overflow and rollback tests from hle/acphal: fix APU range overflow/overlap, SHAPE rollback, and XApuConnect OOM #90 remain covered.

Tested

  • Windows 11 build 26300, GeForce RTX 4070 driver 621.35, Intel Core i7-13700K, rustc 1.94.1. Debug workspace tests and release smoke builds.
  • cargo build --offline --locked --workspace completed. cargo test --offline --locked --workspace -- --test-threads=4 --show-output reported 717 passed, 0 failed, 41 ignored. Two reported passes explicitly skipped for no wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • The focused ACP suite passed 8 tests. The typed caller fixture failed to compile against the old mapper signature.

Regression run
Both clean builds used the upstream smoke script for 60 seconds offline, with fresh profiles and separate cold DXIL caches at 1920×1080.

Main

xcl-smoke v1
commit: 077ce40c3e371cf3df8c57985b1cc6b1db39e75a
gpu: NVIDIA GeForce RTX 4070
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1027 (PresentX 1027)
presents per 2 s (last 3): 47 49 49
device removals: 0
crashes: 0
peak commit: 15334 MB

This PR

xcl-smoke v1
commit: 37e2dcad707cdecc6ebee67963cc8097de760566
gpu: NVIDIA GeForce RTX 4070
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 872 (PresentX 872)
presents per 2 s (last 3): 34 38 43
device removals: 0
crashes: 0
peak commit: 15333 MB

Not tested

  • AMD, Intel GPU or Wine. The 60-second smoke is a startup regression check. The synthetic export test exercises the mapper directly.

AI use

  • Codex (GPT-6) wrote the implementation and fixture and ran and reviewed the checks.

Return the APU token for a registered virtual address without writing caller data. Test the published export pointer, interior addresses, and alignment while preserving existing range allocation and rollback checks.

Assisted-by: Codex (GPT-6)
@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean main@beaa245 (713 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
714 passed; 0 failed; 41 ignored   (exit 0)

One more passing test than main: the APU virtual-address lookup ABI match is covered and green.

Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 37e2dca onto main 9aec53d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 713 passed, 12 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). acphal APU-lookup ABI tests green; see flake footnote.

Footnote: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask failed once in-lane but passes 2/2 in isolation on the same merge, and current main passes the same isolated runs - ordering flake on this rig, not attributed to this PR.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

  • cargo test -p xcl --lib acphal: 8 passed, 0 failed — including apu_mapper_exports_lookup_interior_bytes_without_writing (the new ABI coverage) plus the DSP connect/decoder tests.
  • The ApuMapVirtualAddress(va) -> apu signature change and alignment-aware find_free_range look consistent with the doc comment update; mapped_address now requires full-span coverage instead of partial overlap, which is the safer semantic.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Tested

  • Exact PR head 37e2dcad707cdecc6ebee67963cc8097de760566 on Windows 11 build 26200, Ryzen 9 5980HX, Rust 1.99.0 MSVC. The ACP mapping suite is CPU and memory code; it did not exercise the RX 6800M GPU.
  • cargo test --locked -p xcl --lib -j 2 hle::acphal:: -- --test-threads=1 --show-output: 8 passed, 0 failed, 0 ignored, no explicit skips. The new export ABI test passed, including interior address lookup, unchanged caller bytes, alignment checks, and lookup after free.
  • cargo build --locked --workspace -j 2: passed.

Not tested

  • A title calling the ACP ABI, the full workspace suite, or another operating system. The synthetic tests check the published export pointer and function behavior on this machine.

AI use

OpenAI Codex (GPT-6, exact variant not exposed in this session) reviewed the exact diff, ran the ACP suite and workspace build, checked the logs, and drafted this report.

@S1m0ne1997

Copy link
Copy Markdown

Test report for 37e2dcad707cdecc6ebee67963cc8097de760566 (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 717 passed, 0 failed, 41 ignored.
  • SKIPPED (2): gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run (retail title, scripts/smoke.ps1 -Seconds 60, release; main built from the commit in its block, this PR from its head, no uncommitted changes)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: 37e2dcad707cdecc6ebee67963cc8097de760566
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1626 (PresentX 1626)
presents per 2 s (last 3): 59 44 51
device removals: 0
crashes: 0
peak commit: 17641 MB

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent AMD report for 37e2dcad707cdecc6ebee67963cc8097de760566.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, rustc 1.100.0, debug profile for tests, release for smoke. Tested at the exact PR head (not a local merge onto main). This head's merge base is 077ce40c (24 Nov), older than current main, so I tested the PR head as is, not merged onto current main.
  • cargo test -p xcl --lib acphal: 8 passed, 0 failed (includes the new apu_mapper_exports_lookup_interior_bytes_without_writing).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 717 passed, 0 failed, 41 ignored; no SKIPPED lines.
  • scripts/smoke.ps1 -Seconds 60 on a real title, release build, PR head: 1502 frames, last presents per 2 s 60 60 60, peak commit 17737 MB, no device removal, no crash, exit 0x0. Reference run of current main 06c9f550 on the same title: 1531 frames, peak commit 17752 MB. The PR's script predates -Title, so I paste the numbers rather than the block (it would print the title's folder name).

Not tested

A title that calls the APU mapper ABI, a rebase onto current main, other adapters.

AI use

Claude Code (Claude Sonnet 5.5) ran the tests and the smoke runs and wrote this report. No game files, dumps or shader names are included.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 37e2dca

Overlap: #1470 also makes ApuAlloc's APU address honour the requested alignment (find_free_range aligns the candidate and the skip-to address). This PR does the same and also changes ApuMapVirtualAddress to (va) -> apu and ApuIsVirtualAddressValid to (va, alignment). #1470 does neither, so its change is contained in this one.
The old 3-argument ApuMapVirtualAddress treated the title's VA as an out pointer and wrote the APU address into the title's memory. The new export returns 0 for memory that ApuAlloc did not allocate. map_virtual_span is #[allow(dead_code)] and only the tests use it. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@github-actions github-actions Bot removed the stale No activity for 3 days; closed 4 days later unless something happens label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants