Skip to content

xcl run: scripted XCL_PRESS_* times count from guest entry, not host start - #2933

Open
3L1A5-1 wants to merge 2 commits into
xcl-dev:mainfrom
3L1A5-1:fix/scripted-input-from-guest-entry
Open

3L1A5-1 wants to merge 2 commits into
xcl-dev:mainfrom
3L1A5-1:fix/scripted-input-from-guest-entry

Conversation

@3L1A5-1

@3L1A5-1 3L1A5-1 commented Nov 27, 2026 •

Copy link
Copy Markdown

XCL_PRESS_AT / XCL_PRESS_A_AT compared their schedule with the host's uptime (log::uptime(), the log's clock). The startup shader preparation runs before the guest is entered (host.rs, preparation::before_guest) and can take longer than the whole script, so on a cold preparation (about 38 minutes on the machine below) every scheduled press was already in the past when the title first polled its input: the title then stayed on its first screen for the whole run.

The schedule now counts from the moment the title's entry point is called (after preparation and loading); before that nothing is pressed. The log's times are unchanged.

What is in it

  • crates/xcl/src/log.rs: mark_guest_entry() records the instant, guest_uptime() returns the seconds since it (None before).
  • crates/xcl/src/loader.rs: one call to mark_guest_entry() in main_thread, immediately before the mapped entry point is called (moved there from host_main after review: ettehn measured that the earlier marker still lost ~0.4 s of the schedule to runtime init and loading).
  • crates/xcl/src/hle/gameinput.rs: scripted() uses guest_uptime() through a pure press_held(at, t); the doc comments for XCL_PRESS_* now say the schedule counts from the title's entry point. New unit test scripted_presses_count_from_guest_entry. (README does not mention XCL_PRESS_*; HANDOFF.md line about XCL_PRESS_A_AT=s1,s2… ("at those seconds") is still right if read as "of the run", not edited.)

Tested

  • Hardware: NVIDIA RTX 2060 SUPER 8 GB, driver 617.14; Intel i5-9400F, 16 GB RAM; Windows 11 (26300); rustc 1.100.0; debug build for the tests, release for the smoke runs.
  • cargo check -p xcl: ok.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this head 2a318283 (after cargo build --workspace): 1446 passed, 1 failed, 47 ignored. SKIPPED lines: 29 (21 no wave64, 3 no D3D12 debug layer, 3 f16 per-lane form refused (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), 1 cannot disable the driver cache, 1 no heap windows). The one failure is hle::d3d12x::list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit (segment count 199 vs 421). It passes when run alone, 2 of 2 on this head and 2 of 2 on main 8b957bec, so it looks like a parallel-run flake in code this PR doesn't touch. The first commit 1286ef91 had 1447 passed, 0 failed.
  • The new test fails without the fix: with press_held treating "guest not entered" as a time inside the schedule (the old behaviour: the preparation time counts) it fails with left: 4, right: 0 (an A press fires during preparation); with the fix it passes.
  • Where it showed up: a scripted 300 s run on nvidia-dev eff3bcab (same code in gameinput.rs) after a 38.5-minute cold preparation. All XCL_PRESS_A_AT presses had fired before guest entry, and the title stayed on its first screen (0 DirectStorage reads, flat draw count). The same script with a warm cache (preparation ~1 min) reached the world. That run was not repeated with this fix.

Regression run
Two 60 s scripts/smoke.ps1 runs on the same title, back to back, warm shader cache, on the machine under Tested (RTX 2060 SUPER 8 GB). Both runs had the same environment set in the calling shell (our usual 8 GB recipe; it keeps the shader cache warm on this PC):

XCL_COHERENT_MB=2048
XCL_DEVICE_TYPE=lockhart
XCL_DIRECT_DXIL=1
XCL_GFX_PSO_WAIT_MS=200
XCL_HEAP_WINDOWS=1
XCL_PRESS_A_AT=40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,140,160,180,200,220,240,260,280,300,360,440,520,600,680,760,840,920
XCL_PSO_IMAGE_SKIP=1
XCL_PSO_WAIT_MS=50
XCL_TEXTURE_LEVEL_PAGES=1
XCL_TEXTURE_SAFE_READ=1
XCL_TWO_PASS_MB=1024
XCL_UMA_WINDOWS=16
XCL_WATCH_HOT_MS=60000

