Skip to content

Shaders: warm runtime-selected graphics DXIL variants in --precompile - #2613

Open
Decodere wants to merge 2 commits into
xcl-dev:mainfrom
Decodere:fix-precompile-runtime-graphics-variants-2600
Open

Decodere wants to merge 2 commits into
xcl-dev:mainfrom
Decodere:fix-precompile-runtime-graphics-variants-2600

Conversation

@Decodere

@Decodere Decodere commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Routes the runtime-selected first console vertex (hw == 4) and pixel (hw == 5) FSSM program in xcl shaders --precompile through recomp::pso::console_to_dxil_in_outcome, warming the exact translated/v2 runtime cache variants (including XCL_DIRECT_DXIL=all direct graphics variants), distinguishing cache hits from fresh compiles, preserving full companion-program and later-FSSM coverage alongside exact incomplete-translation skip semantics for both standalone --precompile and hosted prepare_for_launch (#2555), and explicitly reporting standalone PS sampler_base=0 coverage alongside static-sampler shift counts. Updated in follow-up commit ffa475a38d0356e8a4f17be8f2c014b43b0e5a37 on top of fddd2d71 (main f9a0cb80f9decb41d6f6315f6cf4e06270ba2bda, preserving #1871's xcl pso-precompile, --records, --used, and make_pipelines behavior) to fix the multi-program and empty-first-FSSM coverage regression caught by @thehollowedone. Part of #2600, Part of #2508, Part of #1833.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs:
    • Adds console_to_dxil_in_status(blob, stage, sampler_base, split_wave64, windows) -> Result<(Compiled, bool), String> (with console_to_dxil_in delegating to it) returning whether the result came from the in-memory or translated/v2 disk cache (true) vs fresh translation/compilation (false).
    • Adds shared INCOMPLETE_TRANSLATION_PREFIX (used across console_translation, finish_two_pass, and compile_console_mesh), typed CompileOutcome::{Compiled, Incomplete, Failed}, and console_to_dxil_in_outcome(...) so both cold translations and .err-cached lookups distinguish incomplete translations (!Translation::complete()) from hard parse/interface/DXC failures.
    • No change to translated output or cache keys: console_to_dxil_in_status / console_to_dxil_in_outcome wrap the exact same ShaderKey and translated::cached lookup, and INCOMPLETE_TRANSLATION_PREFIX ("incomplete translation, ") is byte-identical to the prior error prefix — existing DXIL/HLSL caches remain valid without re-translation.
  • crates/xcl/src/shaders.rs (precompile):
    • Records the first hardware-stage match (seen_vs for hw == 4, seen_ps for hw == 5) before recomp::interface, matching pso.rs::console_translation's exact selection so an empty or interface == None first FSSM cannot steer a later valid FSSM into console_to_dxil_in_outcome and fail with FSSM without a program (caught by @thehollowedone).
    • Routes only f.programs[0] of that first matching VS/PS FSSM through recomp::pso::console_to_dxil_in_outcome(&blob, stage, 0, graphics_split, windows) (and uses console_to_dxil_in_status for compute while preserving PSO: xcl pso-precompile builds a title's compute pipelines before its run #1871's selected filtering, startup split-chain build path, and pipeline_jobs / make_pipelines ordering), incrementing cached on cache hits and compiled only on fresh compiles.
    • On CompileOutcome::Incomplete(_), counts the hosted startup skip directly (if startup.is_some() { skipped.fetch_add(1, Ordering::Relaxed); }) without re-translating programs[0], preserving exact skip behavior (0 errors, 1 skip on startup) for both standalone --precompile and hosted prepare_for_launch (xcl run: prepare shaders in the game window before title execution #2555, addressing @CryingLaughing's report).
    • Short-circuits only when handled_first_program && f.programs.len() == 1 and iterates f.programs.iter().skip(usize::from(handled_first_program)) so companion programs (f.programs[1..]) and subsequent VS/PS FSSMs retain full --precompile coverage.
    • Tracks ps_base0, ps_static_samplers, and vs_static_samplers from Compiled.samplers and prints an explicit runtime-path coverage summary line when standalone PS or static-sampler VS records are warmed.
  • crates/xcl/tests/shaders_e2e.rs:
    • Adds xbox_shader_with_osg using #1942's shared container helper alongside #1871's pso_precompile_help_and_required_records_operand.
    • Adds fresh-process end-to-end tests precompile_warms_direct_vs_ps_and_hits_in_fresh_process (XCL_DIRECT_DXIL=all), precompile_warms_hlsl_static_samplers_and_reports_base_shift (XCL_DIRECT_DXIL=0), and precompile_skips_incomplete_vs_while_warming_supported_vs.
    • Adds @thehollowedone's two regression tests precompile_keeps_companion_programs_and_pixel_variants (compiled 3 -> 0, already cached 0 -> 3, errors 0) and precompile_keeps_a_pixel_variant_after_an_empty_first_variant (compiled 1 -> 0, already cached 0 -> 1, errors 0).

Tested

  • Hardware / toolchain: Windows 11 Home (build 26200), NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves, driver 32.0.16.2114), Intel Core i5-11400F (6C/12T), 32 GB RAM, rustc 1.100.0, DXC 1.9.2609.5, debug + release, follow-up HEAD ffa475a38d0356e8a4f17be8f2c014b43b0e5a37 (fast-forward onto fddd2d71678df6001b8b58f43a60e8cf22d94806, merge-base f9a0cb80f9decb41d6f6315f6cf4e06270ba2bda).
  • Failing-first reproduction on unmodified fddd2d71 with both new precompile_keeps_ tests: 0 passed; 2 failed (compiled 1 instead of 3 on the companion/multi-FSSM PS fixture; errors 1 ... FSSM without a program on the empty-first-FSSM PS fixture).
  • cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition: exit 0, 0 new warnings or errors across all 3 modified files (pso.rs, shaders.rs, shaders_e2e.rs; the -A flags suppress only pre-existing rustc 1.100.0 deny-by-default lints outside this diff).
  • 3x Debug and 3x Release targeted tests (RTX 4060, 0 skips):
    • cargo test --lib -p xcl shaders:: -- --test-threads=4 (Debug 3x, Release 3x): 13 passed; 0 failed; 0 ignored
    • cargo test -p xcl --test shaders_e2e -- --test-threads=4 (Debug 3x, Release 3x): 14 passed; 0 failed; 0 ignored (includes #1871's pso_precompile_help_and_required_records_operand, all 3 graphics-variant warming E2E tests, and both new precompile_keeps_* tests covering cold compile + warm cache hits).
  • cargo build --release -p xcl: exit 0, 0 new warnings in touched files.
  • Independent community verification on fddd2d71 in this thread: @UncommonDLL passed precompile_skips_incomplete_vs_while_warming_supported_vs on Windows (rustc 1.100.0, DXC 1.9.2609.5), and @thehollowedone verified the companion/empty-first-FSSM candidate fix (14/14 shaders_e2e, 13/13 shaders::) on RTX 3080 Ti.

Regression run

Quiet 60 s retail smoke runs (scripts/smoke.ps1 -Seconds 60, XCL_PREPARE=0, XCL_NETWORK=0, title: 29640639, NVIDIA GeForce RTX 4060).

main (f9a0cb80f9decb41d6f6315f6cf4e06270ba2bda, exact merge-base):

xcl-smoke v1
commit: f9a0cb80f9decb41d6f6315f6cf4e06270ba2bda
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1579 (PresentX 1579)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13996 MB

PR (ffa475a38d0356e8a4f17be8f2c014b43b0e5a37):

xcl-smoke v1
commit: ffa475a38d0356e8a4f17be8f2c014b43b0e5a37
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1606 (PresentX 1606)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14019 MB

Not tested

  • Hardware Wave64 GPUs (AMD RDNA / GCN) and Intel adapters, D3D12 debug-layer tests (d3d12SDKLayers.dll not installed on this host), XCL_HEAP_WINDOWS=1, and Windows Developer Mode driver-cache-disable tests.
  • Full retail shader archive cold --precompile / prepare_for_launch run (XCL_PREPARE=0 was used for the 60 s retail smoke; graphics-variant warming, incomplete-VS skip, companion-program, and empty-first-FSSM paths are verified via isolated fresh-process synthetic console VS/PS containers in shaders_e2e).
  • XCL_SAMPLE_* game-data tests and #[ignore] tests.

AI use

  • Google Antigravity (Gemini 4 Neon) implemented console_to_dxil_in_status, CompileOutcome / console_to_dxil_in_outcome, the precompile runtime graphics warming, cache-hit accounting, coverage reporting, and follow-up companion/later-FSSM coverage fix (adapting the repros and fix caught by @thehollowedone), ran all failing-first, clippy, 3x Debug/Release shaders:: and shaders_e2e, release build, and paired 60 s RTX 4060 smoke verifications, and updated this PR description.

@DarkPanda69

DarkPanda69 commented Nov 26, 2026 •

Copy link
Copy Markdown

Update for head ffa475a: the branch no longer merges into main (conflict in shaders.rs), so I tested the PR head against its merge-base f9a0cb8. shaders_e2e: 14 passed, 0 failed, no SKIPPED. shaders::: 13 passed, 0 failed, with the same 1 SKIPPED (pso_measurement_compiles_an_exact_synthetic_record). Same on the RX 9070 XT and the RTX 3060.

Update for head d68c74e: same result. The diff no longer applies as a patch on main 8b957be, so I merged the branch into it (shaders.rs auto-merged, no conflicts). shaders_e2e gives 11 passed, 0 failed, no SKIPPED, on both the RX 9070 XT and the RTX 3060. shaders:: gives 10 passed, 0 failed on both, with the same 1 SKIPPED as before.

Update for head 2d229b9: rerun on main b49be18, same cards and --nocapture. shaders_e2e gives 10 passed, 0 failed, no SKIPPED, on both the RX 9070 XT and the RTX 3060. shaders:: gives 10 passed, 0 failed on both, with the same 1 SKIPPED as main (pso_measurement_compiles_an_exact_synthetic_record).

64-lane AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: both new end-to-end tests pass on both cards, with no skips.

Head a3312c0 applied on main b49be18, debug, Windows 11 Pro 26200, card chosen with XCL_ADAPTER:

  • cargo test -p xcl --test shaders_e2e -- --nocapture: 10 passed, 0 failed, no SKIPPED on both cards, with precompile_warms_direct_vs_ps_and_hits_in_fresh_process and precompile_warms_hlsl_static_samplers_and_reports_base_shift among them.
  • cargo test -p xcl --lib -- shaders::: 10 passed, 0 failed on both cards. 1 SKIPPED, the same on main: pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache).

Not tested: the D3D12 debug-layer tests (no d3d12SDKLayers.dll here either), a retail pack, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Tested — AMD Radeon RX 6800M

  • Exact PR head: a3312c055cf3a31f77bcb7b1e278b7479d29dc41 (clean detached worktree). Windows 11 Home 10.0.26200, Ryzen 9 5980HX, RX 6800M driver 30.0.13002.13003, rustc 1.99.0, DXC 1.9.2609.5, debug build.
  • Set XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, and XCL_DXC_DIR to the local DXC 1.9.2609 x64 directory. Ran cargo test --locked -p xcl --test shaders_e2e -j 1 precompile_warms_ -- --test-threads=1 --nocapture in an isolated target directory under a memory guard: 2 passed, 0 failed, 0 ignored, 8 filtered; no SKIPPED lines; guard did not trigger.
  • Direct VS+PS fresh-process cache hit: warm_translate_dxc_ms=5.452, native_pso_ms=5.909.
  • HLSL static-sampler/base-shift fresh-process case: warm_translate_dxc_ms=4.994, native_pso_ms=18.077.

The child tests assert warm translated/v2 hits and zero DXC compiles on those hits. The numeric native PSO timings show that both cases reached CreateGraphicsPipelineState. The child inherits XCL_ADAPTER=6800M; this machine's matching hardware adapter is the RX 6800M. The helper only falls back to WARP when no adapter matches, so this is RX 6800M native-driver evidence rather than a pass inferred from the outer test status alone.

Not tested: full workspace suite on this head, release profile, a retail shader archive or paired title smoke, other GPUs, and whether the changed path improves title behavior. Timings are single samples, not a performance comparison.

AI use: OpenAI Codex (GPT-6; exact serving variant unavailable) and a Luna subagent selected the focused test, ran it, checked the exact-head log and adapter-selection code, and drafted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

— Devin

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new VS/PS path increments compiled after every successful console_to_dxil_in, including a hit from its in-memory or translated disk cache. That function returns only Compiled, so a second --precompile run can report compiled 2, already cached 0 for graphics variants even when both came from the cache. The HLSL loop below distinguishes hits. Could the graphics path expose/count the cache outcome (or use a separate warmed counter) and add a warm second-run assertion for the summary? Source review at a3312c055cf3a31f77bcb7b1e278b7479d29dc41; I did not run the precompile command. AI-assisted review with Codex.

@SzczepanGrela

SzczepanGrela commented Nov 26, 2026 •

Copy link
Copy Markdown

Updated RX 9070 / Wine verification for head d68c74e55cf5837d7fee81f8eee52472d91dd9b6, current main 8b957bec6f82495aec940944c6bf47faa02db590, and their automatic three-way integration using merge base e120925e3abc9956a8b9bae631969d32e8ccd43c. The integrated preparation preserved the unsupported-VS skip while warming the supported runtime variant in both direct and HLSL modes.

Tested

RX 9070 (RADV GFX1201), Mesa 26.3.1-arch3.5, Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, GE-Proton11-12 / Wine 11.0 Staging, native d3d12/d3d12core/dxgi, vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC 1.9.2602.17, Rust 1.97.1, release x86_64-pc-windows-gnu.

Built each source copy with cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --test shaders_e2e --lib --no-run. Ran the resulting executables through Wine with --nocapture --test-threads=1 and --nocapture --test-threads=4, selecting shaders::tests:: for the unit target. Upstream tests and assertions were unchanged. The only added fixture, on main and the integration, was an append-only #[cfg(test)] caller of prepare_for_launch.

Source shaders_e2e, threads 1 shaders_e2e, threads 4 shaders::tests::, each thread mode
main 8 passed, 0 failed 8 passed, 0 failed 6 passed, 1 failed
exact PR head 11 passed, 0 failed 11 passed, 0 failed 6 passed, 1 failed
integration 11 passed, 0 failed 11 passed, 0 failed 6 passed, 1 failed

All counts have 0 ignored. The unit failure on all three sources was pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache ... Not implemented. (0x80004001), but XCL_REQUIRE_GPU=wave64. This is retained as a failure, not counted as GPU coverage. The six unit passes include retail_pack_sample returning early because XCL_SAMPLE_RPF was unset, one skip message per unit invocation. No retail data was loaded.

Both graphics fresh-process cases passed their cold compiled 2, already cached 0, errors 0, warm compiled 0, already cached 2, errors 0, translated-cache and zero-DXC assertions. The HLSL case also checked the separate PS(base=1) variant. Eight native graphics PSO creations completed across exact-head/integration and the two thread modes, with numeric native-PSO markers and no capability skips. The new incomplete-VS end-to-end case passed in all four PR/integration invocations.

The additional preparation check used one supported VS and one v_cvt_off_f32_i4 VS, with XCL_DIRECT_DXIL=all and 0, XCL_UMA_WINDOWS=4, XCL_HEAP_WINDOWS=0, and the device-selected graphics split form (true). Each source/backend had separate cold, warm and fresh cached-only probe processes, 12 processes total:

  • Both main and integration returned Ok(()), progress 2/2, errors 0, and skipped (runtime pairing or unsupported translation) 1. Cold reported compiled 1, already cached 0; warm reported compiled 0, already cached 1.
  • Before the probe, the integration already had a supported translated/v2 .bin and an incomplete-translation .err. Fresh-process probes reused both without DXC compilation, and cold/warm/probe cache snapshots stayed byte-identical.
  • Main had only the DXC cache after preparation. Its direct cached-only probe missed. Its HLSL probe succeeded using that DXC cache, with zero DXC compiles, and created the translated entry during the probe. Thus the HLSL result is not evidence that main cannot reuse earlier DXC work.
  • Original synthetic shader files remained byte-identical. No unexpected harness failure, device removal, or capability skip occurred in the end-to-end or preparation checks.

An initial local probe incorrectly expected the HLSL main control to miss. I corrected that local expectation after checking the DXC and translated-cache paths, retained its logs, rebuilt the affected test binaries, and repeated the complete 24-invocation comparison above. Source, executable and cache hashes and raw counts were checked separately.

Environment: XCL_ADAPTER=AMD Radeon RX 9070, XCL_REQUIRE_GPU=wave64, XCL_NETWORK=0, XCL_DXC_THREADS=1, native DLL overrides, and private enabled application/driver cache directories.

Not tested

Full workspace suite, guest entry or hosted xcl run, retail archives, smoke runs, shader execution/rendered-image correctness, forced hard-error paths, native Windows, other GPUs, or performance/FPS. The preparation fixture called the preparation function directly. No title-level regression claim.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the changes, prepared the local fixture, built and ran the comparisons, independently checked source bytes, raw logs and cache snapshots, and wrote this update. Publication authorized by the account owner.

@Decodere
Decodere force-pushed the fix-precompile-runtime-graphics-variants-2600 branch from a3312c0 to 2d229b9 Compare November 26, 2026 06:43
@Decodere

Copy link
Copy Markdown
Contributor Author

Thanks @luckyteagirl and @SzczepanGrela — pushed 2d229b9f addressing both review items:

  1. Cache-hit accounting (@luckyteagirl): added recomp::pso::console_to_dxil_in_status returning (Compiled, bool) (from_cache) and wired it into shaders.rs::precompile (CS, VS, and PS) so in-memory and translated/v2 hits increment already cached instead of compiled. Both shaders_e2e tests now verify cold compiled 2, already cached 0, errors 0 followed by a warm second --precompile run reporting compiled 0, already cached 2, errors 0.
  2. Native PSO error handling (@SzczepanGrela): changed time_native_graphics_pso to return Result<Option<f64>, String> so root-signature and CreateGraphicsPipelineState failures fail the test with the exact error / HRESULT once a D3D12 device is created, while genuine no-device environments route through runner::skip_test("no D3D12 device").
  3. Re-verified release WARP & RTX 4060 shaders_e2e (10/0/0, 0 skipped), full release workspace (1437/0/47), and paired 60 s RTX 4060 smoke (1546 frames, 60 60 60, 0 removals/crashes).

@KDenKC

KDenKC commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Correction (see 7193409689 below): the cleaner control, main with its own full --precompile (graphics included), also has almost no gap: median 23 ms, max 129 ms over 38 large pipelines. So most of the 4,024 ms → 6 ms below comes from precompiling graphics at all, not from this PR alone. This PR's own share in this measure is about 23 → 6 ms median (129 → 8 ms max).

Retail title, RTX 5090: the large graphics pipelines now start their driver compile within milliseconds instead of seconds. One 600 s run per side. Our control's precompile was compute-only (see Not tested).

Setup: RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11, release, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1 XCL_NETWORK=0.

  • PR side: main b49be18 + this PR at a3312c05 + Shaders: --precompile --pipelines also builds a split program's whole form #2551 (3567b2e). 2d229b9f differs only in the counters and tests. xcl shaders <pack> --precompile --used-only --pipelines (graphics included) took 42.3 min: 26,503 shaders, 0 errors; PS warmed at assumed sampler_base=0: 12101 (5765 with static samplers); VS with static samplers shifting paired PS base: 173; 2,812 pipelines, 0 refused.
  • Control: main b49be18, precompiled with --only cs.
  • Both: a 200 s warm-up, then 600 s on a copy of the warmed cache.

Large graphics pipelines (≥ 200 KB DXIL) in the world-start stall (no frames shown). Gap = time from the previous driver compile finishing to this one starting, from the driver compile start/finish trace lines:

control this PR
pipelines 31 34
median gap 4,024 ms 6 ms
longest gap 7,144 ms 8 ms

The rest of the stall is the NVIDIA driver's own compile, which this PR does not change. Run-wide graphics compiles with no driver blob: 1,328 taking 106.7 s on the control, 1,447 taking 131.1 s here.

Run totals: both reached 600 s with no removal or crash. Frames shown: 2,163 (control) vs 2,117. Two-second windows with no frame after 120 s: 206 vs 215 of 240. These totals are not a fair A/B, for two reasons:

  • The PR side hit about 100 s more of cold huge compute pipelines (314 s vs 214 s). --used-only came from a 200 s run that never reached them.
  • The control's exe had a warmer NVIDIA shader cache from earlier runs under the same name.

Not tested

  • main with its own full --precompile (graphics included) as the control. That is the cleaner A/B for this PR, and we can run it if useful.
  • A pair with identical NVIDIA cache warmth and full compute coverage.
  • 2d229b9f itself (only its diff against a3312c05 was read).
  • AMD, Intel, Linux.
  • Shifted sampler_base > 0 pixel shader paths.

AI use: Claude Code (Claude Opus 5.5) built and ran both sides. Gemini (Antigravity) extracted the trace numbers. Claude Code recomputed the gap table from the raw logs and wrote this.

@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

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Ran the shaders end-to-end tests at 2d229b9:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --test shaders_e2e -- --nocapture
10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out      (exit 0)

Both new fresh-process tests pass here. The timings printed on this adapter were warm_translate_dxc_ms=3.738 native_pso_ms=12.321 (direct VS+PS) and warm_translate_dxc_ms=3.191 native_pso_ms=21.054 (HLSL static-sampler VS+PS). They are single runs, not a benchmark.

What this adds: the hardware reports in the thread are on an RTX 4060 (Ada) and WARP, at the earlier head a3312c0. This is a Blackwell wave32 part at the current head 2d229b9, which addressed the review findings.

Not tested: a full retail shader archive, a paired 60 s smoke run, the whole workspace suite, AMD and Intel GPUs, native wave64, Wine, release profile, title data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Route standalone VS and PS variants through the exact runtime console_to_dxil_in path so precompile warms translated/v2 serialization and the selected HLSL/direct-DXIL backend instead of only manually warming HLSL output.

Selection matches the runtime's first hardware VS/PS FSSM and exact stage, split, windows, and base-zero keys. Paired PS variants with nonzero VS sampler bases remain cold because the shader archive has no pipeline pairing data.

GNU Windows-target cargo check passed. Fresh-cache Windows probes, GPU execution, and retail smoke were not available on this host.

Adapted from PR xcl-dev#2613.
Assisted-by: Codex (GPT-5.6-sol)
@KDenKC

KDenKC commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Correction to 7186156070, with the cleaner control I offered there. main b49be18 with its own full --precompile --used-only --pipelines (graphics included, 42 min, 0 errors), the same recipe otherwise (200 s warm-up, then 600 s):

large graphics pipelines (≥ 200 KB) in the world-start stall control: main, compute-only precompile main, full precompile this PR + #2551, full precompile
count 31 38 34
median gap before the driver compile 4,024 ms 23 ms 6 ms
longest gap 7,144 ms 129 ms 8 ms

So the large drop in my earlier comment comes mostly from precompiling graphics at all, which main already does. In this measure, this PR takes it from ~23 ms to ~6 ms median (129 to 8 ms worst). I've put a note at the top of the earlier comment.

The full-precompile main run used an exe name with a warmer NVIDIA cache. The gap is XCL-side, so that shouldn't move it, but I'm noting it. That run ended with the #2403 removal at 577 s.

AI use: Claude Code (Claude Opus 5.5) ran the control, recomputed the gaps from the trace lines and wrote this.

@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Route standalone VS and PS variants through the exact runtime console_to_dxil_in path so precompile warms translated/v2 serialization and the selected HLSL/direct-DXIL backend instead of only manually warming HLSL output.

Selection matches the runtime's first hardware VS/PS FSSM and exact stage, split, windows, and base-zero keys. Paired PS variants with nonzero VS sampler bases remain cold because the shader archive has no pipeline pairing data.

GNU Windows-target cargo check passed. Fresh-cache Windows probes, GPU execution, and retail smoke were not available on this host.

Adapted from PR xcl-dev#2613.
Assisted-by: Codex (GPT-5.6-sol)
@CryingLaughing

Copy link
Copy Markdown
Contributor

Hosted xcl run verification on current main after #2555. The supported vertex shader warmed correctly. An unsupported loose vertex shader also exposed a startup regression.

Five launches compared clean main 8b957bec6f82495aec940944c6bf47faa02db590 with its unmodified Git three-way merge with PR head 2d229b9f76b605edffed09419328dc2245b97e8a (tree 7a620e2bf3335ace3a34de65826b4c964985ad8b). RTX 4080 driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11, debug. Each used the same synthetic guest, isolated caches, and xcl run <fixture> -- --pr2600-vs-only with XCL_DIRECT_DXIL=all XCL_ADAPTER=4080 XCL_ASYNC_PSO=0 XCL_PSO_DISK_CACHE=0 XCL_HEAP_WINDOWS=0 XCL_UMA_WINDOWS=4.

  • All three launches with the supported VS created a native translated graphics PSO and exited 0. On main, startup wrote one HLSL cache entry and the guest translated the VS when it created the PSO. The integrated tree wrote the byte-identical 2,584-byte direct cache entry 24acc6835ffb0a75_Vertex_0_4_1.bin before the guest ran. A fresh integrated process with only that cache entry and no loose shaders created the same PSO, retained the entry byte for byte, and emitted no targeted direct compile dump or fallback.
  • In the other two launches, the loose 400-byte VS had one decoded v_cvt_off_f32_i4, and the guest still requested the separate supported VS. Main reported 0 errors, 1 skip, ran the guest to its PSO marker, and exited 0. The integrated build reported 1 error, 0 skips, logged incomplete translation, missing: ["v_cvt_off_f32_i4"], and exited 2 before guest entry.
  • The four launches that ran preparation added the same two empty NVIDIA driver-log directories in the synthetic folder on both builds. The outer folder-equality guard reported that difference. All original fixture files stayed byte-identical. The fresh cache-only replay passed the folder guard.

Could the hosted path preserve the old skip behavior for incomplete translations? Routing that case through the existing per-program handling would keep the successful cache warmup and let launch proceed past an unused unsupported shader.

@CryingLaughing

Copy link
Copy Markdown
Contributor

I tested a follow-up for the hosted startup failure reported above. When the runtime path refuses a graphics shader during xcl run preparation, that stage now falls back to the existing per-program preparation, which handles incomplete translations as skips. Successful cache warming still uses the runtime path. Production patch · Verified review branch

The review branch retains current main 8b957bec6f82495aec940944c6bf47faa02db590 and PR head 2d229b9f76b605edffed09419328dc2245b97e8a as the integration parents. On RTX 4080 driver 621.01, Windows 11 25H2 build 26200.9974, Core i5-13600K, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11, debug, all five controls completed as expected. The formerly fatal loose VS now reports 0 errors and 1 skip, and its guest exits 0. The supported VS still warms the exact 2,584-byte cache entry and a fresh synthetic guest reuses it with no direct recompile. Both offline controls keep the original unsupported-shader diagnostic and count, and exit 0.

The automatic integration had a stale dxbc_container test call after main moved the helper. The review branch changes that call separately. At combined tip 7b3a0fc8176b905cd0ce52c51bba877f3332cc29, the two focused cold/warm tests and all ten shaders_e2e tests passed with zero capability skips. Test-helper patch

@Decodere

Copy link
Copy Markdown
Contributor Author

Thanks for catching that #2555 interaction and confirming the fallback shape — fixed in d68c74e5 (rebased onto e120925e, cleanly mergeable onto main 8b957bec):

  • Added CompileOutcome::{Compiled, Incomplete, Failed} and console_to_dxil_in_outcome in pso.rs (sharing INCOMPLETE_TRANSLATION_PREFIX across both cold translations and .err-cached hits).
  • In shaders.rs::precompile, CompileOutcome::Incomplete(_) now falls through to the existing per-program recomp::translate loop (keeping Mode::Vertex / Mode::Pixel arms and graphics_split intact) so standalone --precompile and hosted prepare_for_launch (#2555) both skip unsupported shaders with 0 errors.
  • Updated shaders_e2e.rs for #1942's container helper and added precompile_skips_incomplete_vs_while_warming_supported_vs (supported VS + v_cvt_off_f32_i4 unsupported VS, cold + warm .err-cached + fresh-process zero-DXC cache hit). Also verified in a live 3-way merge against 8b957bec that both cold and warm .err-cached prepare_for_launch runs return Ok(()) with 0 errors, 1 skip, alongside full release workspace (1445/0/47) and paired 60 s RTX 4060 smokes (e120925e vs d68c74e5).

bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Route standalone VS and PS variants through the exact runtime console_to_dxil_in path so precompile warms translated/v2 serialization and the selected HLSL/direct-DXIL backend instead of only manually warming HLSL output.

Selection matches the runtime's first hardware VS/PS FSSM and exact stage, split, windows, and base-zero keys. Paired PS variants with nonzero VS sampler bases remain cold because the shader archive has no pipeline pairing data.

GNU Windows-target cargo check passed. Fresh-cache Windows probes, GPU execution, and retail smoke were not available on this host.

Adapted from PR xcl-dev#2613.
Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Route standalone VS and PS variants through the exact runtime console_to_dxil_in path so precompile warms translated/v2 serialization and the selected HLSL/direct-DXIL backend instead of only manually warming HLSL output.

Selection matches the runtime's first hardware VS/PS FSSM and exact stage, split, windows, and base-zero keys. Paired PS variants with nonzero VS sampler bases remain cold because the shader archive has no pipeline pairing data.

GNU Windows-target cargo check passed. Fresh-cache Windows probes, GPU execution, and retail smoke were not available on this host.

Adapted from PR xcl-dev#2613.
Assisted-by: Codex (GPT-5.6-sol)

Assisted-by: Codex (GPT-5.6-sol)
Route console VS (hw == 4) and PS (hw == 5) FSSM variants in `xcl shaders
--precompile` through `recomp::pso::console_to_dxil_in_outcome` instead of
only the manual HLSL translate + compile_cached loop:

- Warms the `translated/v2` cache used at runtime for both direct graphics
  (`XCL_DIRECT_DXIL=all`) and HLSL graphics (`XCL_DIRECT_DXIL=0`), warming
  at most one runtime VS and one runtime PS variant per container while
  keeping ES/GS skipped counting and Mode::Mesh handling unchanged.
- Adds `recomp::pso::console_to_dxil_in_status` returning `(Compiled, bool)`
  and typed `recomp::pso::CompileOutcome` / `console_to_dxil_in_outcome`
  (sharing `INCOMPLETE_TRANSLATION_PREFIX` across both cold translations
  and `.err`-cached lookups) so `--precompile` increments `already cached`
  on in-memory or `translated/v2` disk cache hits and `compiled` only when
  translation or compilation actually runs. On `CompileOutcome::Incomplete`,
  falls through to the existing per-program `recomp::translate` loop (keeping
  `Mode::Vertex` / `Mode::Pixel` arms intact) so both standalone
  `--precompile` and hosted `prepare_for_launch` (xcl-dev#2555) preserve exact
  skip semantics without failing startup on unsupported shaders.
- Reports explicit standalone PS `sampler_base=0` coverage alongside counts
  of PS and VS records carrying static samplers (which shift paired PS bases
  at pipeline creation).
- Updates `crates/xcl/tests/shaders_e2e.rs` for `xcl-dev#1942`'s shared `container`
  helper and adds fresh-process end-to-end tests covering direct VS/PS
  warming, HLSL static-sampler `sampler_base=0` hit vs `sampler_base=1`
  miss, and incomplete VS (`v_cvt_off_f32_i4`) skip + supported VS warming
  across cold and warm `.err`-cached runs.

Part of xcl-dev#2600
Part of xcl-dev#2508
Part of xcl-dev#1833

Assisted-by: Google Antigravity (Gemini 4 Neon)
@Decodere
Decodere force-pushed the fix-precompile-runtime-graphics-variants-2600 branch from d68c74e to fddd2d7 Compare November 27, 2026 15:59
@Decodere

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto main (f9a0cb80 / #1871) at fddd2d71678df6001b8b58f43a60e8cf22d94806 (preserving #1871's xcl pso-precompile, --records, --used, and make_pipelines behavior), updated the PR description, and re-verified on RTX 4060 (0 new clippy warnings, 3x Debug & Release shaders:: 13/0/0 + --test shaders_e2e 12/0/0, paired 60 s XCL_PREPARE=0 smoke 1595 vs 1579 frames, 0 device removals/crashes).

AI disclosure: Google Antigravity (Gemini 4 Neon) resolved the shaders.rs conflict, ran local verification, and updated the PR.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Merge status (I have been asked to prepare merges of PRs with several independent tests; the bar is: no open critical finding or performance regression, a fresh check of the merge result against today's main, and green required checks. Each merge is still confirmed by a person.)

This one merges cleanly into main 6089122a and both checks are green, but the head fddd2d7 was pushed today after the rebase and I find no independent run on it (the eight earlier reports are on older heads, and three findings fixed since then were not re-confirmed by their reporters). One independent test of the current head, ideally by one of the earlier testers, and it is ready for the pre-merge review from my side. It also touches gpu/recomp/pso.rs: a line in the description on whether translated output or cache keys change would help testers.

AI use: Claude Code (Claude Fable 5.2).

@Decodere

Copy link
Copy Markdown
Contributor Author

Thanks @throny for the clean merge check on #2613.

Added the requested clarification to the PR description under crates/xcl/src/gpu/recomp/pso.rs (zero code changes pushed; head remains fddd2d71678df6001b8b58f43a60e8cf22d94806):

  • No change to translated DXIL output or cache keys: console_to_dxil_in_status and console_to_dxil_in_outcome wrap the exact same ShaderKey and translated::cached lookup, and INCOMPLETE_TRANSLATION_PREFIX ("incomplete translation, ") is byte-identical to the prior error prefix — existing DXIL/HLSL caches remain valid without re-translation.
  • Also confirming that @luckyteagirl's earlier review note (compiled vs cached hits) was addressed prior to this head in d68c74e5 / fddd2d71 (from_cache: bool + warm second-run assertion).

Welcoming an independent run on fddd2d71 so this is ready for your pre-merge review.


AI disclosure: comment drafted and PR description updated by Google Antigravity (Decodere) based on the verified fddd2d71 diff.

@thehollowedone

Copy link
Copy Markdown
Contributor

I found one precompile coverage regression on head fddd2d71. --precompile promises to visit every program, but the new runtime-cache helper selects only the first program of the first matching graphics FSSM. On success, the loop skips its companion programs; the warmed_vs/warmed_ps guard also skips later FSSMs of that stage. If the first FSSM is empty, the helper fails while a valid later FSSM goes unwarmed.

Two synthetic PS fixtures reproduce this without a title: one has two programs plus a later PS FSSM; the other has an empty first PS FSSM and a valid second one. With the two test additions on the untouched head, cargo test --offline --locked -j 4 -p xcl --test shaders_e2e precompile_keeps_ -- --nocapture failed 0/2 (the first fixture compiled 1 instead of 3; the second reported FSSM without a program). The candidate below passed 2/2, and the complete shaders_e2e target passed 14/14. cargo test --offline --locked -j 4 -p xcl --lib shaders:: -- --test-threads=4 passed 13/13.

The candidate handles only the runtime-selected first program through console_to_dxil_in_outcome; it leaves companion programs and later FSSMs on the prior loop. It records the first hardware match before checking its interface or program count, so a later FSSM cannot be mistaken for the runtime's selection. An Incomplete outcome counts the selected program as a hosted skip without immediately retranslating it. A selected one-program FSSM returns before allocating the old loop's jobs vector.

Full cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 --quiet on Windows 11 build 26300, RTX 3080 Ti / 621.35, Rust 1.99.1, DXC 1.8.2502.11: candidate 1,465 passed / 4 failed / 47 ignored / 25 GPU skip notices; untouched head with the same two tests 1,463 passed / 6 failed / 47 ignored / 25 skip notices. The four shared failures were console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk and three e2e test-title cases. The only additional failures on the untouched head were the two new regressions.

Not tested: retail precompile, paired smoke, rendered graphics, AMD or Intel. This is an uncommitted candidate for the author to adapt and verify on a clean head. AI use: Codex (GPT-6.2 Sol) wrote and ran the candidate and tests; Codex (GPT-6.2 Astra) reviewed the selection and loop invariants.

Candidate source and regression diff
diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs
index c56e5300..1627d9a4 100644
--- a/crates/xcl/src/shaders.rs
+++ b/crates/xcl/src/shaders.rs
@@ -1915,50 +1915,53 @@ fn precompile(input: &Input, limit: usize, windows: u32, split: Option<bool>, on
                     record_done();
                     continue;
                 }
-                let (mut warmed_vs, mut warmed_ps) = (false, false);
+                let (mut seen_vs, mut seen_ps) = (false, false);
                 for f in &sh.fssm {
+                    let first_hw_stage = match f.stages.first().map(|s| s.hw) {
+                        Some(4) if !seen_vs => { seen_vs = true; Some(recomp::pso::Stage::Vertex) }
+                        Some(5) if !seen_ps => { seen_ps = true; Some(recomp::pso::Stage::Pixel) }
+                        _ => None,
+                    };
                     let Some(mode) = recomp::interface(&blob, &sh, f) else { continue };
-                    let runtime_stage = match (&mode, f.stages.first().map(|s| s.hw)) {
-                        (recomp::Mode::Vertex(_), Some(4)) => Some((recomp::pso::Stage::Vertex, &mut warmed_vs)),
-                        (recomp::Mode::Pixel(_), Some(5)) => Some((recomp::pso::Stage::Pixel, &mut warmed_ps)),
+                    let mut handled_first_program = false;
+                    let runtime_stage = match (&mode, first_hw_stage) {
+                        (recomp::Mode::Vertex(_), Some(recomp::pso::Stage::Vertex)) => Some(recomp::pso::Stage::Vertex),
+                        (recomp::Mode::Pixel(_), Some(recomp::pso::Stage::Pixel)) => Some(recomp::pso::Stage::Pixel),
                         _ => None,
                     };
-                    if let Some((stage, warmed)) = runtime_stage {
-                        if *warmed || f.programs.is_empty() {
-                            continue;
-                        }
-                        *warmed = true;
-                        match recomp::pso::console_to_dxil_in_outcome(&blob, stage, 0, graphics_split, windows) {
-                            recomp::pso::CompileOutcome::Compiled { compiled: c, from_cache } => {
-                                if stage == recomp::pso::Stage::Pixel {
-                                    ps_base0.fetch_add(1, Ordering::Relaxed);
-                                    if !c.samplers.is_empty() {
-                                        ps_static_samplers.fetch_add(1, Ordering::Relaxed);
+                    if let Some(stage) = runtime_stage {
+                        if !f.programs.is_empty() {
+                            handled_first_program = true;
+                            match recomp::pso::console_to_dxil_in_outcome(&blob, stage, 0, graphics_split, windows) {
+                                recomp::pso::CompileOutcome::Compiled { compiled: c, from_cache } => {
+                                    if stage == recomp::pso::Stage::Pixel {
+                                        ps_base0.fetch_add(1, Ordering::Relaxed);
+                                        if !c.samplers.is_empty() {
+                                            ps_static_samplers.fetch_add(1, Ordering::Relaxed);
+                                        }
+                                    } else if !c.samplers.is_empty() {
+                                        vs_static_samplers.fetch_add(1, Ordering::Relaxed);
+                                    }
+                                    if from_cache {
+                                        cached.fetch_add(1, Ordering::Relaxed);
+                                    } else {
+                                        compiled.fetch_add(1, Ordering::Relaxed);
                                     }
-                                } else if !c.samplers.is_empty() {
-                                    vs_static_samplers.fetch_add(1, Ordering::Relaxed);
                                 }
-                                if from_cache {
-                                    cached.fetch_add(1, Ordering::Relaxed);
-                                } else {
-                                    compiled.fetch_add(1, Ordering::Relaxed);
+                                recomp::pso::CompileOutcome::Incomplete(_) => {
+                                    if startup.is_some() { skipped.fetch_add(1, Ordering::Relaxed); }
                                 }
-                                continue;
-                            }
-                            // Incomplete translation (`!t.complete()`): fall through to the existing
-                            // per-program loop below so standalone `--precompile` and hosted
-                            // `prepare_for_launch` keep their exact skip behavior without errors.
-                            recomp::pso::CompileOutcome::Incomplete(_) => {}
-                            recomp::pso::CompileOutcome::Failed(e) => {
-                                let mut g = errors.lock().unwrap();
-                                if g.len() < 10 {
-                                    g.push(format!("{name}: {}", e.lines().find(|l| l.contains("error")).unwrap_or(e.lines().next().unwrap_or(""))));
+                                recomp::pso::CompileOutcome::Failed(e) => {
+                                    let mut g = errors.lock().unwrap();
+                                    if g.len() < 10 {
+                                        g.push(format!("{name}: {}", e.lines().find(|l| l.contains("error")).unwrap_or(e.lines().next().unwrap_or(""))));
+                                    }
+                                    failed.fetch_add(1, Ordering::Relaxed);
                                 }
-                                failed.fetch_add(1, Ordering::Relaxed);
-                                continue;
                             }
                         }
                     }
+                    if handled_first_program && f.programs.len() == 1 { continue; }
                     let jobs: Vec<(&str, Option<String>)> = match &mode {
                         recomp::Mode::Vertex(_) => vec![("vs_6_6", None)],
                         recomp::Mode::Pixel(_) => vec![("ps_6_6", None)],
@@ -1969,7 +1972,7 @@ fn precompile(input: &Input, limit: usize, windows: u32, split: Option<bool>, on
                             continue;
                         }
                     };
-                    for p in &f.programs {
+                    for p in f.programs.iter().skip(usize::from(handled_first_program)) {
                         let code = &f.data[p.offset..p.offset + p.len];
                         // as `pso` translates: with the title's memory windows (`console_translation`,
                         // `translate_mesh`)
diff --git a/crates/xcl/tests/shaders_e2e.rs b/crates/xcl/tests/shaders_e2e.rs
index 7003b95d..80c3d602 100644
--- a/crates/xcl/tests/shaders_e2e.rs
+++ b/crates/xcl/tests/shaders_e2e.rs
@@ -535,6 +535,65 @@ fn precompile_warms_hlsl_static_samplers_and_reports_base_shift() {
     assert!(c_out.contains("fresh_child_timing: mode=hlsl"), "{c_out}");
 }
 
+#[test]
+fn precompile_keeps_companion_programs_and_pixel_variants() {
+    if xcl::gpu::recomp::dxc::location().is_err() {
+        xcl::gpu::recomp::runner::skip_test("no DXC");
+        return;
+    }
+    use xcl::gpu::dxil::container::{signature_part, SigPartElement};
+    let (dir, cache) = (TempDir::new("two-program-ps"), TempDir::new("two-program-ps-cache"));
+    let ps_osg = signature_part(&[SigPartElement { stream: 0, name: "SV_Target".into(), index: 0, system_value: 64, comp_type: 3, register: 0, mask: 0xF, rw_mask: 0, min_precision: 0 }], &[]);
+    let mut code = static_sampler_code(0xF800_180F);
+    let mut second = static_sampler_code(0xF800_180F);
+    second[36..40].copy_from_slice(&0x0D0C_0B0Bu32.to_le_bytes());
+    code.extend_from_slice(&second);
+    let mut third = static_sampler_code(0xF800_180F);
+    third[36..40].copy_from_slice(&0x0D0C_0B0Cu32.to_le_bytes());
+    let blob = xbox_shader_with_osg(0, &[fssm(&code, &[(5, 1)]), fssm(&third, &[(5, 1)])], &ps_osg);
+    assert_eq!(xcl::gpu::xbox::parse(&blob).unwrap().fssm.iter().map(|f| f.programs.len()).collect::<Vec<_>>(), vec![2, 1]);
+    std::fs::write(dir.path().join("ps.bin"), blob).unwrap();
+    let run = || Command::new(env!("CARGO_BIN_EXE_xcl"))
+        .args(["shaders", dir.path().to_str().unwrap(), "--precompile", "--windows", "1", "--split", "0"])
+        .env("XCL_DIRECT_DXIL", "0")
+        .env("XCL_DXIL_CACHE", cache.path())
+        .env_remove("XCL_TRANSLATED_CACHE")
+        .output()
+        .expect("spawn xcl shaders --precompile");
+    let cold = run();
+    let text = String::from_utf8_lossy(&cold.stdout);
+    assert!(cold.status.success(), "{cold:?}");
+    assert!(text.contains("compiled 3, already cached 0, errors 0"), "{text}");
+    let warm = run();
+    let text = String::from_utf8_lossy(&warm.stdout);
+    assert!(warm.status.success(), "{warm:?}");
+    assert!(text.contains("compiled 0, already cached 3, errors 0"), "{text}");
+}
+
+#[test]
+fn precompile_keeps_a_pixel_variant_after_an_empty_first_variant() {
+    use xcl::gpu::dxil::container::{signature_part, SigPartElement};
+    if xcl::gpu::recomp::dxc::location().is_err() {
+        xcl::gpu::recomp::runner::skip_test("no DXC");
+        return;
+    }
+    let (dir, cache) = (TempDir::new("empty-first-ps"), TempDir::new("empty-first-ps-cache"));
+    let ps_osg = signature_part(&[SigPartElement { stream: 0, name: "SV_Target".into(), index: 0, system_value: 64, comp_type: 3, register: 0, mask: 0xF, rw_mask: 0, min_precision: 0 }], &[]);
+    let blob = xbox_shader_with_osg(0, &[fssm(&[], &[(5, 1)]), fssm(&static_sampler_code(0xF800_180F), &[(5, 1)])], &ps_osg);
+    assert_eq!(xcl::gpu::xbox::parse(&blob).unwrap().fssm.iter().map(|f| f.programs.len()).collect::<Vec<_>>(), vec![0, 1]);
+    std::fs::write(dir.path().join("ps.bin"), blob).unwrap();
+    let out = Command::new(env!("CARGO_BIN_EXE_xcl"))
+        .args(["shaders", dir.path().to_str().unwrap(), "--precompile", "--windows", "1", "--split", "0"])
+        .env("XCL_DIRECT_DXIL", "0")
+        .env("XCL_DXIL_CACHE", cache.path())
+        .env_remove("XCL_TRANSLATED_CACHE")
+        .output()
+        .expect("spawn xcl shaders --precompile");
+    let text = String::from_utf8_lossy(&out.stdout);
+    assert!(out.status.success(), "{out:?}");
+    assert!(text.contains("compiled 1, already cached 0, errors 0"), "{text}");
+}
+
 #[test]
 fn precompile_skips_incomplete_vs_while_warming_supported_vs() {
     use xcl::gpu::recomp::{dxc, pso};

@UncommonDLL

Copy link
Copy Markdown

@Decodere @throny We ran precompile_skips_incomplete_vs_while_warming_supported_vs unchanged on Windows at fddd2d71678df6001b8b58f43a60e8cf22d94806, using Rust 1.100.0 and DXC 1.9.2609.5. The cold run compiled one shader. The warm run compiled zero and found one already cached. Both reported zero errors. In a fresh process, the supported vertex shader hit the cache-only path with zero DXC cache-miss compilations at that check. The unsupported shader returned Incomplete for v_cvt_off_f32_i4.

Cargo exited 0 with one test passed and 11 filtered out. This fixture covers the vertex-shader cache path. The companion pixel-shader cases reported above exercise a separate path. OpenAI Codex ran the test with PowerShell and Cargo.

Fix the --precompile coverage regression caught by @thehollowedone on
fddd2d7 (xcl-dev#2613#issuecomment-7223511423):

- In `crates/xcl/src/shaders.rs` (`precompile`), record the first VS
  (`hw == 4`) and PS (`hw == 5`) FSSM match (`seen_vs`/`seen_ps`) before
  `recomp::interface` to match `pso.rs::console_translation`, so an empty
  or `interface == None` first FSSM cannot steer a later valid FSSM into
  `console_to_dxil_in_outcome` and fail with `FSSM without a program`.
- Route only `f.programs[0]` of that first matching FSSM through
  `console_to_dxil_in_outcome`, count `Incomplete` skips directly on
  `startup.is_some()` without re-translating `programs[0]`, short-circuit
  only when `handled_first_program && f.programs.len() == 1`, and iterate
  `f.programs.iter().skip(usize::from(handled_first_program))` so
  companion programs and subsequent FSSMs retain full --precompile
  coverage.
- Add `precompile_keeps_companion_programs_and_pixel_variants` and
  `precompile_keeps_a_pixel_variant_after_an_empty_first_variant` (cold
  compile + warm cache hits, 0 errors) in `crates/xcl/tests/shaders_e2e.rs`.

Part of xcl-dev#2600
Part of xcl-dev#2508
Part of xcl-dev#1833
Assisted-by: Google Antigravity (Gemini 4 Neon)
@Decodere

Copy link
Copy Markdown
Contributor Author

Great catch, @thehollowedone — thank you for the clean repros and analysis, and thanks @UncommonDLL for confirming the VS cache-only path on Windows!

I pushed follow-up commit ffa475a38d0356e8a4f17be8f2c014b43b0e5a37 (Shaders: keep companion programs and later FSSMs in --precompile) fast-forward onto fddd2d71 addressing all three parts of the coverage regression (cc @throny for visibility):

  1. Match pso.rs::console_translation's exact first-FSSM selection (crates/xcl/src/shaders.rs):
    • Replaced warmed_vs/warmed_ps with seen_vs/seen_ps recorded on the first hw == 4|5 FSSM before recomp::interface, so an empty or interface == None first FSSM cannot steer a later valid FSSM into console_to_dxil_in_outcome and fail with FSSM without a program.
    • Routed only f.programs[0] of that first matching VS/PS FSSM through console_to_dxil_in_outcome, counted CompileOutcome::Incomplete directly on startup.is_some() without re-translating programs[0], short-circuited only when handled_first_program && f.programs.len() == 1, and iterated f.programs.iter().skip(usize::from(handled_first_program)) so companion programs (f.programs[1..]) and subsequent FSSMs retain full --precompile coverage.
  2. Regression tests added (crates/xcl/tests/shaders_e2e.rs):
    • Added precompile_keeps_companion_programs_and_pixel_variants and precompile_keeps_a_pixel_variant_after_an_empty_first_variant (both checking cold compile + warm cache hit counts and 0 errors).
  3. Verification on ffa475a38d0356e8a4f17be8f2c014b43b0e5a37 (RTX 4060, Windows 11, rustc 1.100.0, DXC 1.9.2609.5):
    • Failing-first on unmodified fddd2d71: 0 passed; 2 failed (compiled 1 instead of 3; errors 1 ... FSSM without a program).
    • cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition: exit 0, 0 new warnings in touched files.
    • 3x Debug + 3x Release shaders::: 13 passed; 0 failed; 0 ignored.
    • 3x Debug + 3x Release --test shaders_e2e: 14 passed; 0 failed; 0 ignored; 0 skipped.
    • Clean cargo build --release -p xcl + quiet 60 s XCL_PREPARE=0 RTX 4060 smoke (title: 29640639): 1606 frames (PresentX 1606), 60 60 60, 0 device removals, 0 crashes, 14019 MB peak commit (vs f9a0cb80 1579 frames / 13996 MB).
    • PR description updated with the new commit, test counts, smoke block, and preserved pso.rs no-DXIL/no-cache-key-change clarification.

Ready for re-check whenever you have a moment!

(AI use: Google Antigravity (Gemini 4 Neon) adapted the fix and regression tests credited to @thehollowedone, ran failing-first/clippy/tests/smoke verifications, and drafted this reply.)

@UncommonDLL

Copy link
Copy Markdown

@Decodere We re-checked ffa475a38d0356e8a4f17be8f2c014b43b0e5a37 on Windows with DXC 1.9.2609.5. Both unchanged pixel-shader cache tests passed. Cargo exited 0 with two passed, zero failed, zero ignored and zero runtime skips.

The companion-program fixture compiled three shaders cold and found all three in cache on the warm run. The empty-first fixture compiled one shader cold and found it in cache on the warm run. Both fixtures reported zero errors on both passes. Their original assertions checked the captured child output. We used your failing-parent control. OpenAI Codex ran the tests through PowerShell and Cargo.

Prime1997 pushed a commit that referenced this pull request Nov 28, 2026
Route standalone VS and PS variants through the exact runtime console_to_dxil_in path so precompile warms translated/v2 serialization and the selected HLSL/direct-DXIL backend instead of only manually warming HLSL output.

Selection matches the runtime's first hardware VS/PS FSSM and exact stage, split, windows, and base-zero keys. Paired PS variants with nonzero VS sampler bases remain cold because the shader archive has no pipeline pairing data.

GNU Windows-target cargo check passed. Fresh-cache Windows probes, GPU execution, and retail smoke were not available on this host.

Adapted from PR #2613.
Assisted-by: Codex (GPT-5.6-sol)

Assisted-by: Codex (GPT-5.6-sol)
@bmjask

bmjask commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Current-main audit (2026-11-29): implemented/superseded; please close this PR.

Current main now has standalone_graphics_variants, warms the runtime-selected first VS/PS variants, and—more importantly—prepares exact graphics history recipes through the graphics worker/corpus path, including the actual paired fixed-function/static-sampler state this PR could not infer from standalone records. The companion/later-FSSM coverage is also present in the evolved precompile path.

Merging this stale conflicted implementation would duplicate older preparation logic. Cache impact of the concept is safe because it warms existing identities rather than changing shader output, but there is no remaining patch to carry.

Review assisted by Codex; exact model name was not exposed in this session.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #2928 #2950 solves the same problem in a different way: #1607, group D148. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head ffa475a

Main commit 03241a5 (merged with #2959) is adapted from this PR. Through standalone_graphics_variants, it sends the runtime-selected VS/PS (first hardware stage 4/5 FSSM, sampler base 0) through pso::console_to_dxil_in in xcl shaders --precompile.
What main does not take from this PR:

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.