dxc: hash arguments into the DXIL cache key and honor XCL_DXC_ARGS (#559) #591

Open
github-bot wants to merge 1 commit from github-bot/gh-591 into main AGit
Owner

@⁠Ivankiosan on GitHub · 2026-11-24 02:12 UTC · original
Ivankiosan:dxc-cache-key-args → main · +142 −33 · 1 files · 1 commits · open

Hash explicit and environment DXC arguments into the DXIL disk cache key, and honor XCL_DXC_ARGS on the cached compilation path. Fixes #559.

Previously, cache_key_for_toolchain only hashed the package version, toolchain identity, profile, entry, and source text, omitting any compiler arguments (extra: &[&str]). Furthermore, compile_cached_in hardcoded an empty argument list &[], ignoring XCL_DXC_ARGS. This caused different optimization levels or custom arguments to collide on the same cache key or be dropped entirely.

This change:

  1. Updates cache_key_for_toolchain and cache_key to append and hash the argument list into the FNV-1a digest. Empty argument lists keep the digest unchanged.
  2. Introduces compile_cached_args to allow callers to pass explicit arguments through the cache.
  3. Plumbs XCL_DXC_ARGS through compile_cached_in so environment-specified arguments reach both the cache key and the compiler.

What is in it

  • crates/xcl/src/gpu/recomp/dxc.rs: hash arguments into cache_key_for_toolchain, expose compile_cached_args, consult XCL_DXC_ARGS in compile_cached_in, and add unit tests verifying key separation and environment variable handling

Tested

  • Hardware: AMD Radeon RX 7600 (8152 MiB VRAM, driver 32.0.32029.2010), AMD x86_64 CPU, Windows 11 Build 26200, rustc 1.100.0 (MSVC), debug & release builds
  • Commands run: cargo test --workspace -- --test-threads=4: 678 passed, 0 failed, 37 ignored
  • SKIPPED GPU tests on adapter: none
  • Title checked: retail title Scarlett retail build (game_scarlett_master.exe)

Regression run

xcl-smoke v1
commit: 9ce2070eccf436d7bd38601c90407da447df34f3
gpu: AMD Radeon RX 7600
title: xbox
seconds: 20
exit: 0x0
frames shown: 234 (PresentX 235)
presents per 2 s (last 3): 60 60 38
device removals: 0
crashes: 0
peak commit: 10054 MB
xcl-smoke v1
commit: 6c68cc703df3e2d75d5820ee594a4a155ce3ee9e
gpu: AMD Radeon RX 7600
title: xbox
seconds: 20
exit: 0x0
frames shown: 211 (PresentX 213)
presents per 2 s (last 3): 27 52 59
device removals: 0
crashes: 0
peak commit: 9695 MB

Not tested

  • NVIDIA GPUs / Intel Arc GPUs
  • Shaders exceeding 8 MB size threshold under non-default optimization flags

AI use

  • Antigravity with Gemini 2.5 Flash for investigating issue #559, implementing cache key argument hashing and helper functions, writing unit tests, and running full workspace tests and regression smoke runs
**@⁠Ivankiosan** on GitHub · 2026-11-24 02:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/591) `Ivankiosan:dxc-cache-key-args` → `main` · +142 −33 · 1 files · 1 commits · open Hash explicit and environment DXC arguments into the DXIL disk cache key, and honor `XCL_DXC_ARGS` on the cached compilation path. Fixes #559. Previously, `cache_key_for_toolchain` only hashed the package version, toolchain identity, profile, entry, and source text, omitting any compiler arguments (`extra: &[&str]`). Furthermore, `compile_cached_in` hardcoded an empty argument list `&[]`, ignoring `XCL_DXC_ARGS`. This caused different optimization levels or custom arguments to collide on the same cache key or be dropped entirely. This change: 1. Updates `cache_key_for_toolchain` and `cache_key` to append and hash the argument list into the FNV-1a digest. Empty argument lists keep the digest unchanged. 2. Introduces `compile_cached_args` to allow callers to pass explicit arguments through the cache. 3. Plumbs `XCL_DXC_ARGS` through `compile_cached_in` so environment-specified arguments reach both the cache key and the compiler. **What is in it** - `crates/xcl/src/gpu/recomp/dxc.rs`: hash arguments into `cache_key_for_toolchain`, expose `compile_cached_args`, consult `XCL_DXC_ARGS` in `compile_cached_in`, and add unit tests verifying key separation and environment variable handling **Tested** - Hardware: AMD Radeon RX 7600 (8152 MiB VRAM, driver 32.0.32029.2010), AMD x86_64 CPU, Windows 11 Build 26200, rustc 1.100.0 (MSVC), debug & release builds - Commands run: `cargo test --workspace -- --test-threads=4`: 678 passed, 0 failed, 37 ignored - `SKIPPED` GPU tests on adapter: none - Title checked: retail title Scarlett retail build (`game_scarlett_master.exe`) **Regression run** ``` xcl-smoke v1 commit: 9ce2070eccf436d7bd38601c90407da447df34f3 gpu: AMD Radeon RX 7600 title: xbox seconds: 20 exit: 0x0 frames shown: 234 (PresentX 235) presents per 2 s (last 3): 60 60 38 device removals: 0 crashes: 0 peak commit: 10054 MB ``` ``` xcl-smoke v1 commit: 6c68cc703df3e2d75d5820ee594a4a155ce3ee9e gpu: AMD Radeon RX 7600 title: xbox seconds: 20 exit: 0x0 frames shown: 211 (PresentX 213) presents per 2 s (last 3): 27 52 59 device removals: 0 crashes: 0 peak commit: 9695 MB ``` **Not tested** - NVIDIA GPUs / Intel Arc GPUs - Shaders exceeding 8 MB size threshold under non-default optimization flags **AI use** - Antigravity with Gemini 2.5 Flash for investigating issue #559, implementing cache key argument hashing and helper functions, writing unit tests, and running full workspace tests and regression smoke runs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:34 +00:00
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-24 02:47 UTC · original