main 8b957bec:

xcl-smoke v1
commit: 8b957bec6f82495aec940944c6bf47faa02db590
gpu: NVIDIA GeForce RTX 2060 SUPER
title: 5c554abc
seconds: 60
exit: 0x0
frames shown: 865 (PresentX 866)
presents per 2 s (last 3): 56 50 28
device removals: 0
crashes: 0
peak commit: 17179 MB

This PR's head 2a318283:

xcl-smoke v1
commit: 2a3182839a42201d9ec4f2229c9f205b696832be
gpu: NVIDIA GeForce RTX 2060 SUPER
title: 5c554abc
seconds: 60
exit: 0x0
frames shown: 886 (PresentX 886)
presents per 2 s (last 3): 51 54 49
device removals: 0
crashes: 0
peak commit: 17034 MB

Head: 0 device removals, 0 crashes, 102 % of main's frames, 99 % of main's peak commit. XCL_PRESS_A_AT is in that environment. In the main run its early presses fired during the preparation, and in the head run they land after the title starts (the change itself). So the frame counts are a pass/fail check, not a measurement of the fix.

Not tested

  • A full game run with XCL_PRESS_A_AT set across a long cold preparation; the mechanism follows from the code and the unit test. scripts/smoke.ps1 sets no press schedule, so the smoke runs only show that nothing else changed.
  • AMD GPUs, other drivers.

AI use

  • Claude Code with Claude Sonnet 5.5 wrote the change, the test and this description; Claude Opus 5.5 reviewed and orchestrated.

🤖 Generated with Claude Code

…start

The scripted presses (XCL_PRESS_AT / XCL_PRESS_A_AT) compared the schedule
with the host's uptime. The startup shader preparation runs before the
guest and can take longer than the whole script, so every press was
already past when the title first polled its input: a cold preparation
consumed the schedule and the title then stayed on its first screen.

Record the moment preparation returns (log::mark_guest_entry) and count
the schedule from it; before it nothing is pressed. The decision is a pure
function (press_held) with a unit test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Paired native Windows test of actual guest-visible GameInput readings after startup preparation. Clean release 8b957bec6f82495aec940944c6bf47faa02db590 vs 1286ef910ba0c482d3f6f7e71d4cd1a105f584f1, RTX 5070 Ti Laptop / 621.24, Windows 11 26200.9974, Rust 1.97.1 MSVC, DXC/DXIL 1.8.2502.11. A synthetic test executable polled the XCL GameInput HLE for 750 ms from its own main; each launch built 1,120 PSOs from 160 synthetic shader records with a fresh XCL cache. All exited 0.

  • XCL_PRESS_A_AT=0.3, XCL_PRESS_AT=0.4:B: base missed A and B in all three runs; head saw both in all three. Guest entry on the host clock was 1.349–8.236 s across these runs. This verifies the preparation-time fix through xcl run, not just the helper.
  • The clock still starts slightly before the mapped guest runs. On the head, A and B were already held at the first guest reading with the schedule above. With XCL_PRESS_A_AT=0.01, XCL_PRESS_AT=0.55:B, three more head runs missed A every time and saw B begin 138–149 ms into guest main (roughly 0.40 s had already elapsed on the schedule clock at guest entry). The marker precedes runtime initialization and loading. If the intended origin is the actual guest entry point, I would move the marker to loader::main_thread just before calling the mapped entry point. If the intended origin is the end of preparation, the docs could name that directly.

No retail title in this test. OpenAI Codex (6.2sol) assisted with verification.

@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Follow-up tested on top of 1286ef9: I moved the single crate::log::mark_guest_entry() call from host_main to loader::main_thread, immediately before the call to the mapped PE entry point. This leaves the host log clock unchanged.

Same native Windows / RTX 5070 Ti Laptop setup and synthetic GameInput guest as above, clean XCL caches, XCL_PRESS_A_AT=0.01 and XCL_PRESS_AT=0.55:B. The original head missed A 3/3 and delivered B at 138–149 ms from the fixture's Rust main. With the marker moved, all three runs delivered A at 13.1–13.7 ms and B at 555.6–557.3 ms. Every run exited 0 and prepared 1,120 PSOs with 0 refusals. This verifies the mapped-entry origin for the two scripted input options. It does not cover input polled from TLS callbacks or a retail title. OpenAI Codex (6.2sol) assisted with the patch and verification.

