Shaders: xcl shaders --precompile --pipelines blobs rejected on run 1 (compute retry) due to NodeMask, static_samplers, and device-flag mismatches #2453

Open
opened 2026-11-26 05:31:20 +00:00 by github-bot · 2 comments
Owner

@⁠microwave805 on GitHub · 2026-11-25 19:30 UTC · original

Investigation on main @ c7e1799 of the issue reported on #1833 (xcl shaders --precompile --pipelines blobs rejected with compute retry on the first title run, then accepted on run 2). Part of #1833, Part of #1269.

compute retry is emitted only in compute_container() (crates/xcl/src/hle/d3d12x/real.rs:4434-4440), meaning driver_cache::load(disk) found the prebuilt <fnv64(dxil)>-<len>-0.pso file, CreateComputePipelineState rejected its CachedPSO, deleted it, retried uncached, and overwrote the exact same path with a compatible blob that run 2 then accepts.

Three concrete mismatches between xcl shaders --precompile --pipelines (shaders.rs) and runtime compute_container() (real.rs) cause this:

1. NodeMask mismatch (0 in precompile vs title's d.NodeMask at runtime) and omission from cache keys

  • Where:
    • crates/xcl/src/shaders.rs:1327-1331 (Pipelines::make_with_cache_path)
    • crates/xcl/src/hle/d3d12x/real.rs:4402-4411 (compute_container), 4477-4479 (driver_cache::name), 4651-4656 (compute_blob_key), 6574 (stream_pipeline)
  • Root cause: shaders.rs:1327-1331 constructs D3D12_COMPUTE_PIPELINE_STATE_DESC with ..Default::default(), hardcoding NodeMask = 0. compute_container() (real.rs:4402) copies d verbatim and preserves the title's NodeMask (e.g. NodeMask = 1, including stream subobject 18 at real.rs:6574). Both driver_cache::name(dxil, flags) and compute_blob_key(dxil, rs, flags) omit NodeMask (unlike graphics_blob_key, compute_key, and dispatch_chain.rs).
  • Effect: Any title passing NodeMask = 1 hits <hash>-<len>-0.pso built with NodeMask = 0 → CreateComputePipelineState returns E_INVALIDARG (compute retry) → deletes and overwrites the file with NodeMask = 1 → run 2 accepts it.
  • Fix direction: Normalize single-GPU copy.NodeMask = 0 in compute_container() (matching CreateRootSignature(0, ...), finish_two_pass, and shaders.rs), or include NodeMask in driver_cache::name and compute_blob_key.

2. driver_cache::name omits static_samplers (pRootSignature content)

  • Where: crates/xcl/src/hle/d3d12x/real.rs:4411, 4477-4479, crates/xcl/src/shaders.rs:1333
  • Root cause: driver_cache::name(dxil, flags) keys only on (fnv64(dxil), dxil.len(), flags) without hashing compiled.samplers, even though S# static sampler descriptors live exclusively in pRootSignature. Two shaders with identical DXIL but different static samplers collide on the same .pso file and fail CachedPSO root-signature validation (compute retry).
  • Fix direction: Mix a deterministic digest of samplers (as graphics_blob_key and two_pass_cs_key already do) into driver_cache::name.

3. Pipelines::new() ignores XCL_DRED, XCL_D3D12_DEBUG, and xcl.toml adapter settings — and triggers post-device debug-layer removal

  • Where: crates/xcl/src/shaders.rs:1289-1301, 1410-1437 vs crates/xcl/src/hle/d3d12x/real.rs:486-540, crates/xcl/src/gpu/recomp/runner.rs:88-90
  • Root cause:
    1. Pipelines::new() hardcodes Selector::from_env_or("auto") and never applies XCL_DRED, XCL_D3D12_DEBUG, or xcl.toml's d3d12_adapter/d3d12_debug, causing prebuilt driver blobs to mismatch runtime devices when any of those are set.
    2. In precompile() (shaders.rs:1411), Pipelines::new() creates pipeline.dev before lines 1436-1437 call runner::graphics_wave32() / wave64_supported(). With XCL_D3D12_DEBUG set, runner::init() enables the D3D12 debug layer after pipeline.dev already exists, removing pipeline.dev (DXGI_ERROR_DEVICE_REMOVED).
  • Fix direction: Apply XCL_D3D12_DEBUG / XCL_DRED and run runner capability queries before creating pipeline.dev (or query wave capabilities directly on pipeline.dev).

(Also note: shaders.rs:1304-1389 currently ignores c.dispatch_chain and only writes .pso for c.dxil, leaving split compute shaders un-precompiled as .chain.pso.)

AI use

  • Antigravity (Gemini 4 Neon): static code audit on main @ c7e1799 and issue drafting.
**@⁠microwave805** on GitHub · 2026-11-25 19:30 UTC · [original](https://github.com/xcl-dev/xcl/issues/2453) Investigation on `main @ c7e1799` of the issue reported on #1833 (`xcl shaders --precompile --pipelines` blobs rejected with `compute retry` on the first title run, then accepted on run 2). Part of #1833, Part of #1269. `compute retry` is emitted only in `compute_container()` (`crates/xcl/src/hle/d3d12x/real.rs:4434-4440`), meaning `driver_cache::load(disk)` found the prebuilt `<fnv64(dxil)>-<len>-0.pso` file, `CreateComputePipelineState` rejected its `CachedPSO`, deleted it, retried uncached, and overwrote the exact same path with a compatible blob that run 2 then accepts. Three concrete mismatches between `xcl shaders --precompile --pipelines` (`shaders.rs`) and runtime `compute_container()` (`real.rs`) cause this: ### 1. `NodeMask` mismatch (0 in precompile vs title's `d.NodeMask` at runtime) and omission from cache keys - **Where:** - `crates/xcl/src/shaders.rs:1327-1331` (`Pipelines::make_with_cache_path`) - `crates/xcl/src/hle/d3d12x/real.rs:4402-4411` (`compute_container`), `4477-4479` (`driver_cache::name`), `4651-4656` (`compute_blob_key`), `6574` (`stream_pipeline`) - **Root cause:** `shaders.rs:1327-1331` constructs `D3D12_COMPUTE_PIPELINE_STATE_DESC` with `..Default::default()`, hardcoding `NodeMask = 0`. `compute_container()` (`real.rs:4402`) copies `d` verbatim and preserves the title's `NodeMask` (e.g. `NodeMask = 1`, including stream subobject `18` at `real.rs:6574`). Both `driver_cache::name(dxil, flags)` and `compute_blob_key(dxil, rs, flags)` omit `NodeMask` (unlike `graphics_blob_key`, `compute_key`, and `dispatch_chain.rs`). - **Effect:** Any title passing `NodeMask = 1` hits `<hash>-<len>-0.pso` built with `NodeMask = 0` → `CreateComputePipelineState` returns `E_INVALIDARG` (`compute retry`) → deletes and overwrites the file with `NodeMask = 1` → run 2 accepts it. - **Fix direction:** Normalize single-GPU `copy.NodeMask = 0` in `compute_container()` (matching `CreateRootSignature(0, ...)`, `finish_two_pass`, and `shaders.rs`), or include `NodeMask` in `driver_cache::name` and `compute_blob_key`. ### 2. `driver_cache::name` omits `static_samplers` (`pRootSignature` content) - **Where:** `crates/xcl/src/hle/d3d12x/real.rs:4411, 4477-4479`, `crates/xcl/src/shaders.rs:1333` - **Root cause:** `driver_cache::name(dxil, flags)` keys only on `(fnv64(dxil), dxil.len(), flags)` without hashing `compiled.samplers`, even though `S#` static sampler descriptors live exclusively in `pRootSignature`. Two shaders with identical DXIL but different static samplers collide on the same `.pso` file and fail `CachedPSO` root-signature validation (`compute retry`). - **Fix direction:** Mix a deterministic digest of `samplers` (as `graphics_blob_key` and `two_pass_cs_key` already do) into `driver_cache::name`. ### 3. `Pipelines::new()` ignores `XCL_DRED`, `XCL_D3D12_DEBUG`, and `xcl.toml` adapter settings — and triggers post-device debug-layer removal - **Where:** `crates/xcl/src/shaders.rs:1289-1301, 1410-1437` vs `crates/xcl/src/hle/d3d12x/real.rs:486-540`, `crates/xcl/src/gpu/recomp/runner.rs:88-90` - **Root cause:** 1. `Pipelines::new()` hardcodes `Selector::from_env_or("auto")` and never applies `XCL_DRED`, `XCL_D3D12_DEBUG`, or `xcl.toml`'s `d3d12_adapter`/`d3d12_debug`, causing prebuilt driver blobs to mismatch runtime devices when any of those are set. 2. In `precompile()` (`shaders.rs:1411`), `Pipelines::new()` creates `pipeline.dev` **before** lines `1436-1437` call `runner::graphics_wave32()` / `wave64_supported()`. With `XCL_D3D12_DEBUG` set, `runner::init()` enables the D3D12 debug layer **after** `pipeline.dev` already exists, removing `pipeline.dev` (`DXGI_ERROR_DEVICE_REMOVED`). - **Fix direction:** Apply `XCL_D3D12_DEBUG` / `XCL_DRED` and run `runner` capability queries before creating `pipeline.dev` (or query wave capabilities directly on `pipeline.dev`). *(Also note: `shaders.rs:1304-1389` currently ignores `c.dispatch_chain` and only writes `.pso` for `c.dxil`, leaving split compute shaders un-precompiled as `.chain.pso`.)* ### AI use - Antigravity (Gemini 4 Neon): static code audit on `main @ c7e1799` and issue drafting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:20 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 20:49 UTC · original

Claiming this issue: aligning xcl shaders --precompile --pipelines descriptor/cache-key construction (NodeMask, static_samplers, device flags) with runtime compute_container(), with regression tests.
AI use: Claude Code (Claude Opus 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 20:49 UTC · [original](https://github.com/xcl-dev/xcl/issues/2453#issuecomment-7174227648) Claiming this issue: aligning xcl shaders --precompile --pipelines descriptor/cache-key construction (NodeMask, static_samplers, device flags) with runtime compute_container(), with regression tests. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠KOLESNiii on GitHub · 2026-11-26 01:08 UTC · original

Two offline parity checks on main at b49be18.

  • Verified. Folder precompile skips FSPX-only compute inputs. The worker requires xbox::parse before it checks the stage or reaches Pipelines::make. That parser requires a DXIL part containing XDAT. The runtime’s console_translation accepts an ACCC/FSPX container directly, and the CLI’s measure/export path already recognizes the format. I ran the upstream synthetic ACCC-only fixture with the extracted parsers and confirmed that runtime classification accepts it and XDAT lookup fails. The worker skips it even with --only cs, before incrementing any result counter. The number of affected title pipelines is unknown. Precompile worker · Runtime translator · Fixture
  • Verified control-flow difference, suspected extra driver work. Offline reuse requires a successful create followed by a GetCachedBlob result of exactly the input size. A successful create with a different-sized blob takes the same branch as a failed create. Under the cap it calls CreateComputePipelineState again without the blob. Above the cap it discards the returned object, deletes the file and counts the input as capped. If a driver accepts the input and rebuilds or reserializes it, the first call may already have done the expensive work. Equal sizes also cannot establish reuse by themselves. A Windows trace with the first HRESULT, both blob lengths and elapsed time for each create would show whether this matters on a given driver. Offline create and retry

Static review and a standalone parser probe on Linux. Windows, title coverage and timing remain unmeasured. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for review, probe and drafting.

**@⁠KOLESNiii** on GitHub · 2026-11-26 01:08 UTC · [original](https://github.com/xcl-dev/xcl/issues/2453#issuecomment-7179477364) Two offline parity checks on `main` at `b49be18`. - **Verified. Folder precompile skips FSPX-only compute inputs.** The worker requires `xbox::parse` before it checks the stage or reaches `Pipelines::make`. That parser requires a DXIL part containing XDAT. The runtime’s `console_translation` accepts an ACCC/FSPX container directly, and the CLI’s measure/export path already recognizes the format. I ran the upstream synthetic ACCC-only fixture with the extracted parsers and confirmed that runtime classification accepts it and XDAT lookup fails. The worker skips it even with `--only cs`, before incrementing any result counter. The number of affected title pipelines is unknown. [Precompile worker](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/shaders.rs#L1630-L1657) · [Runtime translator](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/recomp/pso.rs#L1015-L1028) · [Fixture](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/gpu/recomp/tests.rs#L8851-L8871) - **Verified control-flow difference, suspected extra driver work.** Offline reuse requires a successful create followed by a `GetCachedBlob` result of exactly the input size. A successful create with a different-sized blob takes the same branch as a failed create. Under the cap it calls `CreateComputePipelineState` again without the blob. Above the cap it discards the returned object, deletes the file and counts the input as capped. If a driver accepts the input and rebuilds or reserializes it, the first call may already have done the expensive work. Equal sizes also cannot establish reuse by themselves. A Windows trace with the first HRESULT, both blob lengths and elapsed time for each create would show whether this matters on a given driver. [Offline create and retry](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/shaders.rs#L1518-L1569) Static review and a standalone parser probe on Linux. Windows, title coverage and timing remain unmeasured. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for review, probe and drafting.
This discussion has been locked. Commenting is limited to contributors.
No description provided.