Stubs: record R8/R9 argument registers of stub calls in the report #2712
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2722"
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 amazedturnip on 2026-11-26T08:29:37Z.
Record the 3rd/4th Win64 argument registers (R8/R9) at stub-thunk call time and surface them in report.json as first_args/last_args per called stub, to diagnose which console slots actually receive which values. Args are kept in a side table keyed by the StubInfo pointer so no StubInfo fields or thunk bytes change (avoids overlap with open #936/#1155). Tests pin first/last/call-count and serde on/off; verified on the AMD Radeon iGPU retail build.
What is in it
crates/xcl/src/stubs.rs:stub_reportnow takes(r8, r9)and records first/last R8/R9 per stub in a side-table keyed by the StubInfo pointer (no StubInfo field changes, no thunk-bytes changes).crates/xcl/src/report.rs:StubCallgains optionalfirst_args/last_args(hex, serde default + skip_serializing_if empty);build()emits them fromstub_args.crates/xcl/src/stubs_args_tests.rs(new sibling test module): thunk call records first/last R8/R9 and call count; arglessrecord_callleaves the side table empty; StubCall with args serializes them, without args omits them.Tested
AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64),XCL_ADAPTER=radeon):cargo test --workspace -- --test-threads=2— 1312 passed, 1 failed, 27 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1)Regression run
main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T08:33:41Z.
Review: COMMENTED
I found a concurrency issue in the new R8/R9 diagnostics at head
77158b0(baseb49be18). This is a source-derived review; I did not run a native concurrent title test.record_call_with_argsassigns the call ordinal withfetch_addand storesfirst_callerbefore taking theARGSmutex. If call A gets ordinal 0 and pauses during first-call logging, call B can get ordinal 1 and insert B's arguments into the empty side table. A then acquires the mutex and overwrites the last arguments. After both calls, the report can sayfirst_caller=A,first_args=B, andlast_args=A. Neither argument pair matches the ordinal implied by its label.Could the side table record the first/last ordinal alongside the arguments and update each field only when the incoming ordinal is earlier/later, or otherwise serialize ordinal assignment with the table update? A two-thread fixture that forces the first caller to enter the table second would cover the first and last fields. Logging and hooks can remain outside the mutex.
AI assistance: GPT-6.2 Sol identified the interleaving; GPT-6.2 Astra independently checked the exact-head source and wording.
Imported from ivall/xcl. Originally posted by amazedturnip on 2026-11-26T09:54:55Z.
Fixed per the review: the ARGS side table now records (first_ord, last_ord, first_r8, first_r9, last_r8, last_r9) per info and updates each field only when the incoming ordinal is strictly earlier/later. Ordinal assignment still happens via fetch_add before the ARGS mutex (logging/hooks remain outside), but no field is overwritten by an out-of-order caller now. A two-thread fixture (
ordinal_first_caller_arriving_late_still_records_as_first_and_last) forces caller A (ordinal 0) into the table second via a test-only pause hook; the test asserts A's args land as first_args and B's as last_args. All stubs tests pass (9/9).Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T11:49:31Z.
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2722 at
315e3f85e2eb51a490643560fca3e91c52d3c6be(exact parentorigin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)Targeted Win11 / RTX 4060 release unit tests (
315e3f85)cargo test --release -p xcl --lib stubs_args_tests:: -- --nocapture: 4 passed, 0 failed, 0 ignored (0.00 s, exit0), coveringordinal_first_caller_arriving_late_still_records_as_first_and_last,thunk_records_first_and_last_r8_r9_args,record_call_without_args_leaves_side_table_empty, andstub_call_serializes_args_only_when_present.cargo test --release -p xcl --lib stubs_args_tests:: -- --test-threads=4(3 consecutive parallel stress passes): 4 passed, 0 failed, 0 ignored × 3 (0.00 seach, exit0).cargo test --release -p xcl --lib stubs:: -- --test-threads=4: 7 passed, 0 failed, 0 ignored (0.02 s,0skipped, exit0).cargo test --release -p xcl --lib report:: -- --test-threads=4: 1 passed, 0 failed, 0 ignored (0.10 s,0skipped, exit0).Observations
ARGSside-table ordering fix (ordinal_first_caller_arriving_late_still_records_as_first_and_last) and allstubs_args_tests::,stubs::, andreport::tests passed cleanly in--releaseon native Windows 1126200, including 3 consecutive parallel--test-threads=4stress runs with zero flake.report.jsonverification on the 60 s retail smoke:called_stubsrecorded9entries total, with1thunk-captured entry cleanly serializing bothfirst_argsandlast_args(two hex R8/R9 values each) and the other8entries omitting both fields as expected.exit: 0x0,1545frames shown,60 60 60steady-state presents per 2 s,0device removals,0crashes,14014 MBpeak commit vs parentb49be183's14018 MB/1518frames).Paired 60 s RTX 4060 smoke (
b49be183vs315e3f85)Parent
origin/main(b49be183):PR #2722 head (
315e3f85):Limits of coverage
315e3f85(only targetedstubs_args_tests::,stubs::, andreport::release tests plus paired quiet 60 s smoke).26200) / x86-64 RTX 4060 only; no Wine/Linux run on this host.AI use
Ran the targeted release unit tests, paired quiet 60 s smoke runs, and
report.jsonfield check with assistance from Google Antigravity (Gemini 4 Neon); all test counts,report.jsonstatistics, and smoke blocks were taken directly fromcargo test,report.json, andscripts/smoke.ps1outputs.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-30T00:49:42Z.
NVIDIA and AMD full-suite run, to go with the reports above by Decodere, since none of them covers AMD. Tested exact head
315e3f85(on its baseb49be18).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::bridged_dpp_agrees_with_hlsl_on_the_gpu --skip hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap --skip gpu::dxil::fuzz_tests: 1427 passed, 0 failed, 45 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.ordinal_first_caller_arriving_late_still_records_as_first_and_last,thunk_records_first_and_last_r8_r9_args,record_call_without_args_leaves_side_table_empty,stub_call_serializes_args_only_when_present.XCL_ADAPTER=radeon),cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 --skip two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs: 1438 passed, 0 failed, 47 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main53e85fb1too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh,bridged_dpp_agrees_with_hlsl_on_the_gpu(no wave64 on this card) andtwo_pass_binds_set_the_shared_view_heap(heap windows are opt-in,XCL_HEAP_WINDOWS=1) fail the same way;gpu::dxil::fuzz_testsstays skipped as in earlier runs (seeds 70, 545, 1019 and 1507 failedCreateComputePipelineStatewithE_OUTOFMEMORYon this card; they passed on this main's baseline). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6).two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsfails on main too, since #2959 (#3441). (Edited: this line first named the wrong merge.) The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T17:32:28Z.
merge-check claim
head:
315e3f85e2Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T17:35:26Z.
merge-check claim
head:
315e3f85e2Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T17:37:50Z.
merge-check
base:
9dfbe3ea66head:
315e3f85e2merge: clean (trial merge b0147c63cae4de8bd882ebd89340fbb7e1371533; git diff --check clean; +188/-7 in crates/xcl/src/report.rs, stubs.rs, new stubs_args_tests.rs)
build: cargo build --workspace -> ok (pre-existing warnings only, none from the PR's lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2889 passed, 1 failed, 51 ignored (base + 4 new tests); SKIPPED: 27, the standard set for this card (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"). Failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 — pre-existing on this machine, identical on base
9dfbe3ea. All four new tests pass here, including the forced-race ordinal fixture.review: read the whole diff and the surrounding code. The change records the R8/R9 registers (3rd/4th Win64 arguments) of each stub call — first and most recent per stub — into report.json as first_args / last_args, so a stubbed function's callers can be identified by the objects they pass. I checked the ABI: the generated thunk (stubs.rs:164-174) only touches RCX/RDX/RAX/RSP before call rax, so R8/R9 at stub_report entry are the guest call's original 3rd/4th arguments, and its 0x28 shadow reservation already covers four arguments; the thunk machine code itself is unchanged, and the only call site that needs the new parameters is the thunk itself (the Rust-side record_call path for D3D12.X guards and real.rs:11744 is untouched and leaves the side table empty, so the report fields are omitted there). The first/last labeling uses the fetch_add ordinal taken before the table update, with strictly-earlier/later updates under the ARGS mutex, so a caller that grabs ordinal 0 but enters the table later still records its args as first; the test-only pause hook (consumed on use, None in release) forces exactly that race in a two-thread fixture, and the first-call log and hook run outside the mutex. The serde fields are additive with default + skip_serializing_if, so old report.json files still deserialize and unthunked stubs serialize as before; only report.rs:240 constructs StubCall. I verified all four new tests' assertions by hand (thunk first/last capture, the late-ordinal fixture's 0x0A01/0x0B01 expectations, the empty-side-table case, and the serialize-only-when-present JSON check). Thread: Decodere's RTX 4060 release run passed the targeted tests (with three consecutive parallel stress passes) and a paired 60 s retail xcl-smoke (1545 vs 1518 frames, no crashes, peak commit 14014 vs 14018 MB) with a live report.json check (1 thunk entry carrying first_args/last_args, the other 8 stub entries omitting both); futurepro62's full workspace runs on an RTX 5070 Ti (1427/0/45) and the RDNA2 iGPU of a 9800X3D (1438/0/47) pass with only that rig's known skips. No duplicates; only the three listed files, no unsafe added beyond the pre-existing transmute of the hook pointer, no new dependencies, no stop-criteria files.
performance: none; one extra mutex section per stub call for thunks, the first-call log and hook stay outside it.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T17:43:44Z.
merge-check
base:
9dfbe3ea66head:
315e3f85e2merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2888 passed, 2 failed, 51 ignored; 29 SKIPPED lines; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, test_title_runs_and_game_folder_is_untouched — both fail on the base alone (each re-run on
9dfbe3eaand reported FAILED there), so neither is this PR'sreview: one logical change in 3 files (+188/-7), well inside the size target. The subtle part is the race between ordinal and arrival: a caller can take ordinal 0 and reach the side table after a caller that took ordinal 1, so "first" cannot mean "first to insert". This handles it correctly —
record_call_with_argstakes the ordinal first, then holds the side-table mutex across the update and replaces first/last by ordinal comparison — and the new test forces exactly that interleaving through a#[cfg(test)]-only hook, so it cannot fire in a release build. Storing args in a side table keyed by the StubInfo pointer rather than adding fields keeps the thunk bytes and StubInfo layout untouched, which is what lets it avoid the overlap with #936/#1155 the description mentions.report.jsonstays backward compatible:first_args/last_argsareOption<String>withserde(default, skip_serializing_if), so stubs with no recorded args serialize exactly as before. The four-argumentstub_reportmatches Win64 (RCX/RDX/R8/R9), so R8/R9 are the 3rd/4th console arguments without any thunk change — consistent with the description. Tests cover first/last/call-count, the argless path leaving the table empty, and serde with and without args. No duplicate: searched open and merged PRs for the same subject and only this PR matches. Nothing to stop it.performance: one global mutex acquisition plus a map lookup per stub call, in release builds, whether or not a report is ever built. Stub calls are console API calls rather than per-draw work, so this is very likely negligible — but it is on a shared path, and if a title turns out to be stub-heavy under many threads it would show up as contention. An env-gate would remove even that doubt; I would not hold the PR for it.
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-01T08:48:33Z.
Triage (#1607) – head
315e3f8No open or merged PR records stub arguments in the report. The thunk in
stubs.rsonly setsrcx/rdxbefore callingstub_report, sor8/r9still hold the title's 3rd/4th arguments, as the PR relies on.One cost to check:
record_call_with_argsnow takes the globalARGSmutex and does aHashMaplookup on every stub call. Before, a call was only an atomicfetch_add. That may matter for stubs a title calls many times per frame.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T21:42:29Z.
merge-check
base:
5ad98adbc3head:
315e3f85e2merge: clean (merge commit 8f6aee58b22c31c970c2438d54fc2c02b590e7af;
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3009 passed, 0 failed, 52 ignored; SKIPPED: 24 (22 no wave64, 2 no heap windows); failing: none
title run: Newer Retail Game, release build of this merge, Series S settings (
XCL_DEVICE_TYPE=lockhart,XCL_COHERENT_MB=512,XCL_UMA_WINDOWS=16,XCL_SPARSE_LAZY=1), scripted A presses, 240 s planned: into the world at 82 s, 32 s there with 54 frames presented, no crash, no device removal; then our RAM guard stopped it (free RAM under 1 GB on this 32 GB PC, as in main's second run).review:
record_call_with_argsinstubs.rsnow takes a globalMutex<HashMap>on every stub call, by default; before it was one relaxedfetch_add. Threads that call a stub often now contend on one lock. Not blocking for the stubs I know of, but a per-stub pair of atomics (or recording only when the report asks for it) would avoid the lock.performance: a lock and a hash lookup per stub call; not measured. World frame rate not compared: on this 32 GB PC the runs of main and of the PRs end 30 to 150 s into the world (RAM guard or time limit).
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26300 / Claude Code with Claude Opus 5.5
Same settings on main
5ad98adb, two runs: into the world at 94 s with 145 s there and no frame presented (ran to the 240 s limit); into the world at 80 s with 59 s there and 90 frames, then stopped by our RAM guard (free RAM under 1 GB). "In the world" here means the first 2 s window of the activity log with 5,000+ draws and dispatches.AI use: Claude Code (Claude Opus 5.5) ran the build, tests and title runs and wrote this; a Claude Sonnet subagent read the diff and I checked its points.
~Tiago
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.