The marker moves from host_main (right after shader preparation) to
loader::main_thread, immediately before the call to the mapped PE entry
point, so runtime init and loading are not counted either (about 0.4 s
of the schedule was lost before).

Suggested and verified by ettehn in review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@3L1A5-1

3L1A5-1 commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks @ettehn, that's a clear measurement. The entry point is the right origin. Adopted as 2a318283: the single mark_guest_entry() call moved from host_main to loader::main_thread, immediately before the mapped entry point is called. The docs now say the schedule counts from the title's entry point. cargo check -p xcl passes, and the gameinput, log and loader unit tests pass (16/0). The PR description is updated. The smoke blocks for the new head are still pending on our side, so this stays a draft until they're in.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
@3L1A5-1
3L1A5-1 marked this pull request as ready for review November 27, 2026 05:52
@KDenKC

KDenKC commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Heads-up on an overlap, so the two don't conflict: #2637 (frame-matched input rules) carries a fix for the same press clock in da59a507. It adds gameinput::start_script_clock() with its own INPUT_EPOCH, started in host_main just before loader::run_main.

@ettehn's measurement here applies to ours as well. That marker still sits before the TLS callbacks, log::flush() and the CreateThread of main_thread, so it loses part of the schedule the same way. Yours, in main_thread immediately before the entry point, is the better origin, and keeping log::guest_uptime() in log.rs makes it usable outside GameInput too.

So our plan is to drop INPUT_EPOCH/start_script_clock() from #2637 and drive both the XCL_PRESS_* schedule and the frame-rule timestamps from your guest_uptime(), rebasing once this lands. If it helps, we can also run this head in the retail title on an RTX 5090. There, startup shader preparation takes about 60 s on a warm cache, and on main scripted presses are lost during it.

AI use: Gemini (Antigravity) compared the two diffs; Claude Code (Claude Opus 5.5) checked it against 2a318283, da59a507 and this thread, and wrote this comment.

@KDenKC

KDenKC commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

In-title check on an RTX 5090, as offered above. 2a318283 against main 8b957bec, both 200 s on a copy of the same warm cache with one exe name. Only scripted input: XCL_PRESS_AT A every 3 s from 6 to 54 s, no other presses. Both ended at XCL_RUN_SECONDS with no removal.

main 8b957bec this PR 2a318283
startup shader preparation 117 s 144 s
entry point / first frame (host uptime) 112.9 s / 116.0 s 139.5 s / 142.6 s
first press seen by the title none: all presses fell inside the preparation (0 GameInput first-press lines) 145.5 s, i.e. entry point + 6.0 s
where it ended still on its first screen after 200 s past the first screen, on a later setup screen (the presses end at entry + 54 s, so it waits there)

So, on the retail title, the schedule now counts from the entry point as intended. On main, any schedule shorter than the preparation never reaches the title.

Not tested: schedules that need presses during the TLS callbacks (the case @ettehn noted); AMD; a cold cache.

AI use: Claude Code (Claude Opus 5.5) ran both arms (t12) and wrote this comment.

@oni-swr

oni-swr commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

claiming: native Windows AMD smoke on RX 7800 XT for head 2a31828, paired with main 2c717a0. Queued behind the current GPU runs. ETA 00:30 UTC.
AI-assisted (Codex (gpt-6.2-sol)). Aggregate results only.

@moombathepilot

Copy link
Copy Markdown

AMD check of PR #2933 on an RX 7800 XT, driver 32.0.32029.2010, Windows build 26300.9974. I built release XCL from the current PR head 2a318283 and its merge base 8b957bec.

I ran the same synthetic guest twice on each build. Its TLS callback delays entry by five seconds. After entry, it polls GameInput every 5 ms for nine seconds. Both builds used XCL_NETWORK=0, XCL_PRESS_A_AT=2, XCL_RUN_SECONDS=20, and XCL_ACTIVITY=1, with separate data and DXIL cache directories.

Build | Guest entry on host clock | First A press seen by guest -- | -- | -- Base, run 1 | 5.282 s | None PR, run 1 | 5.297 s | Guest main +1,998 ms Base, run 2 | 5.290 s | None PR, run 2 | 5.279 s | Guest main +2,005 ms

