Skip to content

Direct DXIL: defer cold console_geometry during cached_only PSO probes - #2103

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1269-dxil-gs-defer
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-1269-dxil-gs-defer

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

What is in it

Adds the missing dxc::defer() guard to the direct DXIL branch of console_geometry() in crates/xcl/src/gpu/recomp/pso.rs, matching compile_console_shader (CS, VS, PS) and compile_console_mesh (MS):

  • Root cause: real.rs wraps translated_graphics_pso (including translated_gs_pso -> pso::console_geometry) in dxc::cached_only() during async PSO cache probes. While compile_console_shader (CS/VS/PS) and compile_console_mesh (MS) all check if dxc::defer() { return Err("DXIL not compiled yet".into()); } before cold direct DXIL translation, console_geometry omitted that check. Under XCL_DIRECT_DXIL=1 + dxc::cached_only(), it ran kernel::translate_geometry() synchronously on the render thread — and when mesh_passthrough_for() was already warm in DXC's cache, dxc::cached_only() returned (Ok(TwoPass), missed = false) instead of deferring.
  • Fix (crates/xcl/src/gpu/recomp/pso.rs):
    • Factor console_geometry_with(vs, gs, ps, split_wave64, direct: bool) so unit tests can exercise both the direct DXIL and HLSL paths without mutating XCL_DIRECT_DXIL, keeping console_geometry calling it with crate::gpu::dxil::kernel::enabled().
    • Add if dxc::defer() { return Err("DXIL not compiled yet".into()); } at the top of if direct { ... } right before kernel::translate_geometry, leaving the HLSL path (direct = false) unchanged.
  • Tests (geometry_defer_tests in crates/xcl/src/gpu/recomp/pso.rs):
    • direct_console_geometry_defers_during_cached_only_even_with_warm_passthrough: constructs minimal synthetic console VS(ES)+GS containers, runs console_geometry_with(..., true) once outside dxc::cached_only (confirming direct DXIL succeeds and warming mesh_passthrough_for in DXC's cache), then verifies dxc::cached_only(|| console_geometry_with(..., true)) returns Err("DXIL not compiled yet") with missed == true.
    • hlsl_console_geometry_keeps_warm_cached_only_hit: verifies the HLSL path (direct = false) still hits cleanly inside dxc::cached_only (Ok, missed == false) once warm.

Part of #1269 (related to #1896)

Tested

  • Hardware / toolchain: Windows 11 (26200), Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (32-lane waves, driver 621.14), rustc 1.100.0, DXC 1.9.2609.5, release build.
  • Failing-first check (before adding dxc::defer() in console_geometry_with):
    • cargo test --release -j 4 -p xcl --lib geometry_defer_tests -- --nocapture --test-threads=1: 1 passed, 1 failed (direct_console_geometry_defers_during_cached_only_even_with_warm_passthrough panicked: direct console_geometry must defer inside dxc::cached_only (missed=false)).
  • After the fix (targeted, default + WARP):
    • cargo test --release -j 4 -p xcl --lib geometry_defer_tests -- --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored, 0 skipped.
    • XCL_ADAPTER="Microsoft Basic Render Driver" cargo test --release -j 4 -p xcl --lib geometry_defer_tests -- --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored, 0 skipped.
    • cargo test --release -j 4 -p xcl --lib gpu::recomp::pso:: -- --test-threads=1: 18 passed, 0 failed, 1 ignored (repeated_pso_shader_compile benchmark is #[ignore]).
  • Release workspace build & full test suite:
    • cargo build --release --workspace: exit 0.
    • cargo test --release --workspace -- --test-threads=4: 1156 passed, 0 failed, 46 ignored across 21 test binaries, with 25 SKIPPED stderr lines:
      • 20 no wave64 (32-lane RTX 4060 hardware)
      • 3 per-lane form: refused (#1426 unsupported f16/f32 semantics in per-lane wave32 tests)
      • 1 cannot disable the driver cache (Windows Developer Mode is required) (pso_measurement_compiles_an_exact_synthetic_record)
      • 1 no heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form)

Regression run

Paired 60s scripts/smoke.ps1 runs on the same retail title (title: 29640639) and GPU (NVIDIA GeForce RTX 4060):

Base (origin/main, cbc296ab):

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

This PR (7743842a):

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

No regressions (1610 vs 1539 frames, 14511 MB vs 14520 MB peak commit, 60 60 60 presents per 2 s, 0 device removals, 0 crashes).

Not tested

  • End-to-end live gameplay under XCL_DIRECT_DXIL=1 exercising legacy GS pipelines through real.rs async PSO probes (the paired scripts/smoke.ps1 runs used the default translator configuration; direct GS deferral is covered by geometry_defer_tests).
  • Native 64-lane hardware waves (AMD / Intel GPUs); this change only gates dxc::defer() before translate_geometry on the CPU and does not alter generated DXIL.

AI use

  • Google Antigravity (Gemini 4 Neon) investigated the missing dxc::defer() guard in pso::console_geometry, factored console_geometry_with, authored the fix and unit tests in pso.rs, and ran all build, unit, WARP, workspace, and paired smoke checks.

In `crates/xcl/src/gpu/recomp/pso.rs`, `compile_console_shader` (CS, VS,
PS) and `compile_console_mesh` (MS) all check `dxc::defer()` before
running cold Direct DXIL translation during `dxc::cached_only()` async
PSO probes, but `console_geometry()` omitted that guard. Under
`XCL_DIRECT_DXIL=1` + `dxc::cached_only()`, it ran
`kernel::translate_geometry()` synchronously on the render thread — and
when the pass-through mesh shader was already warm in DXC's cache,
`dxc::cached_only()` even returned `(Ok(TwoPass), missed = false)`
instead of deferring.

Factor `console_geometry_with(..., direct: bool)` so tests can exercise
both paths without mutating the `XCL_DIRECT_DXIL` environment variable,
and add `if dxc::defer() { return Err("DXIL not compiled yet".into()); }`
at the top of the direct DXIL branch before `kernel::translate_geometry`,
leaving the HLSL path (`direct = false`) unchanged.

Add unit tests verifying that direct `console_geometry_with` defers with
`missed == true` inside `dxc::cached_only()` even when the pass-through
mesh shader is warm, still succeeds outside `dxc::cached_only()`, and
that the HLSL path still hits cleanly inside `dxc::cached_only()`.

Part of xcl-dev#1269 (related to xcl-dev#1896)

Assisted-by: Google Antigravity (Gemini 4 Neon)
@JJAutoCompare

Copy link
Copy Markdown

Both CPU/DXC geometry cache tests passed on PR #2103 at 7743842ada44feff940b4785bf94e70b87b7d39c. The PR was open at that SHA before and after testing, and the checkout was clean and detached. I read the current AGENTS.md and CONTRIBUTING.md. The PR description contained the author’s same-head results, and the discussion had no independent same-head report.

Tested on STOR-WINLAB, Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, Ryzen 7 3800X, Rust/Cargo 1.100.0 x86_64-pc-windows-msvc. Both tests logged DXC/DXIL 1.9.2609.5 loaded from %LOCALAPPDATA%\XclTooling\dxc-1.9.2609\bin\x64. The installed Arc A770 driver was 32.0.101.9175. Source inspection confirmed CPU-only execution before the run, and an unmatched XCL_ADAPTER was set as a precaution. Each test used private TEMP/TMP and a fresh, empty XCL_DXIL_CACHE, with two Cargo jobs and incremental compilation and dev/test debug info disabled.

cargo test --locked -p xcl --lib gpu::recomp::pso::geometry_defer_tests::direct_console_geometry_defers_during_cached_only_even_with_warm_passthrough -- --exact --nocapture --test-threads=1
cargo test --locked -p xcl --lib gpu::recomp::pso::geometry_defer_tests::hlsl_console_geometry_keeps_warm_cached_only_hit -- --exact --nocapture --test-threads=1
  • Direct DXIL: The initial call produced nonempty compute and mesh DXIL and warmed the mesh passthrough. The cached-only call still deferred with DXIL not compiled yet and missed=true.
  • HLSL: The cached-only call succeeded with missed=false and returned byte-identical compute and mesh DXIL to the warm-up call.

Each command exited 0. Total 2 passed, 0 failed, 0 ignored, 0 skipped.

Not tested — GPU execution, live async PSO probes, retail titles, or the rest of the workspace suite.

AI use — T3 Code / Codex (gpt-6.2-sol) inspected the fixtures, ran the tests, and wrote this report.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows run on 7743842. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.

The clean cargo build --workspace --offline --locked -j 4 passed. cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4 finished with 1156 passed, 0 failed, 46 ignored, including both stock geometry-cache tests. Cargo's pass count includes 25 runtime skips (20 no native wave64, three unsupported per-lane forms, one unavailable driver-cache control and one no heap windows).

A separate synthetic fixture exercised XCL's hooked CreateGraphicsPipelineState on the native backend. With direct DXIL enabled, the mesh shader cache warm, and XCL_LAZY_PSO=0, the async call returned a stand-in. A background worker replaced it with a native mesh PSO and its associated compute PSO. With async disabled, the same input produced both PSOs during the call. Both runs passed with zero skips and zero GS HLSL fallbacks. Removing only the new geometry defer guard made the async run build immediately and fail the stand-in assertion. The focused filter was local_gs_cached_probe_builds_both_native_pipelines.

This covers PSO creation and worker routing. No draw or retail smoke was run. AI use: Codex (GPT-6, exact variant unspecified) prepared the scratch fixture, ran the tests and drafted this report.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

AMD RX 7800 XT test report

Tested locally by merging PR head 7743842ada44feff940b4785bf94e70b87b7d39c onto base main 3f2777019544c0ada2cd294aa792d3c378ff0df8 (no push). The base is an ancestor of current main and both trees merge cleanly.

Hardware and tools: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Windows 10 Pro; Rust 1.100.0 / Cargo 1.100.0; DXC 1.8.2502.11 (DXIL 1.8.2502.11). Debug test build.

cargo test --workspace --no-fail-fast -- --test-threads=4: 1,357 passed, 2 failed, 46 ignored. There were 7 SKIPPED reports: six GPU cases (wave32/wave64 variants for three unsupported instruction forms) and one heap-window case. The two failures and all 7 SKIPPED reports match the baseline (1,355 passed, 2 failed, 46 ignored).

Not tested

  • Smoke run or retail titles
  • Release build
  • Other GPUs

AI use
Codex (gpt-6-luna) ran Phase 2 tests and wrote this report (Phase 1 pre-compile / initial baseline run used Claude Code (Claude Sonnet 5.5)).

@ClosetPie107

Copy link
Copy Markdown

Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head 7743842ada44feff940b4785bf94e70b87b7d39c (merged cleanly onto main 2898511).

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv b540c8a2 + relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu (debug for tests, release for retail)

Unit / GPU tests (XCL_REQUIRE_GPU=wave64, XCL_DXC_DIR, VKD3D_CONFIG=ignore_shared_fence, --test-threads=1 --nocapture)

  • gpu::recomp::pso::: 26 passed, 0 failed, 1 ignored (0 skipped)

Combined retail sanity run (main 2898511 + #2103, #838, #1250, #1733 merged together; XCL_DIRECT_DXIL=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PSO_WAIT_MS=50, XCL_SPLIT_MIDLIST_WAIT=0, XCL_COHERENT_MB=1024, VKD3D_CONFIG=ignore_shared_fence, XCL_PSO_PRELOAD=0, XCL_NETWORK=0, warm PSO cache)

  • Ran 268 s with 0 device removals, 45,841 translated draws, 154,125 dispatches (+ 4,634 chained split-compute), 47,255 Opus packets (0 errors), 13.2 GiB peak VRAM (0 GTT spill), 15.1 GiB peak RSS (vs 19.3 GiB on clean main 2898511).
  • Ended at 268.4 s on the same pre-existing main 0xc0000005 TOCTOU race in title_textures::subresources (copy_nonoverlapping reading 0x793a08000) also reproduced on clean main 2898511 (161.8 s).

Not tested

  • Full workspace test suite, native Windows, or an isolated single-PR retail run (retail sanity run above was on the 4-PR batch).

AI use

  • T3 Code / Antigravity (Gemini 4 Neon) merged the PR onto main, ran the tests and combined retail run under Proton on this machine, and drafted this report.

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

No concrete correctness defect found. The cached_only defer guard matches the existing direct CS/MS behavior and the focused tests cover the intended miss/hit paths. Nonblocking coverage gap: the direct fixture does not exercise a translate_geometry unsupported error followed by the existing HLSL fallback while cached_only. That is not a blocker, but would make the fallback contract clearer.

@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

I compared this guard and the overlapping guard in #2918 using the same two-PS synthetic ES+GS fixture. Clean Windows builds of main 8b957bec, #2103 7743842a, and #2918 4ddb971c. SDK DXC 1.8.2502.11, Rust 1.97.1 MSVC debug. A seed process first warmed the mesh passthrough DXIL on disk for both PS signatures. Each of five fresh processes per revision and mode then called dxc::cached_only(|| console_geometry(...)) with each PS, translated one PS variant normally, and repeated both cached-only probes.

Direct DXIL Disk warm, ES+GS cold in this process After one ordinary ES+GS translation
main Ok, missed=false Ok, missed=false
#2103 Deferred, missed=true Deferred, missed=true
#2918 Deferred, missed=true Ok, missed=false for both signatures

Setting XCL_RECOMP_WHY=1 on #2918 bypassed its RAM cache and restored the #2103 results in five more processes. With XCL_DIRECT_DXIL=0, both probes hit on all three builds. This confirms #2918 also covers the cold deferral fixed here and adds the warm in-process hit. It exercises the translation entry point with CPU/DXC only. GPU scheduling and retail impact were outside this check.

OpenAI Codex assisted with verification.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 7743842

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 2c717a0
head: 7743842
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1468 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored
review: no blocking finding. The guard matches the existing defer guards for console shaders and mesh shaders. Known limit, measured in the thread: without a RAM cache every cached-only probe of a direct-DXIL geometry shader defers, even after an in-process translation; #2918 (open) overlaps this PR and adds that warm hit, so one of the two is redundant. The test fails without the change; like the existing pso tests it needs DXC and has no skip. Open, not blocking: the HLSL fallback is not exercised under cached-only.
performance: only with XCL_DIRECT_DXIL=1, where geometry-shader translation moves off the render thread; no translator source changes (reasoned).
verdict: safe to merge (decide between this and #2918)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@KOLESNiii

Copy link
Copy Markdown
Contributor

merge-check claim
head: 7743842

@akimfomin

Copy link
Copy Markdown

A nearby producer/consumer check is AnyXboxX #575: an exact used key survives a warm build while unused variants stay cold. For the cache-only DXIL probe here, a synthetic pair with one published geometry key and one missing one can show that the miss does not build on the caller. The published key must still hit. This checks probe policy, independently of the existing runtime measurements.

@KOLESNiii

Copy link
Copy Markdown
Contributor

merge-check
base: 753e8b1
head: 7743842
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1514 passed, 0 failed, 47 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: none. The suite ran on this PC at the same time as 6 other PRs' suites, in one queued job.
review: none. Whole diff read (pso.rs: console_geometry_with, defer under dxc::cached_only on the direct DXIL path, 2 tests). Inside cached_only a direct-DXIL legacy GS pipeline now returns "DXIL not compiled yet" (the caller's existing defer path) instead of translating synchronously on the calling thread; outside it and on the HLSL path nothing changes.
Re-frozen on main 753e8b1 before posting (main changed this PR's files: README / build.rs / pso.rs / pso_async.rs, in code this PR does not touch); the merge diff was read again against it.
performance: reasoned, not measured: with XCL_DIRECT_DXIL=1, a GS pipeline first met in a cached-only call is built later instead of stalling that call; default (HLSL) path unchanged.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 6635dd67226655209a41590a6a726c34df6103c6 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).

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.