Skip to content

Shaders: restore direct DXIL cache ID after source deletion - #2047

Draft
luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/dxil-source-deletion
Draft

luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/dxil-source-deletion

Conversation

@luckyteagirl

Copy link
Copy Markdown

Fixes #2033. Cargo can miss the first build after a nested direct-DXIL source is deleted, leaving the temporary source ID in the binary and missing otherwise valid shader-cache entries. The build script keeps its directory watch for additions and now also watches each file it hashes, so removal of a watched file reruns the script immediately. The hash algorithm and cache identity for unchanged sources do not change.

What is in it

  • crates/xcl/build.rs: emit cargo:rerun-if-changed for every direct-DXIL source included in the hash, while retaining the directory watch.
  • scripts/test_dxil_source_id.py: run the real build script in a temporary, dependency-free Cargo package; add and remove a nested DXIL source, then compare the first post-removal incremental ID with a clean build. It leaves no fixture files in the repository.

Tested

  • Head 3933694fcb35f157fd4b169ecfd14015b9724ce2 on main 3da2abb81606df622610e009f0430de99aa9881c; Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. Debug workspace build and tests; release main and PR builds.
  • python scripts/test_dxil_source_id.py failed before the fix: original/clean ID 344117f303413662, first post-deletion ID 26dcbf2be98a5142, second post-deletion ID restored. On this exact head it passed: first post-deletion, clean, and original IDs were all 344117f303413662.
  • git show --check HEAD, cargo build --locked --workspace -j 2, and cargo build --locked --release -p xcl -j 2 passed.
  • cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output completed across 20 binaries: 953 passed, 158 failed, 46 ignored. Eight explicit SKIPPED messages are included in the passed count. The RX 6800M GPU was suspended (0x887A0005), followed by GPU test failures; this suite was not green.
  • A locally owned title ran for 7 seconds on the RX 6800M at both revisions. Each showed one frame, no crash, and no device removal; peak process commit was 6,979 MB on main and 6,989 MB on this PR.

Regression run

main:

xcl-smoke v1
commit: 3da2abb81606df622610e009f0430de99aa9881c
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 6979 MB

PR head:

xcl-smoke v1
commit: 3933694fcb35f157fd4b169ecfd14015b9724ce2
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 6989 MB

Not tested

  • The 7-second title run logged zero draws and did not add/remove translator sources; the standalone Cargo fixture is the direct test of this fix. Longer title runs, other adapters, and newer drivers are untested.

AI use

OpenAI Codex (GPT-6, exact variant not exposed in this session) implemented the fix and regression script, ran the builds and tests, reviewed the diff, and drafted this description.

@lewisnic94-max lewisnic94-max left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 3933694fcb35f157fd4b169ecfd14015b9724ce2, the first Cargo build after deleting a nested direct-DXIL source restored the clean fingerprint in 8/8 cycles, versus 0/8 on merge base 3da2abb81606df622610e009f0430de99aa9881c. The first restored workspace executable also reused the original HLSL, direct-compute, direct-all and per-lane entries. All four synthetic compute pipelines were created, with unchanged cache paths, bytes and timestamps.

Two P3 findings in scripts/test_dxil_source_id.py (high confidence)

  1. Line 69. With PYTHONOPTIMIZE=1, the PR script paired with the unpatched build.rs exits 0 even though the first restored ID is 26dcbf2be98a5142 and the clean ID is 344117f303413662. Normal Python exits 1 on the same input. Use explicit checks that raise or exit nonzero, and run this known-bad control with optimization enabled.

  2. Line 32. With CARGO_BUILD_TARGET=x86_64-pc-windows-msvc on native Windows, Cargo builds the probe successfully, then the script raises FileNotFoundError looking under debug/. Use cargo run --offline --quiet to read the ID without guessing the executable path. A scratch copy with both corrections passed on the fixed head with the host target set and failed on the optimized broken control.

