Shaders: adaptive DXC memory budget & direct-DXIL mesh/graphics precompilation #2950
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2950"
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 POMXARK on 2026-11-27T03:54:40Z.
Speeds up cold shader precompilation and prevents host OOM / stalled launches by adapting DXC/pipeline concurrency to available host resources, routing
Mode::Meshand direct graphics (Vertex/Pixel) stages throughpsoduringprecompile(), and allowingXCL_PIPELINE_MAX_KB-capped compute pipelines to defer cleanly to runtime.What is in it
crates/xcl/src/gpu/recomp/dxc.rs(0093a63):estimate_compile_mb) and dynamically scale active compile budget/permits against available host commit/RAM with a 3.0 GB floor (wait_for_memory_for).crates/xcl/src/shaders.rs(0093a63,2879c5b,0b3729b):default_pipeline_threads(4..=12) from CPU thread count and host RAM.Mode::Mesh(NGG) containers throughpso::console_mesh_insotranslated/v2caching andXCL_DIRECT_DXILmatch runtime pipeline creation instead of unconditionally falling back to HLSL + DXC (~35%of shader packs).XCL_DIRECT_DXIL=allis active, route standaloneVertexandPixelstages throughpso::console_to_dxil_in.XCL_PIPELINE_MAX_KB-capped compute pipelines to stay deferred to runtime during startup preparation instead of failingprepare_for_launchwith an error after translation finishes cleanly (0failures,0refused pipelines).crates/xcl/src/gpu/recomp/pso.rs(2879c5b):pub fn console_mesh_in(blob, ps, split_wave64, windows)and add unit testconsole_mesh_in_forwards_windows_and_populates_cache.Tested
32.0.16.2124), AMD Ryzen 7 5700X (8C/16T),rustc 1.91.1 (ed61e7d7e 2025-11-07), DXC/DXIL1.8.2502.11, release build--locked.cargo test -p xcl --lib dxc -- --test-threads=4(on0093a63):45 passed, 0 failed, 3 ignored(dump_dxc_lowering,blob_dxc_cost,dxc_time_levels)cargo test -p xcl --lib pso -- --test-threads=4(on2879c5b):53 passed, 0 failed, 1 ignored(repeated_pso_shader_compile)cargo test -p xcl --lib shaders -- --test-threads=4(on0b3729b):17 passed, 0 failed, 0 ignoredcargo test -p xcl --test shaders_e2e -- --test-threads=4(on0b3729b):8 passed, 0 failed, 0 ignored--precompilebenchmarks on an anonymized 26,503-record RPF9 corpus (NVMe SSD):--precompile --limit 300(HLSL default):18.33 s(main) ->14.196 s(0093a63, avg9.39/16cores,0errors)--precompile --limit 500(XCL_DIRECT_DXIL=all):23.278 swall /22.9 sinternal (0093a63,548.dxil,15.68 MB,0errors) ->2.014 swall /1.1 sinternal (2879c5b,48.dxil+500translated/v2,12.31 MB-21.5%, ~20.8x internal speedup,0errors)--precompile(XCL_DIRECT_DXIL=all, empty cache):311.8 sinternal /322.215 swall (5m 12s),26,308compiled (25,694translated/v2+677passthrough.dxil,3,723.93 MB),0errors,390paired GS skipped, avg11.32/16cores, peak1.72 GB WS / 1.79 GB PM.--direct --sample 2000 --max-bytes 0 --validate --threads 12):2000/2000 (100.0%)translated & validated in31.0 s(CS 205,GS 35,MS 708,PS 874,VS 178,0unsupported/validator errors/panics/timeouts).Regression run
Draft PR pending clean
scripts/smoke.ps1xcl-smoke v1runs onmainand0b3729b(earlier 60s launch on warmtranslated/v2cache finished shader preparation cleanly and entered the title, then aborted at 47s due to low free space on the host system drive forpagefile.sys).Not tested
cargo test --workspaceon0b3729b, non-NVIDIA GPUs, and a completed 60sscripts/smoke.ps1run.AI use
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:07:43Z.
On
0b3729b1c7ada92b28666d05942c02ea3e7d9ba4, an unused loose pixel shader with one unsupported instruction prevents guest entry whenXCL_DIRECT_DXIL=all. The same guest and shader start successfully on the PR’s base,8b957bec6f82495aec940944c6bf47faa02db590.I ran six fresh
xcl runprocesses on an RTX 5070 with isolated data and shader caches, using unmodified executables from each revision and the repository’s synthetic title. I placed one pixel shader in the title’sshadersdirectory. The unsupported variant replaces one instruction withv_cvt_off_f32_i4. The guest does not request that shader.all0allEvery exit-0 guest reported zero fixture failures. The failing launch reported
incomplete translation, missing: ["v_cvt_off_f32_i4"], with zero refused pipelines and zero pipelines over the size cap. The direct-graphics precompile route counts this incomplete translation as a hard failure. The existing per-program path skips it.PR #2613 addressed this distinction for graphics warmup by retaining the old per-program fallback for incomplete translations. Its treatment of
CompileOutcome::Incompleteis relevant here. Related PR #2613This test covers launch admission for a synthetic pixel shader. Retail shader incidence, performance and world loading were not measured. AI use: OpenAI Codex with GPT-6.2 Astra adapted the synthetic shader, built both revisions and ran the paired launches; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T04:09:56Z.
I checked the reservation boundary in
wait_for_memory_foron0b3729b. The headroom check readsRESERVED_MBbefore the OS query and later adds to it separately. Multiple workers can all admit themselves using the same pre-reservation state.In an isolated Windows Rust harness, I used the exact admission code and replaced only the memory query with a synchronized test source. It released eight workers from their first query with 3 GiB reserve plus 128 MiB available. Each job requested the 128 MiB estimate. With no priority bypass and no timeout reached, 8/8 workers entered while the first permits were still held, reserving 1,024 MiB against the 128 MiB budget, in 5/5 trials. Main
8b957becalso admitted 8/8 with the same coordinated snapshots, so the check/reserve race predates the estimates.A local control sampled memory first, then serialized the headroom check and permit acquisition under one mutex. 1/8 entered before release, 128 MiB reserved, in 5/5 trials. All eight finished and the counters returned to zero in both variants. This is a deterministic admission-policy test with injected headroom. It does not measure actual commit use, a compiler OOM, or retail performance.
OpenAI Codex assisted with verification.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:11:42Z.
I tested a local fix on #2950 head
0b3729b1. If the runtime graphics translator reports an incomplete vertex or pixel translation, precompilation falls through to the existing per-program path for that shader variant. Successful direct translations retain their current route. Other errors keep their original failure behavior. This follows the incomplete-translation distinction used by #2613.On native Windows with an RTX 5070 and the repository’s synthetic guest, the unused pixel shader containing
v_cvt_off_f32_i4now produced one skip and exit 0 withXCL_DIRECT_DXIL=all, both cold and when a fresh process read its cached incomplete-translation reason. Unmodified #2950 produced one error and exit 2. The supported direct shader and the unsupported shader with direct graphics disabled also reached guest entry and finished with zero fixture failures. A separate negative control injected a non-incomplete reason into an isolated refusal-cache record. The local fix preserved the hard error and stopped before guest entry with exit 2.A new regression test builds a single synthetic container with two pixel shader variants, placing the incomplete variant first and a supported one second. Stock #2950 compiled zero variants and reported two errors. The local fix compiled the supported variant and reported zero errors. All nine tests in
shaders_e2epassed on the candidate.These results cover graphics precompilation with synthetic inputs. The patch has not been submitted or tested on a retail title. AI use: OpenAI Codex with GPT-6.2 Astra adapted and independently reviewed the fallback and fixtures and ran the tests; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:14:49Z.
PR #2950 changes startup handling of an incomplete mesh translation
A synthetic guest reached its entry point on parent
8b957becand exited successfully. On PR head0b3729b1, the same guest exited 2 during shader precompilation. This reproduced withXCL_DIRECT_DXILunset, set to0, and set toall.The input was a loose 128-thread mesh shader with its PSV0 metadata intact. The unsupported variant changed one instruction to
v_cvt_off_f32_i4. Each run used fresh data and DXIL caches on Windows with the RTX 5070 selected.With explicit settings, the parent counted one unsupported translation as skipped. The head counted one error and zero skips, with the missing opcode in its diagnostic. The mesh branch calls
pso::console_mesh_inindependently of the direct vertex/pixel setting. Handling incomplete translation in the vertex/pixel branch alone leaves this startup failure reproducible.The test covers startup classification and guest entry. It contains no retail game data and measures no game performance. AI use: OpenAI Codex with GPT-6.2 Astra generated and ran the fixtures; Codex coordinated and prepared this follow-up.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:20:00Z.
Follow-up to the incomplete-mesh report: a local candidate treats only the explicit incomplete-translation result as a request to continue through the existing per-program path. Other mesh translation failures remain errors. It also keeps mesh variants out of the direct VS/PS-only filter during that fallback.
The synthetic two-variant mesh container has an incomplete first program and a supported second program. With direct DXIL both
0andall, the candidate compiled the compute/pass-through pair, skipped the incomplete program, and reached guest exit 0. The unmodified head exited 2 on the same input. Supported-only and incomplete-only controls passed with their expected compile/skip counts. A genuine undecodable instruction and a separate cached hard refusal remained fatal, each with one error and exit 2. Fresh and cached incomplete reasons both took the skip path.The repository shader integration suite passed 10/10, including the graphics and mixed-mesh regressions. The local combined patch was independently checked against the pristine head. This is synthetic startup evidence; GTA VI behavior and performance were not measured.
AI use: OpenAI Codex with GPT-6.2 Astra implemented, tested and independently reviewed the candidate; Codex coordinated and prepared this follow-up.
Imported from ivall/xcl. Originally posted by POMXARK on 2026-11-27T11:29:16Z.
Thanks for catching both blockers @andrewDoing @ettehn — both are fixed and verified, marking this ready for review:
Serialize
wait_for_memory_foradmission + reservation (@ettehn):Guarded availability checks,
WORKING, andRESERVED_MBupdates underMEMORY_GATE(MemoryGateState::try_admit/release) incrates/xcl/src/gpu/recomp/dxc.rsso concurrent DXC workers cannot read the same uncommitted budget and over-admit pastreserve + job_mb. Addedwait_for_memory_serializes_concurrent_admission_at_budget_boundarytesting 8 threads at the exact boundary (peak_active == 1).Non-fatal incomplete-translation fallback for direct graphics & Mesh (
@andrewDoing):Added
is_incomplete_translation_errorincrates/xcl/src/shaders.rs. Whenconsole_mesh_inor directconsole_to_dxil_inreturns"incomplete translation..."(cold or cachedXCLTERR1),precompile()falls back into the per-FSSM / per-program loop instead of incrementingfailed(preventing early exit 2 before guest startup on loose incomplete shaders, and allowing remaining supported FSSM variants in mixed containers to compile). Real decode/compile errors still incrementfailedas fatal. Covered bystartup_preparation_skips_incomplete_and_fails_on_decode_errorandshaders_precompile_skips_incomplete_and_keeps_hard_errors_for_graphics_and_mesh.Tests on Windows (release):
cargo check -p xcl --all-targets,wait_for_memory1/1,memory_budget1/1,console_mesh_in1/1,startup_preparation_skips_incomplete_and_fails_on_decode_error1/1,shaders_e2e9/9 PASS.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T12:10:16Z.
Independent Windows/NVIDIA full-suite check of #2950 head
897f0924. This is the current revision with the serialized memory gate and incomplete-translation fallback; the checkout was clean.Windows 11 build 26300, RTX 3080 Ti (12 GiB, NVIDIA 621.35), Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC available.
XCL_DXIL_CACHEpointed to a writable scratch cache.cargo build --offline --locked --workspace: passed.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet: 1,452 passed, 0 failed, 47 ignored across 38 targets. The log contained 25 GPU skip notices: 21 no native wave64, three refused per-lane f16/packed cases, and one no heap windows. These skips are not GPU coverage.The full-suite pass did not include a title or a cold full-pack precompile, nor AMD or Intel testing. The PR description still names older commits for its measured runs and has no clean-head smoke pair for
897f0924; this test report does not satisfy that runtime merge gate.AI use: Codex (GPT-6.2 Sol) ran the clean-head build and suite and checked the counts.
Update on the same head, against current main �6f90c1: I built clean release binaries from both commits and ran scripts/smoke.ps1 -Seconds 60 -Title retail-title under a 16 GiB process-tree commit guard and 12 GiB minimum system commit headroom, with separate copies of the same profile and DXIL cache seed. The first main attempt with default preparation timed out during startup before the guest timer; no smoke block was produced. With the documented XCL_PREPARE=0 setting, main completed the 60-second run. The guard exited normally, peaking at 15.91 GiB with at least 22.67 GiB system headroom.
Generated clean-main smoke block
The same XCL_PREPARE=0 setting on clean #2950 head
897f0924still entered mandatory preparation of 26,503 shaders and reached the script's 120-second startup limit before producing a log or valid smoke block. Its outer guard exited normally at 2.19 GiB peak; this is a smoke setup blocker, not a measured guest crash. That head predates main's XCL_PREPARE=0 preparation opt-out. Please rebase onto current main (or include the equivalent opt-out), then rerun the full suite and clean-head paired smoke after the push. I can retest the new head. The generated main block alone does not satisfy the PR's two-block gate. This run did not cover cold full-pack preparation or world load.AI use: Codex (GPT-6.2 Sol) built both clean revisions, ran the guarded smoke attempts, checked the generated block and traced the preparation difference.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T13:59:47Z.
Tested PR #2950 (
897f0924) on Windows 11 (Ryzen 5 5500 6C/12T, 32 GB RAM, NVIDIA GeForce RTX 3060 Ti 8 GB, driver32.0.16.2140).Unit & E2E tests
cargo test --locked -p xcl --lib -- wait_for_memory memory_budget console_mesh_in --nocapture:gpu::recomp::dxc::cache_tests::memory_budget_scales_with_hlsl_size_and_restores_on_drop— okgpu::recomp::dxc::cache_tests::wait_for_memory_serializes_concurrent_admission_at_budget_boundary— okgpu::recomp::pso::shader_cache_tests::console_mesh_in_forwards_windows_and_populates_cache— okcargo test --locked -p xcl --test shaders_e2e -- --nocapture:shaders_precompile_skips_incomplete_and_keeps_hard_errors_for_graphics_and_mesh).xcl shaders --precompile --pipelines --limit 1500checkRan cold-cache
--precompile --pipelines --limit 1500(XCL_DEVICE_TYPE=lockhart,XCL_DIRECT_DXIL=all):compiled 1500, already cached 0, errors 0, skipped (GS – paired at pipeline creation) 31, time 5.0 s(wall_s=6.58),rc=0.1500records of this title's pack,pipelines made on the GPUwas0(all compute GPU pipelines sit past that range), so this run exercised DXIL/graphics precompile cleanly while GPU compute pipeline gating was not exercised here.Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:51:46Z.
Two contributors checked independently and found that #2613 #2928 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:12:56Z.
Triage (#1607) – head
897f092Overlaps #2613 and #2928, which also route VS/PS through
pso::console_to_dxil_inin--precompile, and #1723 / #1724 / #1762, which also budget DXC memory by source size or RAM. Each solves it differently, so none is a duplicate.Problems in the diff:
dxc.rs), the default pipeline threads, the mesh and graphics routing, and the capped-pipeline rule.shaders.rsprecompile: droppingcappedfrom the failure condition changes main's rule that startup preparation stops when pipelines go overXCL_PIPELINE_MAX_KB.pso.rsconsole_mesh_in_forwards_windows_and_populates_cachebuilds windows=2 in a temp cache andmem_windows()in the global one and compares onlymax_vertices, so it does not show the windows being forwarded.perf(dxc):andfix(shaders,dxc):are not in the repository's style.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.