NVIDIA run, since Not tested lists NVIDIA GPUs.

Tested

  • Exact head 6c68cc703df3e2d75d5820ee594a4a155ce3ee9e, clean worktree
  • NVIDIA GeForce RTX 3060 (32-lane waves), driver 32.0.16.1088; AMD Ryzen 7 5700X; Windows 11 Pro 26H2 (build 26300.9974); rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); debug
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4: 687 passed, 0 failed, 41 ignored (lib 647 / 0 / 21)
  • The three new tests passed in that run: cache_key_tracks_the_dxc_arguments, compile_cached_args_distinguishes_argument_lists, compile_cached_in_honors_xcl_dxc_args_env
  • SKIPPED (no wave64 on this adapter): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • XCL_SAMPLE_* and XCL_DXC_ARGS not set

Not tested

  • A retail title, so no smoke.ps1 run here.
  • Release build; one run of the suite only.

AI use

  • Claude Code (Claude Opus 5.5) ran the build and tests on the machine above and wrote this report from the log.
**@⁠fromthemoonx** on GitHub · 2026-11-24 02:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/591#issuecomment-7120482871) NVIDIA run, since **Not tested** lists NVIDIA GPUs. **Tested** - Exact head `6c68cc703df3e2d75d5820ee594a4a155ce3ee9e`, clean worktree - NVIDIA GeForce RTX 3060 (32-lane waves), driver 32.0.16.1088; AMD Ryzen 7 5700X; Windows 11 Pro 26H2 (build 26300.9974); rustc 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); debug - `cargo build --workspace`, then `cargo test --workspace -- --test-threads=4`: **687 passed, 0 failed, 41 ignored** (lib 647 / 0 / 21) - The three new tests passed in that run: `cache_key_tracks_the_dxc_arguments`, `compile_cached_args_distinguishes_argument_lists`, `compile_cached_in_honors_xcl_dxc_args_env` - SKIPPED (no wave64 on this adapter): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` - `XCL_SAMPLE_*` and `XCL_DXC_ARGS` not set **Not tested** - A retail title, so no `smoke.ps1` run here. - Release build; one run of the suite only. **AI use** - Claude Code (Claude Opus 5.5) ran the build and tests on the machine above and wrote this report from the log.
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 02:55 UTC · original

Test run of 6c68cc703df3e2d75d5820ee594a4a155ce3ee9e on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto current main 18c105a locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 692 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 652 passed, 0 failed, 21 ignored
  • 0 SKIPPED; cache_key_tracks_the_dxc_arguments, compile_cached_args_distinguishes_argument_lists and compile_cached_in_honors_xcl_dxc_args_env pass.