The default script failed on the merge-base build script and passed on this head. Adding it to Windows CI would exercise this regression on future changes. The workspace suite currently does not invoke it.

Tested. Windows 11 26200.9974, Ryzen 7 5800X, RTX 3080 (616.92), Rust/Cargo 1.100.0 MSVC, DXC 1.9.2602.17. cargo test --locked --workspace --no-fail-fast -j 1 -- --test-threads=4 --nocapture gave 1,111 passed, 0 failed, 46 ignored on the head and 1,111 passed, 0 failed, 46 ignored on the base. The head emitted 27 explicit SKIPPED messages and 12 other skip messages, some for subcases. The shader_cache_tests filter passed 15/15.

AMD and coverage. Earlier RX 6800M runs on driver 30.0.13002.13003 also reported device removal. A pre-existing failure cascade is plausible, but the public record does not establish the cause of all 158 failures. A same-driver merge-base run with the first error and per-test results would distinguish them. I did not test AMD, wave64, release builds or a retail title. Earlier RX 6800M report

AI assistance. OpenAI Codex (GPT-6) inspected the changes, ran the independent tests and drafted this review.

@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

One thing that only shows after a merge with main (read at 3933694, not run): scripts/test_dxil_source_id.py:41 copies only build.rs into its package, and main's crates/xcl/build.rs (since #2031) loads src/source_hash.rs as a module (#[path], line 49), which is not there, so the script would fail at its first build. CI doesn't run it, so nothing reports it. Copying that file to the package's src/ too should be enough.

The build.rs change reads right to me (it fixes my #1947): it watches exactly the files it hashes and does not change what is hashed.

Read by Claude Code (Claude Opus 5.5), checked with Claude Fable 5.2; each point checked by a person before posting.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Windows 11 Enterprise Evaluation x64 build 26200.9974, NTFS, Ryzen 7 3800X, native x86_64-pc-windows-msvc Rust/Cargo 1.100.0, Cargo dev profile, portable CPython 3.13.7 from L:/XclTooling/pr1999-coverage-52a120f7/portable.

Command for each run: & 'L:/XclTooling/pr1999-coverage-52a120f7/portable/python.exe' scripts/test_dxil_source_id.py from the checkout or scratch fixture root. The script invokes cargo build --offline --quiet --manifest-path <fixture>/Cargo.toml --target-dir <target> and runs the resulting debug/xcl.exe after each successful build.

  • PR Shaders: restore direct DXIL cache ID after source deletion #2047 3933694fcb35f157fd4b169ecfd14015b9724ce2 — Clean detached checkout, verified against the open PR before and after execution. The checked-in script exited 0. Five Cargo builds and five probes succeeded, all four assertions passed, and there were zero failures or skips. The temporary source changed the ID from 344117f303413662 to 26dcbf2be98a5142. The first incremental build after deletion, the clean build, and the second incremental build all returned 344117f303413662.
  • Main cbc296ab65a2661a61e3e2da109134bcd5319f60 — In scratch fixtures with main's exact build.rs and src/source_hash.rs, the submitted script exited 1 on the first Cargo build because it did not copy src/source_hash.rs into the temporary package. One build failed before any probe or assertion ran. With one test-only change to copy the actual module into the package, five builds and five probes succeeded with zero skips. The script exited 1 at the regression assertion: first post-deletion ID 6404de24ffc18849 still matched the temporary-file ID, and the original, clean and second post-deletion IDs were 13533542a3f5a0ac.

Not tested

Rebased or merged PR tree, XCL workspace build or tests, GPU execution, titles, and shader-cache I/O. The probe measured the compiled-in source ID.

AI use

Codex in T3 Code (gpt-6.2-sol, high reasoning effort) ran the checked-in test, prepared and ran the scratch comparisons, and wrote this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First incremental build after a DXIL source deletion can miss valid shader-cache entries

4 participants