Skip to content

D3D12.X: persist both PSOs for translated mesh and geometry - #1942

Open
ZekkJJ wants to merge 3 commits into
xcl-dev:mainfrom
ZekkJJ:upstream/two-pass-driver-cache
Open

ZekkJJ wants to merge 3 commits into
xcl-dev:mainfrom
ZekkJJ:upstream/two-pass-driver-cache

Conversation

@ZekkJJ

@ZekkJJ ZekkJJ commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Persist driver blobs for the NGG compute pass (executes first) and the passthrough mesh graphics pass (executes second) for translated MS and VS+GS. Rejected blobs are evicted and retried under the cold-compile gate. Part of #1269, with NGG compute and canonical hashing overlap in #1836 and shared graphics-hashing and disk transport overlap in #902.

Stacked on #1941. Only 024b2e2dc51924965df478fdb4f63fbcae9dc0b2 belongs here.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs integrates both cache identities and uses the existing disk transport and RAM budget. crates/xcl/tests/gpu_two_pass_cache_e2e.rs exercises both console translation entry points, separate pass corruption, cross-process replay, disablement and actual GPU pixel output. The commit is 1,006 changed lines (350 runtime and unit-test lines, 656 GPU E2E lines). The synthetic console container, D3D12 dispatch and readback scaffolding make the test self-contained without a retail shader pack. The cache validation needs the runtime integration in the same review.

Tested

  • NVIDIA GeForce RTX 4060 Laptop GPU (8 GiB), driver 616.56, AMD Ryzen 7 8845HS, 16 GiB RAM, Windows 11 25H2 (26200.9974), Rust 1.98.1 (MSVC x64), Windows SDK 10.0.26100.0 (DXC/DXIL 1.8.2502.11). Debug tests and release smoke builds.
  • cargo build --locked --release -p xcl --jobs 1 succeeded on clean 024b2e2dc51924965df478fdb4f63fbcae9dc0b2 and baseline 689f2db477c3c062cf162649781640ef8a977c18.
  • .\scripts\test.ps1 (Cargo build jobs 1, test threads 4) on stack head 024b2e2dc51924965df478fdb4f63fbcae9dc0b2 reported 983 passed, 0 failed, 45 ignored across 21 targets. Explicit runtime SKIPPED markers (23) were 18 no native wave64, 3 refused wave32 per-lane operations, 1 Windows Developer Mode unavailable, 1 no heap windows. Optional sample-backed cases also returned early with their sample variables unset. GPU regressions for TRIANGLE replay and both-pass persistence ran without runtime skips.
  • Historical three-pipeline cold-to-warm times were 34.1× faster in process wall time and 133.5× faster in aggregate driver API time. Those measures include warmed translated DXIL and NVIDIA driver caches. On this exact head, two fresh-process trials each took 2.10–2.45 s with warmed caches and XCL disk persistence disabled (0/6 blobs) and 2.21–2.28 s with persistence enabled (6/6 blobs). The ranges overlap. The benchmark used a three-pipeline sample with XCL_DIRECT_DXIL=1 and XCL_HEAP_WINDOWS=1. Only the persistence threshold was at its default in the measured runs. The separate seed launch used a 0 ms threshold.
  • scripts/smoke.ps1 -Game <retail-folder> -Seconds 60 -Title 'Retail workload A' -Xcl <matching-release-binary> on the same anonymized retail workload. NVIDIA selected with XCL_ADAPTER=nvidia.

Regression run

main

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 4060 Laptop GPU
title: Retail workload A
seconds: 60
exit: 0x0
frames shown: 800 (PresentX 800)
presents per 2 s (last 3): 51 53 57
device removals: 0
crashes: 0
peak commit: 15846 MB

PR

xcl-smoke v1
commit: 024b2e2dc51924965df478fdb4f63fbcae9dc0b2
gpu: NVIDIA GeForce RTX 4060 Laptop GPU
title: Retail workload A
seconds: 60
exit: 0x0
frames shown: 771 (PresentX 772)
presents per 2 s (last 3): 44 42 42
device removals: 0
crashes: 0
peak commit: 15480 MB

Not tested

  • AMD, other driver builds, live adapter or driver changes, and native wave64 cases skipped on this adapter. The warmed benchmark covers three retail MS pipelines. Retail smoke coverage is limited to startup and frame production. Offline journal and replay are outside this stack.

AI use

  • OpenAI Codex (GPT-6, deployment variant unavailable) split and audited the code, added retry and accounting regressions, ran validation and benchmark controls, and drafted this description. The original implementation and investigation are archived in Google Antigravity; its model is unrecorded.

Use the passthrough mesh shader output topology on both translated MS and GS streams. Exercise cached replay against a synthetic triangle PSO.

Assisted-by: OpenAI Codex (GPT-6)
Hash the final driver inputs by value, with distinct compute and mesh domains and versioned ABI state. Exercise state sensitivity and padding independence without enabling persistence.

