NVIDIA: cached pipeline blobs bake static-sampler slots; a later run with a different sampler order samples the wrong samplers #3044
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 grahamster2 on 2026-11-27T17:34:56Z.
What happens
On NVIDIA, a driver blob from
GetCachedBlob(fed back throughD3D12_CACHED_PIPELINE_STATE) records which slot of the driver's own sampler table each static sampler took. In a later process that created its samplers in a different order, the driver accepts the blob without error, but the pipeline samples through other samplers: linear becomes unfiltered, point becomes filtered. XCL turns constant S# into static samplers of its ABI root signature (gpu/recomp/pso.rsabi_signature) and keeps driver blobs on disk by default (XCL_PSO_DISK_CACHE,hle/d3d12x/real.rsdriver_cache), so a warm cache can give wrong sampling with no warning. The order XCL creates its ABI static samplers in depends on translation order across the pipeline worker threads, andxcl pso-precompilewrites blobs from a different process, so a mismatch is the normal case, not a corner case. Title pipeline libraries (CreatePipelineLibrary) go straight to the driver and carry the same blobs. The refused-blob fallback never triggers, because the blob is not refused.Reproduced on an RTX 3080 (one GPU so far) (Windows 11), with a probe that runs each case in its own process. The program is translated by XCL with three constant S#: point, linear and trilinear.
First found by readmet3xt-lab in VIctory-NVIDIA (
7fa0e958), throughID3D12PipelineLibrary: posterized colour grading with green and magenta fringes when cached. The same report measured that an NVIDIA driver holds at most 2,032 distinct static samplers per process; one more removes the device.This matters for the pipeline-library plan: a pipeline library serializes the same driver blobs, so it should have the same problem.
Options
Which one should be the default? I have a branch with the probe (an
#[ignore]GPU test), a static-sampler counter that warns near 2,032, and an opt-inXCL_PSO_CACHE_STATIC_SAMPLERS=0(option 1, default unchanged) for A/B. I'll open it as a PR, and can follow up with whichever default you pick.Imported from ivall/xcl. Originally posted by akimfomin on 2026-11-27T20:26:16Z.
The public PipelineLibrary controls suggest a useful way to choose the default here. KyleS98 reported silent output changes with an extra static sampler on Windows / RTX 3090 Ti / 616.92. UncommonDLL's standalone fixture kept its expected output on RTX 5070 Ti / 621.40 when the extra BORDER sampler was created first. victory-fork #1459 · XCL C1 extra-sampler control
When your three-sampler probe is public, it could distinguish the cache paths on the same configuration. Run CachedPSO and PipelineLibrary with the same adapter, driver, shaders and sampler descriptors, varying only sampler creation order between the writer and reader processes. Check both a successful cache load and output against the cold baseline. That would show whether to apply a workaround to one cache path or both on that setup.
Codex helped compare these public reports for PortBridge. The hardware runs are credited to the original testers.
Imported from ivall/xcl. Originally posted by gabdam-src on 2026-11-28T16:27:14Z.
Test report for the comparison @akimfomin asked for. I ran CachedPSO and ID3D12PipelineLibrary side by side, with the same GPU, driver, shaders and sampler descriptions. The only thing that changes between the process that writes the blob and the process that loads it is the order in which static samplers get created.
Result on an RTX 5070 (driver 621.01): graphics pipelines loaded from a blob sample through the wrong samplers on both cache paths whenever the loading process created its static samplers in a different order. Compute pipelines sampled correctly in every case. Every load reported success.
How the probe works
It's a standalone D3D12 program that doesn't use XCL code. Every case runs in a fresh process.
The shader samples one small texture three times, once through each of three static samplers: point (s0), linear (s1) and trilinear (s2).
The texture and the coordinates are chosen so that each sampler returns a different value. That way the output shows which sampler the pipeline really used:
(Texture: R32_FLOAT, 2×1 texels with 2 mip levels. Mip 0 holds 0 and 1, mip 1 holds 4. Sampled with
SampleLevel(uv = (0.375, 0.5), lod = 0.25).)The writer process compiles the pipeline cold and saves it twice: as a
GetCachedBlobblob and as a serialized pipeline library.A reader process then creates some other static samplers first (its "prefix") and loads the pipeline in one of three ways: a cold compile with no blob (the control), from the CachedPSO blob, or from the pipeline library.
Reader prefixes:
The writer itself ran once with no prefix and once with the "shifted" prefix. Each combination ran 3 times, and the 3 runs always matched.
Graphics pipelines (vertex + pixel shader)
What the wrong results show:
So the blob keeps the positions its samplers had in the writer's table, and reads whatever sits in those positions in the reader's table. This matches CharlyRien's model on #505. Creating a root signature on its own is enough to change the positions. No pipeline is needed.
Compute pipelines
I tested two compute shapes:
Each shape ran all of the combinations above (96 runs per shape). Every run returned the correct value from all three samplers on both cache paths. I can't tell from outside the driver whether it used the compute blob or quietly recompiled the pipeline.
What this means for choosing a fix
On this card and driver, the problem is in the driver's blobs, not in one D3D12 path, so a workaround for graphics pipelines has to cover CachedPSO and pipeline libraries alike. Compute showed no failure here, but that doesn't clear compute in general, because upipibi reported compute failures on #505.
Probe source and raw output: <link or gist, to decide>.
Setup: RTX 5070 12 GB, NVIDIA driver 621.01 (UMD 32.0.16.2101), Windows 10 Pro 22H2 (19045), Rust 1.100.0, release build.
Not tested: other NVIDIA cards and drivers, AMD and Intel, mesh pipelines, XCL's own translated pipelines, and the retail title.
AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran it and drafted this report.
Imported from ivall/xcl. Originally posted by Hash-0x on 2026-11-30T17:04:25Z.
A standalone two-process test on an RTX 4070 SUPER, driver 621.24. Graphics reads through the wrong static samplers, as reported here. Compute does too, but only on the first load of a pipeline the driver has not seen, which may be why the compute reports disagree.
I did not run XCL. The test is
--cachein wave64-prefix-test at commita01a85c: my own shaders, three static samplers (point, linear, trilinear), gabdam-src's texture and expected values (0 / 0.25 / 1.1875). Every read is a process of its own. Each pipeline gets a root signature that differs only in the register space of an unused root constant, so that NVIDIA's own cache does not know it: with a new space a cold create takes 9 to 14 ms every time, with a repeated one 0.4 to 0.8 ms.Nothing else created before saving
With 10 others created before saving, only loading after the same 10 reads right; in compute, that is about the first load. No load is refused.
My reading, from the times only: on this driver compute prefers NVIDIA's own cache when it has an entry for the current sampler layout, and takes the blob as it is when it has none. Then a cold control run before the blob, or repeating with the same shader, hides the compute failure. My first version did exactly that and read compute right in every case. I have not run the other tests posted here or in #505, so whether this is what happened in them is a guess. An easy check is a new pipeline per case and no cold create before the load.
If it holds, #3169 may need compute as well: its rules for compute stay as they are, and the first run after the blobs are written is the one that would read wrong.
Tested: GeForce RTX 4070 SUPER (driver 32.0.16.2124), Windows 11 Pro 26300, 10 runs. The times are from a separate run of 3 rounds. WARP: all 100 reads right, 2 runs. Debug layer: 0 errors and 0 warnings.
Not tested: XCL, a retail title, mesh pipelines, large shaders, other cards and drivers.
AI use