Review: An empty argument list keeps the old digest, so existing caches stay valid. One thing in the tests: compile_cached_in_honors_xcl_dxc_args_env sets XCL_DXC_ARGS="-O1" with std::env::set_var in the middle of the xcl lib test binary, which runs with several threads. While it is set, any GPU test compiling through compile_cached / compile_cached_in at the same time reads -O1 from env_dxc_args(), compiles with it and caches under that key. It does not fail anything today, but it makes those runs depend on scheduling. Testing env_dxc_args()'s parsing separately and calling compile_cached_args with an explicit list (as compile_cached_args_distinguishes_argument_lists already does) would keep the environment untouched. Smaller: XCL_DXC_ARGS is split on whitespace, so an argument containing a space cannot be passed.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

**@⁠MesshM** on GitHub · 2026-11-24 02:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/591#issuecomment-7120601229) Test run of `6c68cc703df3e2d75d5820ee594a4a155ce3ee9e` on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto current `main` `18c105a` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **692 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 652 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; `cache_key_tracks_the_dxc_arguments`, `compile_cached_args_distinguishes_argument_lists` and `compile_cached_in_honors_xcl_dxc_args_env` pass. **Review:** An empty argument list keeps the old digest, so existing caches stay valid. One thing in the tests: `compile_cached_in_honors_xcl_dxc_args_env` sets `XCL_DXC_ARGS="-O1"` with `std::env::set_var` in the middle of the `xcl` lib test binary, which runs with several threads. While it is set, any GPU test compiling through `compile_cached` / `compile_cached_in` at the same time reads `-O1` from `env_dxc_args()`, compiles with it and caches under that key. It does not fail anything today, but it makes those runs depend on scheduling. Testing `env_dxc_args()`'s parsing separately and calling `compile_cached_args` with an explicit list (as `compile_cached_args_distinguishes_argument_lists` already does) would keep the environment untouched. Smaller: `XCL_DXC_ARGS` is split on whitespace, so an argument containing a space cannot be passed. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Author
Owner

@⁠KainanP on GitHub · 2026-11-24 19:35 UTC · original

Thanks for wiring XCL_DXC_ARGS into the cache key. I read the diff at 6c68cc7 (not run).

Two things about compile_cached_in_honors_xcl_dxc_args_env:

  1. It sets/removes the process-wide XCL_DXC_ARGS while other tests run in parallel. dxil_cache_round_trip calls compile_cached_in twice and asserts the second is a hit. If the set_var("-O1")/remove_var window falls between those calls, the keys differ ([] vs ["-O1"]) and that test fails intermittently.
  2. It calls compile_cached_in_with(..., &env_dxc_args()...) directly, so the compile_cached_in → env_dxc_args wiring is not actually tested.

Suggestion: split parsing into a pure dxc_args_from(Option<&str>) -> Vec<String> and test that, plus compile_cached_args with explicit lists (already covered), and drop the env mutation. Alternatively, guard every test that touches the variable or compile_cached_in with one shared mutex.

AI use: Claude Code (Claude Opus 5.5) read the diff; not run. Checked by the user before posting.

**@⁠KainanP** on GitHub · 2026-11-24 19:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/591#issuecomment-7142315879) Thanks for wiring `XCL_DXC_ARGS` into the cache key. I read the diff at 6c68cc7 (not run). Two things about `compile_cached_in_honors_xcl_dxc_args_env`: 1. It sets/removes the process-wide `XCL_DXC_ARGS` while other tests run in parallel. `dxil_cache_round_trip` calls `compile_cached_in` twice and asserts the second is a hit. If the `set_var("-O1")`/`remove_var` window falls between those calls, the keys differ (`[]` vs `["-O1"]`) and that test fails intermittently. 2. It calls `compile_cached_in_with(..., &env_dxc_args()...)` directly, so the `compile_cached_in` → `env_dxc_args` wiring is not actually tested. Suggestion: split parsing into a pure `dxc_args_from(Option<&str>) -> Vec<String>` and test that, plus `compile_cached_args` with explicit lists (already covered), and drop the env mutation. Alternatively, guard every test that touches the variable or `compile_cached_in` with one shared mutex. _AI use: Claude Code (Claude Opus 5.5) read the diff; not run. Checked by the user before posting._
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 06:43 UTC · original

Empirical test report (6c68cc70)