Assisted-by: OpenAI Codex (GPT-6)
Keep NGG compute and passthrough mesh graphics driver blobs under independent canonical keys. Retry rejected entries under the existing cold-compile policy and validate fresh-process replay, per-pass corruption, and GPU output on synthetic inputs.

Part of xcl-dev#1269. Related to xcl-dev#1836 and xcl-dev#902.

Assisted-by: OpenAI Codex (GPT-6)
@thehollowedone

Copy link
Copy Markdown

Independent check of 024b2e2 on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC and DXC 1.8.2502.11. The offline locked release workspace build passed. cargo test --offline --locked --release -p xcl --test gpu_two_pass_cache_e2e -- --nocapture --test-threads=1 passed 1/1 with zero skips. A separate cache-disabled run confirmed the RTX 3080 Ti and D3D12 debug-layer activation.

The fixture verified five disk hits in a fresh process, recovery when either pass’s blobs were rejected, and the expected pixel readbacks for both translated mesh and geometry. This covers the published stack with synthetic input. Integration with current main, the title’s ExecuteIndirect path, and retail performance remain untested here.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) ran the tests and drafted this report.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 024b2e2:

  • build_two_pass_pso, finish_two_pass, two_pass_driver_id, and crates/xcl/tests/gpu_two_pass_cache_e2e.rs look solid: mesh_pso is held by RAII if the compute pass fails, rejected RAM blobs also evict their disk counterparts before the cold-compile retry, and the E2E suite exercises both translated MS and VS+GS paths with corrupt-blob recovery and pixel readbacks.

What is needed before merge:

  1. Rebase onto current main (now CONFLICTING): main has since merged #1836 (80f4819, adding read_pso_cached_blob / driver_cache compute-pass caching in finish_two_pass), #1937 (2c95f01), and #1774 (de36462, big_compile_headroom in finish_two_pass). Please reconcile finish_two_pass with those changes and drop the already-merged #1937 hunks.
  2. Independent AMD verification on the rebased head (gpu_two_pass_cache_e2e + retail smoke), as current verification is NVIDIA-only (RTX 4060 Laptop and RTX 3080 Ti).

@gefydev gefydev 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.

Review of 024b2e2 (read against main bf9eebd; I did not build or run it).

This now overlaps #1836, which was merged. #1836 merged on 2026-11-25 00:04 UTC, after this PR was opened. That is why real.rs conflicts. On main, finish_two_pass already caches the compute pass blob in memory and on disk (compute_blob_key(&tp.cs, rs, 0), driver_cache::path(&tp.cs, 0)). #1836 also added GRAPHICS_BLOBS (256 MiB), graphics_path, graphics_blob_key (field-by-field state hashing, which avoids the padding problem) and read_pso_cached_blob. After a rebase, the compute half of this PR would be a second cache under a different key for the same blob. What is new is the mesh pass cache, which should go through GRAPHICS_BLOBS and graphics_blob_key rather than a separate hasher (two_pass_identity.rs in #1941), a second pso_cached_blob, and COMPUTE_BLOBS. #902 also keeps slow graphics pipeline blobs on disk.

No measured gain at this head. The fresh-process ranges overlap: 2.10–2.45 s with persistence off and 2.21–2.28 s with it on. The 34× figure is historical and includes warm DXIL and NVIDIA driver caches. A run on AMD, or on NVIDIA with the driver's shader cache cleared, would show whether this cache helps.

Code points:

  1. Shared RAM budget. Mesh blobs share the 512 MiB COMPUTE_BLOBS budget with ordinary compute blobs, and that cache has no eviction. With keep_ram = bytes >= COMPUTE_BLOB_MIN_DXIL || took >= min, nearly every MS+PS pair qualifies, so mesh blobs can crowd out the compute blobs the cache was made for.
  2. Misleading record in the compile log. driver_compile_identified gets the two-pass identity hash as record. That field is documented as the console record's hash that matches [SHADER] lines, so the logged "record" will not match anything.
  3. Removed diagnostic. The "two-pass … PSO gated: …, waited N ms" log is gone. The compile log now prints "huge, ungated here" for these builds and drops the slot wait time.
  4. XCL_PSO_DISK_CACHE_MIN_MS covers only the two-pass path. Ordinary compute keep() still uses KEEP. The variable is not documented in the README.
  5. Weakened assertion in an existing test. compute_blob_tests changes the exact before - 3 assertion to the total == sum invariant. This makes sense with the new concurrent test, but please say why in the description, or keep the exact check by giving that test its own key.
  6. Duplicated test helpers and stale expectations. The e2e re-implements the synthetic container helpers (fssm, xbch, dxil_part, mesh_psv) that already exist in shaders_e2e.rs, gpu/xbox.rs and gpu/recomp/mod.rs. Its tp-cs-* file and counter expectations change once the compute half is rebased onto #1836.
  7. AI use. "Google Antigravity; its model is unrecorded" does not meet CONTRIBUTING's requirement to name the exact model.