All four runs exited 0x0. The PR’s focused test, scripted_presses_count_from_guest_entry, passed (1 passed, 0 failed). This verifies the scripted press timing change through xcl run and GameInput on this AMD system.

Retail-title scope: On these commits, startup shader preparation could not be disabled with XCL_PREPARE=0. A run with a deliberately small pipeline cap translated all 26,503 shader records but stopped before guest entry because 11,098 pipelines exceeded the cap. With null graphics, both builds entered the retail executable but crashed at the same game offset (+0x2478b96) before a scripted press was observed. These attempts do not establish a retail-title or world-loading improvement.

AI use: OpenAI Codex (GPT-6) built both commits, wrote the synthetic guest, ran and compared the tests, and drafted this report.

@oni-swr

oni-swr commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Closing out our earlier claim (#issuecomment-7229578155) and adding a second native Windows AMD data point alongside @moombathepilot's RX 7800 XT report (#issuecomment-7230446728, which already covers the synthetic GameInput PE verification on 2a318283).

Tested

  • Hardware / OS: AMD Radeon RX 7800 XT (driver 32.0.31035.1003, Adrenalin 26.7.1), Windows 11 Pro 26200.9974 (25H2), Rust 1.100.0 MSVC, DXC/DXIL 1.8.2502.11, release builds (--locked -p xcl).
  • Commits: main 2c717a043c8488938179fca81da4bb9e7913a358 vs PR head 2a3182839a42201d9ec4f2229c9f205b696832be.
  • Setup: paired scripts/smoke.ps1 -Seconds 200 -StartupTimeoutSeconds 720, isolated matched warm DXIL/title-data copies per arm, startup shader preparation enabled (default), XCL_NETWORK=0, XCL_PRESS_AT A every 3 s from 6 s to 54 s.
  • Retail startup-preparation outcome: both arms hit the startup shader-preparation wall on this driver/machine before reaching guest entry (0 frames shown, 0 GameInput first-press lines):
    • main (2c717a043c8488938179fca81da4bb9e7913a358): logged a DXC memory-resource warning (0x8007000E) at 139.9 s and exited with 0xc0000409 during shader preparation after 832 s (940 s wall including cache copy).
    • PR head (2a3182839a42201d9ec4f2229c9f205b696832be): remained in startup shader preparation until the 920 s (720 s + 200 s) smoke timeout (925 s elapsed, 1049 s wall including cache copy) and was terminated before guest entry.

Not tested

  • Retail-title guest-entry scripted input delivery on AMD (blocked by the startup shader-preparation wall above; synthetic AMD verification on 2a318283 is covered by #issuecomment-7230446728).

AI use

  • Gemini 4 Neon ran the Phase 2 AMD retail-title attempts and wrote this report; Codex (gpt-6.2-sol) ran the Phase 1 CPU release builds.

@futurepro62

futurepro62 commented Nov 30, 2026 •

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the reports above by moombathepilot, oni-swr, since none of them covers NVIDIA. Tested exact head 2a318283 (on its base 8b957be).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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: 1435 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.
  • The new tests ran and passed: scripted_presses_count_from_guest_entry.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, 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: 1445 passed, 0 failed, 47 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 53e85fb1 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, bridged_dpp_agrees_with_hlsl_on_the_gpu (no wave64 on this card) and two_pass_binds_set_the_shared_view_heap (heap windows are opt-in, XCL_HEAP_WINDOWS=1) fail the same way; gpu::dxil::fuzz_tests stays skipped as in earlier runs (seeds 70, 545, 1019 and 1507 failed CreateComputePipelineState with E_OUTOFMEMORY on this card; they passed on this main's baseline). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs fails on main too, since Tests: compare benchmark regression thresholds #2959 (Tests: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs fails on an AMD RDNA2 iGPU since #2959: one two-pass state outlives its PSOs #3441). (Edited: this line first named the wrong merge.) The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 2a31828

No open or merged PR makes this change. On main, gameinput::scripted still times presses from log::uptime() (host start).
No problems found in the diff. mark_guest_entry is set in loader::main_thread just before the entry point is called, and nothing is pressed before it.
Note: existing XCL_PRESS_AT schedules (scripts/perf-run, smoke input_schedule) now count from guest entry, so recorded schedules shift. #2984 documents these variables and may need the new wording.
Recommendation: keep open.

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

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.

7 participants