Hardware / environment

  • Commit 6c68cc703df3e2d75d5820ee594a4a155ce3ee9e, verified at detached HEAD.
  • Windows 11 Enterprise Evaluation x64, build 26200, in QEMU. CPU reported by Windows as AuthenticAMD Family 23 Model 113 Stepping 0, approximately 3.9 GHz.
  • Rust 1.100.0 (0ef1bc386), host x86_64-pc-windows-msvc, unoptimized test profile. Loaded DXC compiler and DXIL signer 1.9.2609.5 (compiler revision 01b62ad4).
  • CPU/DXC-only run outside the Arc test wrapper. No GPU mutex was acquired.

Commands and results

  • cargo test --workspace --no-run exited 0. It built the workspace test binaries and executed no tests.
  • With XCL_ADAPTER=NONE_CPU_ONLY, RUST_TEST_NOCAPTURE=1, and XCL_DXC_ARGS initially unset, cargo test -p xcl --lib gpu::recomp::dxc:: -- --test-threads=1 exited 0. The focused log recorded 17 passed, 0 failed, 0 ignored, 0 skipped and 651 filtered out. Skips were counted from case-sensitive lines beginning with SKIPPED .
  • The focused run used one test thread because the environment-variable test changes process-wide state.

Observed behavior

  • The three new tests passed. Different optimization flags and argument token boundaries produced different cache keys. Reusing the same argument list hit the cache. Changing the list or setting XCL_DXC_ARGS=-O1 caused a miss in the synthetic cache tests, and repeating the environment value hit the cache.
  • The installed DXC loaded successfully and compiled a minimal compute shader in the default-argument cache round trip. The repeated request returned identical DXIL from cache.

Not tested

Full GPU workspace suite, game smoke runs, and real DXC compilation with overridden flags. The flag-specific tests used synthetic DXIL.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr591-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/591#issuecomment-7155086577) ### Empirical test report (6c68cc70) **Hardware / environment** - Commit `6c68cc703df3e2d75d5820ee594a4a155ce3ee9e`, verified at detached HEAD. - Windows 11 Enterprise Evaluation x64, build 26200, in QEMU. CPU reported by Windows as AuthenticAMD Family 23 Model 113 Stepping 0, approximately 3.9 GHz. - Rust 1.100.0 (`0ef1bc386`), host `x86_64-pc-windows-msvc`, unoptimized test profile. Loaded DXC compiler and DXIL signer 1.9.2609.5 (compiler revision `01b62ad4`). - CPU/DXC-only run outside the Arc test wrapper. No GPU mutex was acquired. **Commands and results** - `cargo test --workspace --no-run` exited 0. It built the workspace test binaries and executed no tests. - With `XCL_ADAPTER=NONE_CPU_ONLY`, `RUST_TEST_NOCAPTURE=1`, and `XCL_DXC_ARGS` initially unset, `cargo test -p xcl --lib gpu::recomp::dxc:: -- --test-threads=1` exited 0. The focused log recorded **17 passed, 0 failed, 0 ignored, 0 skipped** and 651 filtered out. Skips were counted from case-sensitive lines beginning with `SKIPPED `. - The focused run used one test thread because the environment-variable test changes process-wide state. **Observed behavior** - The three new tests passed. Different optimization flags and argument token boundaries produced different cache keys. Reusing the same argument list hit the cache. Changing the list or setting `XCL_DXC_ARGS=-O1` caused a miss in the synthetic cache tests, and repeating the environment value hit the cache. - The installed DXC loaded successfully and compiled a minimal compute shader in the default-argument cache round trip. The repeated request returned identical DXIL from cache. **Not tested** Full GPU workspace suite, game smoke runs, and real DXC compilation with overridden flags. The flag-specific tests used synthetic DXIL. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr591-focused.log and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 13:06 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!

**@⁠DavidM1911** on GitHub · 2026-11-25 13:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/591#issuecomment-7163310485) 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!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/591/head:github-bot/gh-591'
git switch 'github-bot/gh-591'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-591'
git switch 'github-bot/gh-591'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-591'
git switch 'github-bot/gh-591'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-591'
git switch 'main'
git merge --squash 'github-bot/gh-591'
git switch 'main'
git merge --ff-only 'github-bot/gh-591'
git switch 'main'
git merge 'github-bot/gh-591'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.