What is good: build_two_pass_pso takes at most one cold slot per pair and none for blob attempts. Eviction with Arc::ptr_eq handles another thread's replacement correctly. Owning the partial ID3D12PipelineState on failure is cleaner than the manual Release it replaces. The cross-process replay and corrupt-blob e2e is a strong test.

Suggested path: rebase onto main, drop the compute pass half (or explain why two keys for one blob are wanted), cache the mesh pass through GRAPHICS_BLOBS and graphics_blob_key, and add a measurement where the driver's own cache is cold.

Review written with Claude Code (Claude Opus 5.5); I checked each point against the code.

@JJAutoCompare

Copy link
Copy Markdown

PR #1942 GPU verification

D3D12.X: persist both PSOs for translated mesh and geometry

  • Live refs/pull/1942/head from origin was 024b2e2dc51924965df478fdb4f63fbcae9dc0b2. The assigned slot had no Git checkout, so the tests ran in a clean detached checkout under L:\XclTooling\sol-slot-8\source.
  • The fetched origin/main was 3da2abb81606df622610e009f0430de99aa9881c.
  • git merge-tree --write-tree origin/main HEAD exited 1 with a content conflict in crates/xcl/src/hle/d3d12x/real.rs.

Tested

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175, DoublePrecisionFloatShaderOps=0, and reported wave range 8–32. The suite logged the Arc A770 real D3D12 backend.
  • Rust 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.9.2609.5. Unoptimized dev/test profiles with debug info and incremental compilation disabled.
  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the GPU lock.
  • cargo test -p xcl --lib two_pass_identity::tests -- --show-output reported 4 passed, 0 failed, 0 ignored. cargo test -p xcl --lib two_pass_blob_tests -- --show-output reported 2 passed, 0 failed, 0 ignored. Neither run emitted skip markers.
  • Under Invoke-ArcTest.ps1, cargo test -p xcl --test gpu_two_pass_cache_e2e -- --show-output reported 1 passed, 0 failed, 0 ignored, and no skip markers. It exercised cache disablement, cold writes, warm reuse, corrupt blob recovery, and draw readback for translated mesh and geometry. It also passed in the full suite.
  • One locked pass of cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101. Totals across 20 test binaries and one doctest target were 958 reported passed, 25 failed, 45 ignored. There were 25 SKIPPED markers across 15 binary/test pairs. The markers include skipped subcases and represent gaps in coverage.
  • Skip reasons comprised 17 native wave64 subcases, 3 refused wave32 per-lane forms, and one each for tiled-resource tier below 2, no heap windows, missing d3d12SDKLayers.dll, unavailable D3D12 debug layer, and inability to disable the driver cache. The complete marker list is in pr1942-suite-skips.txt. Full output is in pr1942-suite.log.

Failures

Twenty library tests failed at CreateComputePipelineState with 0x80070057 (invalid parameter).

  • gpu::dxil::fuzz_tests: fuzz_validate_and_gpu_0 (seed 2), fuzz_validate_and_gpu_1 (506), fuzz_validate_and_gpu_2 (1003), fuzz_validate_and_gpu_3 (1501).
  • gpu::dxil::ops_tests: doubles_match_cpu, groupshared_barrier_and_atomics_run.
  • gpu::dxil::round_tests: gpu_direct_f32_round_modes_dynamic_and_denormals, gpu_direct_f32_round_modes_static.
  • gpu::recomp::lower_dxil::tests: f64_programs_on_the_gpu.
  • gpu::recomp::tests: gpu_clamp_and_omod_per_instruction, gpu_f64_class_compare, gpu_f64_compares_with_nan, gpu_f64_literal_high_word, gpu_f64_math_random, gpu_f64_roots, gpu_f64_rounding_and_conversions, gpu_float_compares_random, gpu_frexp_f64_exp_and_mant, gpu_ldexp_f64, gpu_rndne_f64.

Four other library tests under gpu::recomp::tests failed assertions.

  • In gpu_nonfused_mad_and_mac_prevent_fma_contraction, the fused overflow control returned infinity.
  • In gpu_ps_image_sample_offset_implicit_lod_between_mips, pixel (0, 0) was 25.609375, expected 26.
  • In gpu_valu_16_and_64_bit, the lane 0 v_add_f16 high-half preservation assertion failed.
  • In gpu_wave64_ps_whole_wave_reductions, pixel 0 returned [2, 217, 2], expected [2, 216, 2].

The e2e.rs test test_title_runs_and_game_folder_is_untouched failed the dynamic depth bias check for RSSetDepthBiasX(-1000.5). The top-right pixel was blue, expected green.

Not tested

  • No suite run on origin/main for comparison. The baseline behavior of the failing tests remains unverified.
  • No retail-title scripts/smoke.ps1 runs on main or the PR head. No AMD or NVIDIA adapter coverage.

AI use

  • T3 Code / Codex (gpt-6.2-sol) ran the build and tests and drafted this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against pr1942-suite.log and published this report.
All 25 GPU SKIPPED entries
SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)
SKIPPED placed_title_textures_share_vram_and_preserve_pixels: tiled tier < 2
SKIPPED test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants