Skip to content

Shaders: DXC compiles skip dxil.dll's validator and XCL signs the DXIL - #1618

Open
chippy01 wants to merge 1 commit into
xcl-dev:mainfrom
chippy01:dxc-bypass-hash
Open

chippy01 wants to merge 1 commit into
xcl-dev:mainfrom
chippy01:dxc-bypass-hash

Conversation

@chippy01

@chippy01 chippy01 commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of #1269.

Every DXC compile runs dxil.dll's validator, which signs the container: D3D12 refuses DXIL without a valid hash. Since #1426, XCL computes that hash itself (gpu::dxil::container::hash, the retail DXBC digest). A title's compiles and xcl shaders --precompile now run DXC with -Vd and sign the container in XCL: the same bytes as before, without the validator's run. On 253 programs of the retail title's pack the validator was 6.4 % of DXC's time and refused none of them.

(The first revision of this PR used the runtime's BYPASS hash instead; it was reworked onto #1426's digest once that was merged, so it no longer depends on the runtime and the caches see the same DXIL as before.)

What is in it

  • crates/xcl/src/gpu/recomp/dxc.rs: compile_without_validator() turns it on for the process (XCL_DXC_VALIDATE=1 keeps the validator); compile_here adds -Vd and sign writes the digest into the container DXC left unsigned. Tests: unsigned_containers_get_the_hash_the_validator_writes (four DXC-signed containers of tests/data/dxil get their own hash back after it is zeroed) and unvalidated_compiles_give_the_validators_container (a CS and a PS through DXC both ways: the same bytes).
  • crates/xcl/src/host.rs: the title host turns it on. crates/xcl/src/shaders.rs: xcl shaders --precompile turns it on. The unit tests do not: the validator stays their oracle.
  • README.md: one line.

