hle/acphal: track cumulative XApu enqueued and dequeued totals #2031
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2041"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T01:40:53Z.
What is in it
Track cumulative XApu enqueued and dequeued totals separately from the pending result queue length (
XCL-BT-043, part of #1489).Part of #1489
crates/xcl/src/hle/acphal.rs,XApuEnqueueCommandwroteq.len() as u32(current pending queue length) into its optionalcountout-parameter instead of the cumulative total of commands enqueued on the connection, andXApuGetResultCountwroteq.len() as u32(the same pending queue length it returns) into its optionaltotalout-parameter instead of the cumulative total of results dequeued viaXApuDequeueResult. After enqueueing 2 commands and dequeuing 2 results,XApuGetResultCount(h, &mut total)returned0with*total = 0instead of2, and enqueueing a 3rd command wrote*count = 1instead of3.queue: VecDeque<XApuResult>,enqueued: u32,dequeued: u32) inXApuResultsunderXApu.results: Mutex<XApuResults>so queue mutations and totals update atomically under one lock:XApuEnqueueCommandpushes the result, incrementsst.enqueuedviawrapping_add(1), and writesst.enqueuedto*countwhen non-null.XApuDequeueResultincrementsst.dequeuedviawrapping_add(1)only whenpop_front()returnsSome(r)(leavingdequeuedunchanged onXAPU_NO_RESULTS), releasing the lock beforewrite_unaligned.XApuGetResultCountreads(st.queue.len() as u32, st.dequeued)under the lock, writesdequeuedto*totalwhen non-null, and returnspending.xapu_enqueue_and_result_count_report_cumulative_totalsandxapu_cumulative_counters_wrap_at_u32_maxincrates/xcl/src/hle/acphal.rscovering cumulative counts across enqueue/dequeue cycles, empty dequeues (XAPU_NO_RESULTS), null optional out-parameters / null handle safety, andu32::MAXwraparound.Tested
621.14, wave32), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust1.100.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5(01b62ad4).origin/main656c0e8with new test added, debug):cargo test -p xcl --lib hle::acphal::tests -- --nocapture->7 passed; 1 failed(xapu_enqueue_and_result_count_report_cumulative_totalspanicked withleft: 2, right: 0when checking*totalafter 2 enqueues and 0 dequeues).b591ccc7):cargo test --release -p xcl --lib hle::acphal::tests -- --nocapture->10 passed; 0 failed; 0 ignored.b591ccc7):cargo build --release --workspace+cargo test --release --workspace -- --test-threads=4 --nocapture->1104 passed, 0 failed, 46 ignoredacross 20 test binaries.SKIPPEDlines (26 total, all pre-existing on this wave32 Windows host without Graphics Tools / Developer Mode / heap windows):no wave64skips (4ingpu::recomp::lower::tests,13ingpu::recomp::lower_dxil::tests,2ingpu::recomp::tests).per-lane form: refusedskips ingpu::recomp::lower_dxil::tests(f16 arithmetic,f16 packed,f32 conversions).test_title_draws_with_a_root_signature_under_the_debug_layer: nod3d12SDKLayers.dll;uploads_start_from_each_subresources_state:0x887A002D).shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable driver cache without Windows Developer Mode.heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.Regression run
Paired 60 s retail title runs with
scripts/smoke.ps1(release build, same title, clean working tree) onorigin/main(8f5fca5b) and this PR (b591ccc7):main:this PR:
Not tested
*countor*totalout-parameters ofXApuEnqueueCommand/XApuGetResultCount; the paired smoke run is a regression check only.AI use
Google Antigravity (Gemini 4 Neon) wrote the fix, unit tests, and this PR description; all builds, tests, and paired retail smoke runs were executed locally on the hardware listed above.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:43:47Z.
Code review on
b591ccc:XApuResults(queue,enqueued: u32,dequeued: u32) incrates/xcl/src/hle/acphal.rscleanly separates cumulative enqueue/dequeue counters from the pendingqueue.len()returned byXApuGetResultCount.XApuEnqueueCommandwrites cumulativewrapping_add(1)enqueued,XApuDequeueResultincrementsdequeuedonly onSome(r), andXApuGetResultCountreturnspendingwhile writing cumulativedequeuedto*total.xapu_enqueue_and_result_count_report_cumulative_totalsandxapu_cumulative_counters_wrap_at_u32_max) cover empty dequeue (XAPU_NO_RESULTS), null out-pointers/handles, andu32::MAXwraparound cleanly.PR descriptionis green andBuild and test (Windows, no GPU)is running.Remaining before merge:
Build and testfinishing green plus dual-vendor (AMD + NVIDIA) verification onb591ccc.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:26:00Z.
PR #2041 verification
Tested live PR head
b591ccc73547b072cdf854ebf8e56dfdb0d58b1dfromrefs/pull/2041/headin a clean detached worktree. Fetchedorigin/mainwascbc296ab65a2661a61e3e2da109134bcd5319f60.git merge-tree --write-tree origin/main HEADexited 0 and produced treeef3ee3f8d9a7410d03ecd6af81afe8b01de9a8f5.What is in it
crates/xcl/src/hle/acphal.rstracks cumulative XApu enqueued and dequeued totals alongside the pending result count. The new tests exercise FIFO order, empty dequeues, optional pointers, and counter wraparound.Tested
DoublePrecisionFloatShaderOps=0). DXC/DXIL 1.9.2609.5,rustc 1.100.0 (0ef1bc386 2026-11-09). Unoptimized Cargo dev/test profiles with debug info and incremental compilation disabled.cargo build --workspaceandcargo test --workspace --no-runsucceeded outside the GPU lock.cargo test -p xcl --lib acphal -- --show-outputoutside the GPU lock reported 10 passed, 0 failed, and 0 ignored. Both new XApu tests also passed in the full suite.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputran once under the shared Arc lock and exited 101. Across 20 target summaries, libtest reported 1077 passed, 27 failed, 46 ignored. The log also records 26 skip notices across 16 tests, including partial skips that libtest can mark as passed. The skipped paths provide no coverage.CreateComputePipelineStatereturning0x80070057and mismatches in fused F32 arithmetic, implicit-LOD sampling, an F16 high-half result, and pixel-wave reduction. Thee2etarget had one failure intest_title_runs_and_game_folder_is_untouched. TheRSSetDepthBiasXdraw produced a blue pixel where the test expected green.Skip notices from the full workspace log
Full log
L:\XclTooling\neon-slot-5\tmp\pr2041-suite.log.Not tested
origin/mainis unverified.XCL_SAMPLE_*unset), and other GPU adapters.AI use
Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against
pr2041-suite.logand published this report.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T04:28:42Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T21:01:17Z.
Tested head
b591ccc73547b072cdf854ebf8e56dfdb0d58b1d(merge-base8f5fca5bb9ad6e695093d75294ad2cec023bba60) on Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug, CPU only (no GPU opened).cargo test -p xcl --lib acphal:: -- --test-threads=1: head 10 passed, 0 failed, 0 ignored; merge-base 8 passed, 0 failed. The 2 extra on head arexapu_enqueue_and_result_count_report_cumulative_totalsandxapu_cumulative_counters_wrap_at_u32_max. The new tests live inline inacphal.rs, so they cannot be run against base code.Not tested: the full suite, GPU, retail title. AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:12:13Z.
merge-check claim
head:
b591ccc735Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:29:47Z.
merge-check
base:
b10cc4c6head:
b591ccc735merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2607 passed, 2 failed, 49 ignored on the merge result with main
b10cc4c6(27 SKIPPED lines). The two failures are uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom and mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment ("Map gave A, wanted B" for a 64 MB segment): the address-space-hungry tests that #3187 moves into a child process, in a file this PR does not touch. The four other trees of this batch on the same base had 0 failures, so I count them as that known instability and not against this PR.review: the mechanics are sound (one mutex, wrapping counters, counters per handle so a reconnect starts at zero, and it builds with main's newer audio code). What holds it back is meaning, not code: it changes what a title reads back from two calls, from "results waiting" to "total ever enqueued" and from a count to "total ever dequeued", and the only source for that meaning is a static audit that cites another project's code. Nobody has shown a title's calls (a trace) that need the cumulative meaning, and a title that uses the returned count to decide how many results to take would behave differently. The reviews in the thread checked the mechanics only.
performance: none.
verdict: not yet: one trace of a title's use of these out-parameters (or another first-hand source) that confirms the cumulative meaning.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-30T20:30:43Z.
merge-check claim
head:
b591ccc735Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T20:33:15Z.
merge-check claim
head:
b591ccc735Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T20:38:55Z.
merge-check claim
head:
b591ccc735Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-30T20:39:34Z.
merge-check
base:
ff0c364b3dhead:
b591ccc735merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored (25 SKIPPED lines: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache); both new acphal tests passed (xapu_enqueue_and_result_count_report_cumulative_totals, xapu_cumulative_counters_wrap_at_u32_max); failing: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (gpu_two_pass_cache_e2e.rs:584, releasing the title PSOs releases their two-pass state: left 1, right 0) — fails on the base
ff0c364balone too (1 passed, 3 failed across 4 runs with the same assertion), unrelated to acphal.rsreview: Code mechanics, locking, wrapping arithmetic, null-pointer handling, scope (+119/-13 in crates/xcl/src/hle/acphal.rs), and unit tests are clean and match the PR description; no duplicate PR found in open/merged PRs or #1607. However, agreeing with the earlier check, the behavioral change to the two optional out-parameters (XApuEnqueueCommand's *count from pending queue length to cumulative enqueued total, and XApuGetResultCount's *total from pending queue length to cumulative dequeued total) rests only on a static audit in #1489 (XCL-BT-043) referencing another project's code, with no title trace or first-hand verification confirming those semantics.
performance: Negligible (reasoned): adds two u32 counters (+8 B per XApu handle) and one wrapping_add(1) under the existing results mutex on enqueue/dequeue.
verdict: not yet: needs first-hand confirmation (e.g. a title trace or hardware/runtime evidence) that XApuEnqueueCommand's count and XApuGetResultCount's total out-parameters are cumulative enqueued/dequeued totals rather than pending queue length.
hardware / tool and model: NVIDIA GeForce RTX 5090 (driver 621.01 / 32.0.16.2101), AMD Ryzen 9 9950X3D, Windows 11 Pro build 26300, Rust 1.100.0 (debug); T3 Code (Antigravity), Gemini 4 Neon (Medium)
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T22:29:00Z.
merge-check
base:
ff0c364b3dhead:
b591ccc735merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored; 29 SKIPPED lines; failing: test_title_runs_and_game_folder_is_untouched (also fails on the base alone, verified by running it there)
review: automated check: diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no line-by-line review and no duplicate search performed.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:14:36Z.
Triage (#1607) – head
b591cccNo open or merged PR makes the same change: the other #1489 PRs touch unrelated code, and the other open XApu PRs (#1715, #1283, #2700) do not change the enqueue/result counters.
XApuEnqueueCommand/XApuGetResultCountinhle/acphal.rson main still report the queue length.No problems found in the diff. The counters and queue share one lock, and an empty dequeue does not count. The cumulative-total semantics come from XCL-BT-043 (VIctory's apu.rs), not from a console measurement.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.