Shaders: validate DXIL containers in the translated/v2 disk cache #2064
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2064
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2064/head"
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?
@RandomGithub12309 on GitHub · 2026-11-25 02:32 UTC · original
RandomGithub12309:shaders/validate-translated-cache-dxil→main· +118 −14 · 2 files · 1 commits · merged 2026-11-25 10:41 UTCdxc::compile_cached_in_observedvalidatesvalid_dxil_containeron both disk loads and fresh writes (and removes corrupt targets before renaming on Windows), preventing corrupt cached DXIL from reachingCreate*PipelineState.However,
translated/v2inpso.rsruns ahead ofdxc::compile_cached(and is the only disk cache forXCL_DIRECT_DXIL), and itsXCLTRAN2header hashes only the input console shader blob rather than the stored DXIL payload:translated::load_inaccepted any payload whose length matched the 4-byte length field — including zero-filled or corrupted DXIL blocks — returning corrupt bytecode on every run forever.translated::store_inandtranslated::cached_inpersisted unvalidated DXIL payloads and dropped the replacement.tmpfile ifrenamefailed over an existing target on Windows.What is in it
crates/xcl/src/gpu/recomp/dxc.rs:valid_dxil_containeraspub(super).crates/xcl/src/gpu/recomp/pso.rs:dxc::valid_dxil_containerintranslated::load_in,translated::store_in, andtranslated::cached_in(returningErr("translated cache: translator returned an invalid DXIL container")on an invalid fresh translation without writing to disk).translated::load_inagainst remaining bytes (n > r.len() / 17).translated::store_in, remove an existing target and retryrenamebefore deleting.tmp.shader_cache_testsfixtures to use valid synthetic DXBC/DXIL containers and add two regression tests (both fail before the fix and pass after):translated_cache_rejects_corrupt_dxil_payload_and_rebuildstranslated_cache_rejects_invalid_fresh_dxil_without_poisoning_disk(including round-tripping a container emitted bygpu::dxil::shader::Shader).Tested
Hardware: Windows 11 (Build 26300), Intel Core Ultra 7 255HX, NVIDIA GeForce RTX 5050 Laptop GPU (wave32-only, driver 32.0.16.2114),
rustc 1.100.0 (0ef1bc386 2026-11-09)stable-x86_64-pc-windows-msvc, Windows SDK DXC1.8.2502.11.cargo test -p xcl --lib gpu::recomp::pso::shader_cache_tests::translated_cache_rejects -- --test-threads=1→0 passed; 2 failed(zeroed DXIL payload must not load as a cache hit,invalid fresh DXIL must be rejected).743a612):cargo test -p xcl --lib gpu::recomp::pso -- --test-threads=4→18 passed; 0 failed; 1 ignored(repeated_pso_shader_compile, pre-existing#[ignore]bench).cargo build --workspace→ succeeded.cargo test --workspace -- --test-threads=4 --skip fuzz_validate_and_gpu:xcllib:1096 passed; 0 failed; 26 ignored; 4 filtered out(gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}, pre-existing RTX 500x8007000Efailure tracked by #1905);24 SKIPPEDlines printed inside passing tests (20 wave64 / no-wave64 sub-cases, 3 wave32 per-lane refused sub-cases, 1pso_measurement_compiles_an_exact_synthetic_recorddue to Developer Mode being off).56 passed; 0 failed; 20 ignored(1 SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsingpu_compute_e2e).1152 passed; 0 failed; 46 ignored; 4 filtered out(25 SKIPPEDnotices).Regression run
Baseline (
upstream/main):PR head (
743a612):(The PR run populated a fresh
translated/v2namespace because editingpso.rs/dxc.rsupdatesXCL_TRANSLATOR_SOURCE_ID, then ran at steady60 60 60presents per 2 s.)Not tested
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}(#1905), andpso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode not enabled on this host).translated/v2corruption triggered by an OS power loss during a retail title run (exercised via unit tests instead).AI use
Antigravity (Gemini 4 Neon) identified the missing DXIL container validation in
translated/v2, implemented the fix and regression tests, ran the test suite and smoke runs, and drafted this PR description.@Parakeet-Wheat on GitHub · 2026-11-25 03:30 UTC · original
NVIDIA RTX 3070 on native Windows, head
743a612on its basecbc296a(currentmain): both new tests fail without the fix and pass with it, the whole suite passes, and the smoke pair is within the limits. The smoke run writes 143translated/v2entries and logs noinvalid DXIL containerrejection.Tested
610.88, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head743a612(one commit onmaincbc296a), checked out clean. Tests in the debug profile, smoke in release.cargo test -p xcl --lib translated_cache_rejects -- --nocapture --test-threads=1:cbc296awith the PR'spso.rsbut its four hunks above the test module (translated::load_in,store_in,cached_in) reverted: 2 failed, 0 passed,zeroed DXIL payload must not load as a cache hitandinvalid fresh DXIL must be rejected;743a612: 2 passed, 0 failed..\scripts\test.ps1(cargo build --workspace, thencargo test --workspace -- --test-threads=4) on743a612: 1156 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 ×no wave64, 3 × per-lane form refused (V_CVT_F16_F32,V_PK_MUL_F16,V_MUL_F16: "its #1426 semantics differ from the console's"), 1 ×no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).Regression run (
scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited).maincbc296a:PR head
743a612:That is 103 % of
main's frames and 104 % of its peak commit. Both runs start with an emptytranslated/v2namespace (the source id differs per commit). The PR's run wrote 143 entries there,main's 144; neither log has an ERROR line, both have 76 WARN lines, and the PR's has notranslated cache: translator returned an invalid DXIL container, so the validator accepted every fresh translation this title makes in the menus. One run each: the18 48 60tail of the PR's run (against43 60 60onmain) is not something I repeated.Not tested
translated/v2file on disk in a retail run (the two new unit tests cover it), a world run, AMD, native wave64 (the 20no wave64skips above), the tests on game data (XCL_SAMPLE_*not set).AI use
@futurepro62 on GitHub · 2026-11-25 03:27 UTC · original · edited 2026-11-25 03:32 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
743a612(on its basecbc296a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1144 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.translated_cache_rejects_corrupt_dxil_payload_and_rebuilds,translated_cache_rejects_invalid_fresh_dxil_without_poisoning_disk.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1155 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),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))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),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))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on maincbc296atoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputestsconst_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@AmateurWizrd on GitHub · 2026-11-25 04:41 UTC · original
Test report on
743a612(head as it is) against its basecbc296a: the new validation rejected no real cache entry on the retail title. On both shader paths, warm runs rewrote 0 cache files on the head, the same as on the base.gpu::recomptests: RTX 5070 Ti 355 passed / 0 failed; native wave64 on an RDNA2 integrated GPU 353 passed / 2 failed, and the same 2 fail on the base.Cache, release builds, retail title, 60 s per run (
XCL_RUN_SECONDS=60,XCL_NETWORK=0, scripted menu input). Run 1 starts from an empty shader cache, runs 2 and 3 reuse it; "rewritten" counts cache files whose write time is after the run's start:.bin)cbc296acbc296aXCL_DIRECT_DXIL=1743a612743a612XCL_DIRECT_DXIL=1cargo test -p xcl --lib -- gpu::recomp --test-threads=4, debug:743a612XCL_ADAPTER=radeon XCL_REQUIRE_GPU=wave64743a612XCL_ADAPTER=radeon XCL_REQUIRE_GPU=wave64cbc296aThe 2 failures on the Radeon, on both commits, are
f16_programs_on_the_gpuandf32_programs_on_the_gpu. They come from the harness, not from this PR: their wave32 per-lane cases are refused (unsupported V_MUL_F16/V_CVT_F16_F32 (its #1426 semantics differ from the console's)), andskip_test(runner.rs:617-628) turns every skip except "no mesh shaders" into a failure whenXCL_REQUIRE_GPU=wave64is set, a refusal included. This is the same pattern as #1651. The head has 2 more passing tests than the base: this PR's two new cache tests.Tested
--locked --offline; title runs and tests started under a local account without network accessNot tested
AI use: omp. Claude Opus 5.5 reviewed the diff before the build and planned the comparison; Claude Fable 5.2 ran it and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 04:55 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!