Tested

  • NVIDIA GeForce RTX 3070 Ti 8 GB (driver 621.24), AMD Ryzen 9 7900X, 32 GB RAM, Windows 11 Pro 26200, rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); tests in debug, runs in release.

  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 on main 06c9f55 with this change: 1267 passed, 0 failed, 46 ignored. SKIPPED: 21 GPU cases for want of wave64 on this card (among them gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, dispatch_chain_native_wave64_builds_whole and the lower / lower_dxil wave64 comparisons), 3 lower_dxil f16 / f32 per-lane cases the per-lane form refuses, and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

  • Seen while testing, in code this PR does not touch:

    • 06c9f55, the first suite run: the lib test binary stopped on a device removal (0x887a0006, device hung) while the hle::d3d12x::list_x cross-queue Wait64BitValueX tests ran (the log ends with cross_queue_cycle_and_same_queue_fifo_do_not_deadlock's >= 0x702 waits). The lib tests never turn this PR's path on (only the title host and --precompile do); the lib binary alone, and then the whole suite above, passed.
    • f087b99 (the previous base): two tests failed with and without this change; Tests: two expectations that no longer match the code #2245 has fixed both on main.
    • c160d86: concurrent_cache_misses_compile_once failed once on its timing check (cached-only waited 1.09 s, limit 200 ms) and passed in the next run.
  • With the sign call removed, unvalidated_compiles_give_the_validators_container fails; with the digest taken over the wrong bytes, both new tests fail.

  • DXC time with and without the validator, on 253 programs of the retail title's shaders.rpf (every 100th by name: xcl shaders --recomp with XCL_DUMP_HLSL, XCL_RECOMP_WINDOWS=4), with XCL's arguments (-HV 2021, -O1 over 1 MB of HLSL) and the SDK's dxc.exe, one compile at a time, the order alternating per program:

    HLSL programs validated -Vd saved
    < 64 KB 55 6.9 s 6.8 s 1.7 %
    64 KB – 256 KB 129 49.2 s 46.9 s 4.7 %
    256 KB – 1 MB 46 64.7 s 61.4 s 5.1 %
    1 – 8 MB (-O1) 23 212.5 s 196.7 s 7.4 %
    all 253 333.2 s 311.8 s 6.4 %

    All 253 compile both ways and the validator refused none. For all 253, container::hash of the -Vd container equals the hash dxil.dll wrote, and the rest of the container is identical.

  • The same 253 in one process on 23 threads, one IDxcCompiler3 per thread as in XCL's pool: 38.8 s and 37.5 s validated, 35.8 s and 37.3 s with -Vd (alternating; the largest programs set the wall time); peak commit 3.7 – 3.8 GB either way.

  • Retail title, 60 s runs of scripts/smoke.ps1 on the working tree before the commit, on c160d86: from an empty XCL_DXIL_CACHE, the log has DXC: compiles skip dxil.dll's validator and are signed by XCL, 12 compiles, 0 failures, 0 failed pipelines, 1393 frames; all 12 containers carry the correct hash and are byte for byte the ones main's validator made for the same programs in its own run from an empty cache. On 06c9f55, with the shared warm cache: 1593 and 1643 frames (main 06c9f55: 1555 and 1625). No device removal or crash in these runs. The title stays in its menus in 60 s, so they show the output is unchanged, not a speed-up.

  • One run of an earlier head (8b9fec0, on c160d86) ended at 34.6 s with an access violation in title_textures::refresh → subresources → the detiler, reading title memory that was no longer mapped (the class of Textures: safe texture::uma_bytes constructs &'static [u8] over uncommitted sparse UMA windows #1393). This PR does not touch that path; the next run of the same build was clean, and no run of this change or of main on this machine has crashed since.

Regression run

main (06c9f55), the second of two runs (the first showed 1555 frames):

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 3070 Ti
title: a08c0918
seconds: 60
exit: 0x0
frames shown: 1625 (PresentX 1625)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15554 MB

this PR's head:

xcl-smoke v1
commit: 80fb8a442e00048de994e30f7f67a253dded0a25      
gpu: NVIDIA GeForce RTX 3070 Ti
title: a08c0918
seconds: 60
exit: 0x0
frames shown: 1576 (PresentX 1576)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17456 MB

Not tested

  • AMD and Intel GPUs, Windows 10, Wine / vkd3d-proton (the DXIL is the same as before on any of them).
  • A world load: the gain is in the compiles the caches do not have, ~6 % of DXC's time; the driver's compile, which dominates for the biggest programs, is untouched.
  • DXIL the validator would refuse now reaches the driver unchecked (as the direct path's does since gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426). None of the 253 programs was refused; XCL_DXC_VALIDATE=1 brings the validator back for a title.

AI use

  • Claude Code with Claude Opus 5.5: Measured the validator's share, co-authored the change, created its tests and this description, and made the test and title runs reported here. I reviewed the diff and the numbers.

@chippy01
chippy01 marked this pull request as ready for review November 24, 2026 18:24
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…README

Integrates 10 open upstream PRs on top of upstream/main (c160d86):
- xcl-dev#1643: per-queue cpu_writes worker threads (eliminating cross-queue
  head-of-line stalls) and atomic 64-bit immediate writes
- xcl-dev#1618: skip DXC validator where the runtime accepts the BYPASS hash
- xcl-dev#1535, xcl-dev#1536: PresentX COPY_SOURCE barrier and sparse upload COMMON
  state transitions
- xcl-dev#1516: route stream graphics PSO creation through tracked path
- xcl-dev#1478: avoid taking sparse state lock on resource final Release
- xcl-dev#1473: implement S_QUADMASK_B32 and S_QUADMASK_B64
- xcl-dev#1621, xcl-dev#1625: frame clock revalidation and short uncompressed
  DirectStorage request zero-padding
- xcl-dev#1557: accept no buffer context before Start in XMA2 voice test under
  Wine

Verified under GE-Proton11-14 + vkd3d-proton ec20719452e916b:
- Release build (x86_64-pc-windows-msvc): ok (32.14s)
- Proton unit tests (heap_window_tests, dxil::core_tests, cpu_writes,
  frame, sparse, present, dstorage, xma2_source_voice,
  gpu_sparse_vram_descriptors_buffers_and_xmem, gpu_valu_float_and_int):
  71 passed, 0 failed, 2 ignored, 0 skipped.
@chippy01 chippy01 changed the title Shaders: skip DXC's validator where the runtime takes the BYPASS hash Shaders: DXC compiles skip dxil.dll's validator and XCL signs the DXIL Nov 24, 2026
@MatyEjsr

MatyEjsr commented Nov 24, 2026 •

Copy link
Copy Markdown

Updated independent Windows / NVIDIA GPU verification on the rebased head b6f4f75b8f17c66cbbd02787ff55612fbda6a46c (superseding earlier run on 8b9fec0; base 1d027e5, verified clean merge with current main 568e7db) using DXC 1.9.2602.17.

Tested

  • Hardware & OS: Windows 11 Pro for Workstations 10.0.26200 (Build 26200; Developer Mode enabled), AMD Ryzen 7 7800X3D (8-core), NVIDIA GeForce RTX 3090 24 GB (driver 617.42, wave32), 31.4 GB RAM
  • Toolchain: rustc 1.100.0 (stable-x86_64-pc-windows-msvc), debug and release builds, Windows SDK DXC dxcompiler 1.9.2602.17 (21d28f72) + dxil 1.9.2602.17
  • git merge-tree --write-tree main HEAD (against main 568e7db): exit 0 (no conflicts, including alongside b937c33 in dxc.rs)
  • cargo build --workspace -j 8: ok (14.78s, 0 errors, 0 warnings in PR files)
  • cargo build --release --workspace -j 8: ok (35.64s, 0 errors, 0 warnings in PR files)
  • cargo test --workspace -j 8 -- --test-threads=4: 961 passed, 0 failed, 43 ignored, 22 SKIPPED
    • 18 no wave64 skips (gpu::recomp::lower::tests::{a_2d_or_3d_group_agrees_with_the_hlsl_path_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, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu}, gpu::recomp::lower_dxil::tests::{a_per_lane_2d_or_3d_group_runs_on_the_gpu, f16_programs_on_the_gpu [2 wave64 cases], f32_programs_on_the_gpu [6 wave64 cases], f64_programs_on_the_gpu, integer_programs_on_the_gpu [2 wave64 cases]}, gpu::recomp::tests::{gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware})
    • 3 per-lane form refusals (gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu wave32 f16 arithmetic / f16 packed, f32_programs_on_the_gpu wave32 f32 conversions)
    • 1 no heap windows skip (heap_window_out_of_memory_falls_back_to_the_switch_form)
  • cargo test -p xcl --lib -- "gpu::recomp::dxc::" --nocapture: 16 passed, 0 failed, 0 ignored, 0 SKIPPED (0.44s with dxil.dll; 0.45s with a dxcompiler.dll-only directory without dxil.dll). Both unsigned_containers_get_the_hash_the_validator_writes and unvalidated_compiles_give_the_validators_container pass on DXC 1.9.2602.17.
  • cargo test --test e2e -j 8 -- --nocapture: 3 passed, 0 failed, 0 ignored, 0 SKIPPED across all four configurations:
    • default (-Vd + XCL signing, 1.92s): logs DXC: compiles skip dxil.dll's validator and are signed by XCL (XCL_DXC_VALIDATE=1 validates them)
    • XCL_DXC_VALIDATE=1 (1.90s): opt-out works; validator stays enabled
    • XCL_DIRECT_DXIL=1 (1.92s): passes with XCL signing enabled for DXC compiles
    • dxcompiler.dll-only directory without dxil.dll (1.93s): logs no dxil.dll and signs in XCL; D3D12 accepts the resulting shaders
  • Release cold xcl shaders <pack> --precompile --limit 256 (alternating 2x2 runs with XCL_TRANSLATED_CACHE=0, XCL_PSO_DISK_CACHE=0, XCL_PSO_PRELOAD=0, and a fresh XCL_DXIL_CACHE per run; 7 compile threads, 4 memory windows, split wave64):
    • Default (-Vd + XCL signing): 285 compiled, 115 already cached, 0 errors, 6 GS skipped — wall time 6.61 s and 6.70 s (6.6 s reported)
    • XCL_DXC_VALIDATE=1 (dxil.dll 1.9.2602.17): 285 compiled, 115 already cached, 0 errors, 6 GS skipped — wall time 6.90 s and 6.97 s (6.8 s and 6.9 s reported)
    • SHA-256 comparison across all 285 compiled .dxil outputs on DXC 1.9.2602.17: 285/285 byte-for-byte identical (0 mismatches, 0 missing on either side), with a consistent ~4% wall-clock speedup on this 7-thread slice.

Code review

  • Rebase onto 1d027e5 resolved the earlier merge conflict cleanly and merges cleanly with current main (568e7db).
  • Minimal, well-scoped diff (dxc.rs, host.rs, shaders.rs, README.md): WITHOUT_VALIDATOR stays off in tests and diagnostic CLI sweeps (--compile, --measure-pso), enables only in host_main and xcl shaders --precompile, honors XCL_DXC_VALIDATE=1, leaves toolchain_identity() intact for disk cache compatibility, and sign() only populates zeroed DXBC hashes.

Not tested

  • AMD / Intel GPUs, native hardware wave64, heap-window OOM fallback (XCL_HEAP_WINDOWS=1), retail title scripts/smoke.ps1 / world-load runs, Wine / vkd3d-proton, and XCL_SAMPLE_* tests.

AI use

  • agy with gemini-4-neon-high (audited by gemini-4-neon-medium): reviewed the rebased diff, ran the debug and release builds, workspace/targeted tests, and cold --precompile byte-identity and timing checks, and wrote/audited this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main in crates/xcl/src/gpu/recomp/pso.rs — needs a rebase before it can be tested.

@chippy01

Copy link
Copy Markdown
Author

@DavidM1911 yep doing it as soon as i have time.

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@chippy01

Copy link
Copy Markdown
Author

@DavidM1911 No more merge conflict if you want to test

@raylitebull

Copy link
Copy Markdown
Member

Diff audit on b6f4f75 (dxc.rs, host.rs, shaders.rs, README.md) looks clean, Build and test + PR description are green, and RTX 3070 Ti + RTX 3090 verification is thorough (285/285 byte-for-byte DXIL parity with DXC -Vd + XCL container::hash).

Only item needed before merge is an AMD (and/or Intel) verification pass on b6f4f75.

Every DXC compile runs dxil.dll's validator, which signs the container:
D3D12 refuses DXIL without a valid hash. Since xcl-dev#1426 XCL computes that
hash itself (gpu::dxil::container::hash, the retail DXBC digest). A
title's compiles and xcl shaders --precompile now run DXC with -Vd and
sign the container here: the same bytes as before, without the
validator's run.

On 253 programs of a retail pack (every 100th, DXC 1.8.2502) the
validator was 6.4 % of DXC's time (333.2 s -> 311.8 s one compile at a
time, 7.4 % on the 1-8 MB programs) and refused none of them. For all
253, the digest of the -Vd container equals the signature dxil.dll
wrote, and the rest of the container is identical.

Tests keep the validator as their oracle, and XCL_DXC_VALIDATE=1 keeps
it for a title too.

Part of xcl-dev#1269.
@chippy01

Copy link
Copy Markdown
Author

Thanks for the audit. I have no AMD or Intel card, so those stay under Not tested. The driver gets the same bytes it gets on main: XCL's digest matched dxil.dll's signature on 253/253 programs here (DXC 1.8) and 285/285 in MatyEjsr's run (DXC 1.9). A run on AMD or Intel from anyone is welcome.

Since your audit the PR was rebased twice, onto main 06c9f55 now (head 80fb8a4). Its added and removed lines are the same as in b6f4f75; only the code around them on main changed.

@chippy01

Copy link
Copy Markdown
Author

@DavidM1911 Rebased again, onto main 06c9f55 (head 80fb8a4): no conflict, if you still want to test it.

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.

5 participants