Skip to content

acphal: PopMessage returns a full-width Win32 BOOL - #463

Open
DavidM1911 wants to merge 2 commits into
xcl-dev:mainfrom
DavidM1911:acphal-halpop-bool
Open

DavidM1911 wants to merge 2 commits into
xcl-dev:mainfrom
DavidM1911:acphal-halpop-bool

Conversation

@DavidM1911

@DavidM1911 DavidM1911 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of #329 (item 1).

hal_pop returned a 1-byte Rust bool through extern "system": only AL was defined, so a console caller testing all of EAX could observe false as nonzero TRUE and process a stale or uninitialized Message. It now returns i32 1/0, matching how ApuIsVirtualAddressValid already answers a Win32 BOOL in the same file.

What is in it

  • crates/xcl/src/hle/acphal.rs: hal_pop returns i32; the module doc line for PopMessage says BOOL; a test calls the vtable slot through a 32-bit-returning signature and checks empty → 0, submitted command → 1 with the right kind/id.

Tested

  • Windows 11, Ryzen 9 7900X (Radeon iGPU + NVIDIA RTX 3060 Ti 8 GB, driver 610.88), Rust 1.100.0 x86_64-pc-windows-msvc:
    • cargo test -p xcl --lib acphal: 8 passed, 0 failed
    • cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored
  • Regression run on the retail title (1.0.2.1, own copy), RTX 3060 Ti, scripts/smoke.ps1 -Seconds 60, cargo build --release -p xcl:

main a6f5f7a:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14457 MB

this PR's head 6f7f4fe:

xcl-smoke v1
commit: 6f7f4fe738490924306136bf45acc281383f76e6
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1492 (PresentX 1492)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14446 MB

Not tested

  • AMD adapter smoke run; the BOOL-width hazard itself is not reproducible from a unit test (upper EAX bits are undefined by construction) — the test pins the 32-bit call shape instead.

AI use

  • Devin (SWE-2 Flash Medium): implemented the fix and test, ran the suites and smoke runs.

hal_pop returned a 1-byte Rust bool through extern "system": only AL
was defined, so a console caller testing all of EAX could see false as
nonzero. Return i32 1/0 like ApuIsVirtualAddressValid does. Part of
xcl-dev#329.

Assisted-by: Devin (SWE-2 Flash Medium)
@shdann

shdann commented Nov 24, 2026

Copy link
Copy Markdown

At acphal.rs:1143, the empty-channel assertion races the audio frame clock. connect schedules the first frame 2,667 µs ahead. If the test thread is descheduled that long before pop, the empty command queue legitimately produces MSG_AUDIO_FRAME and returns 1. Could you check the zero return through the vtable before connecting, then connect and submit the command to check the one return? Queued messages take priority over frame ticks. Static review at 6f7f4fe, assisted by OpenAI Codex (GPT-6).

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Code audit + NVIDIA RTX 5080 test run on 6f7f4fe738490924306136bf45acc281383f76e6 (part of #329):

Review

Looks clean — returning i32 (1 / 0) from hal_pop fixes the full-width EAX Win32 BOOL ABI contract, and calling through the raw vtable as -> u32 in the test exercises the exact caller ABI.

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), rustc 1.100.0 (MSVC), debug build.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored.
  • New test hle::acphal::tests::hal_pop_returns_a_full_width_bool: passed.
  • SKIPPED GPU tests (2, wave32-only adapter): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.

Not tested

  • Retail title / scripts/smoke.ps1 run (test suite only).
  • AMD / Intel GPUs.

AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.

@DavidM1911

Copy link
Copy Markdown
Contributor Author

Re-ran the regression smoke on the new head 5157b50 (test-only change per review — the empty-pop check now runs before connect, so it cannot race the frame clock). RTX 3060 Ti, GTA VI 1.0.2.1, 60 s:

xcl-smoke v1
commit: 5157b5007f97516fb64224c1143018089b05048e
gpu: NVIDIA GeForce RTX 3060 Ti
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 1502 (PresentX 1502)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14443 MB

cargo test -p xcl --lib acphal: 8 passed, 0 failed.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 5157b5007f97516fb64224c1143018089b05048e on AMD RDNA4. I merged it onto current main e50836b locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 705 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 664 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the acphal tests pass.

Review: Returning a full-width Win32 BOOL from PopMessage matches the ABI the title calls it with. Part of #329 with #468 / #471, which I also ran. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

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.

4 participants