GPU: an opt-in gate refuses a translated shader the DXIL validator rejects #1936
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1936
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1936"
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?
@Luislariosss on GitHub · 2026-11-25 01:13 UTC · original
Luislariosss:gpu/validate-translated-dxil→main· +301 −24 · 5 files · 1 commits · openWhy
Translated shaders reach D3D12 pipeline creation unvalidated, by design (
emit/validator.rs: the container hash is ours, D3D12 accepts it). On one AMD card that is not free: the driver's shader compiler (amdxc64.dll) can fault (0xc0000005) on some translated programs, and the whole process dies 40-90 s into the world. A way to make the world survive is to drop the programs the official validator rejects before they reach the driver.Running the validator over one title's shader pack rejects ~800 programs (736 compute: the 1.6 validator's "incompatible with the shader stage", which for compute is
Sample/SampleBiasat validator version 1.6; 72 mesh: the 32 KiB output budget, see #1961). Whether those programs are really invalid on the host is another question (the compute ones are not: the runtime accepts them, and #1948, now closed, was wrong to treat them as invalid). What matters here is only that on this card the driver's compiler faults on them and that refusing them keeps the run alive.What (revised after the triage: the gate is now opt-in)
VICTORY_VALIDATE=1turns on a gate inshader_cache::host_shader: each translation is validated once withdxil.dlland a rejection becomes a cached refusal with its reason (the DXIL validator rejects it: <first specific line>). Refusals already have a path: cached asVSHE+ reason, logged bypipeline.rswith stage and hash, draws dropped. Off by default: nodxil.dllis loaded, nothing is keyed, nothing changes.thread_local, loaded on first use (Send, notSync).dxil.dllinvalidates the shader cache and the pipeline library; that is intended and documented.dxil.dllwith the gate on warns once and translates ungated.rejected) and the pipeline-library summary.first_specific_line(inemit/validator.rs) is shared by the gate and bytranslate --validate, which used to bucket by the generic "See other errors" summary.Evidence on hardware
RX 9060 XT (RDNA4),
amdxc64.dll32.0.32015.7029, Windows 11, empty cache each time. With the gate on, five runs reached the world and stayed 5+ minutes with no0xc0000005from the compiler. Without it, the same build died in the compiler 40-90 s into the world. Lowering the computeSamples toSampleGradinstead did not help (two runs died at the same address after ~50 s), so the faults follow those programs, not the sample opcode. I have not run this on NVIDIA or Intel.Verification
cargo clippy --workspace --all-targets --locked -- -D warningsand the--all-featuresvariant: clean.cargo test --workspace --locked: no failures (one unrelatedframetest failed once and passed on re-run).first_specific_line(4 cases); with the DLL present, an invalid buffer is refused and then served from the cache.No shader bytes, hashes or program names from any title (asset policy).
@Luislariosss on GitHub · 2026-11-25 01:29 UTC · original
First end-to-end run of this branch, on hardware (RX 9060 XT, RDNA4,
amdxc64.dll32.0.32015.7029, Windows 11 26200), built onmain42363abwithdxil.dllfrom DXC 1.9.2609.5 viaVICTORY_DXIL, empty shader cache, noVICTORY_SKIP_PIPELINES:killed: True). No0xc0000005, no device removal, no0x887A…exit.pipeline.rsline with stage, hash and the reasonthe DXIL validator rejects it: ….One limit to be clear about: that run ended with a flood of
E_OUTOFMEMORY (0x8007000E)warnings on small host-visible buffers (about 1 min 45 s after entering the world, with a 47.2 GB commit limit), so the world was running degraded. That is host memory, not the gate, and I am measuring it separately.Cause of the compute rejections, found while testing this: the translator declares validator version 1.6 (
emit/shader.rs), and for versions below 1.8 DXC treatsSample/SampleBias(and the other derivative opcodes) as pixel-only.emit/lower.rsalready limitsimage_sample_candimage_get_lodto pixel shaders but emitsimage_sample/image_sample_bin any stage, so those compute and mesh programs are invalid by construction. That is why the validator text names no rule. I will send that as a separate change; this PR stays the safety net.AI-assisted.
@upipibi on GitHub · 2026-11-25 01:44 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
7dc12f3.victory-shader: 243 passed, with only #1744's 3 NVIDIA failures.victory-gpu: 143 passed, 2 failed, with only the two NVIDIA heap-cap failuresmainalso has (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views). Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 08:20 UTC · original · edited 2026-11-26 01:24 UTC
Automated triage for the maintainers.
Needs work: this needs the maintainer's decision. The code points from the last triage are addressed: the gate in
shader_cache::host_shaderis now opt-in (VICTORY_VALIDATE=1, viavalidator_path), off by default with nodxil.dllloaded;first_specific_lineinemit/validator.rsis shared by the gate andtranslate --validate; the module docs say it is an opt-in run-time gate that loads external code; and the doc comment onvalidator_idsays swappingdxil.dllinvalidates the shader cache and the pipeline library. One commit, merges cleanly.What is left is a decision for the maintainer: with the switch on,
dxil.dll(fromVICTORY_DXIL, the Windows SDK or the DLL search path) is loaded into the game process at run time, and rejected programs have their draws dropped. The root cause of most rejections (image_sample/image_sample_blowered outside pixel shaders while declaring validator 1.6) is still meant to be fixed separately, in the lowering.CI: passing (
check).Generated by Claude Code
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.