tests: add opt-in DXC compile cache for the Python shader checks #2349
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2357"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:33:52Z.
Part of #448
What this unblocks: identical DXC compiles in the Python shader checks can be reused across ctest runs (dev, release and PR reruns), cutting the DXC share of WARP test time that #448 measured at about 19% of
pixel_aot_warp.What changes
tools/dxc_cache.pywithrun_dxc(compiler, args, **options). It mirrorssubprocess.run([compiler, *args]).X2W_DXC_CACHE=<dir>is set. Unset, every call is a plainsubprocess.run, so CI and local runs behave exactly as before.#include/#importin the source,-I,-Fi, response files (@file), unknown-Foutputs, unknown file-like arguments, extrasubprocess.runoptions.#!script mentioningwine) bypass the cache, because the real compiler behind them cannot be fingerprinted.check=Truestill raises.tempfile+os.replace), so parallel ctest jobs can share one directory.tests/pixel_aot_check.pycompile_shadercallsrun_dxc.tests/compute_store_check.pyroutes only DXC-shapedsubprocess.runcalls (-Tand-Fopresent) through the cache with a small proxy, instead of editing its 44 call sites (many open PRs touch that file).tests/dxc_cache_check.pyuses a fake compiler: hit, miss on source/argument/mtime/library change, failures not cached, missing-output-directory retry, Wine launcher bypass, unset variable, include bypass. It runs in the Linux job ofwindows.yml.Verification
Head
384f505d950ba46e09e3d8e0299da223156dc5d8.Linux:
CI on this head: all required jobs green.
Windows Server 2025 WARP at the same head (
x2w_pipe.py win2025 2357 --regex '^(pixel_aot_warp|compute_store_aot_heap_view_load_warp)$' --keep-release, default 5-slot pool), receipt comment posted on this PR:The planned Windows Python checks also passed (exit 0).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T14:34:32Z.
One failed-compile case changes observable output files on Windows at
5a619a41. After a successful DXC compile toprevious.cso(2,052 bytes), I compiled an invalid compute shader to two different output paths using DXC 1.9.2609,-T cs_6_0 -E main -Fo <output> bad.hlsl. All four error returns were0x80004005.run_dxccollects every existing output on a miss, even if the failed invocation left an older file untouched. The replay then materializes unrelated bytecode at the new path. A regression control can seed an output with a successful shader, run a failing compile to that path, and repeat the same failure at an absent path. The fresh output should stay absent. A conservative fix could restrict failure caching to calls with initially absent outputs and replay a cached failure only under the same precondition.For successful compiles I also ran
tests/compute_store_check.py draw-mubuf-formaton WARP and RTX 4060. For each adapter a disabled/cold cache launched DXC 8 times, while both warm passes launched it 0 times. All 12 shader-bytecode hashes presented to the renderer matched in order, with eight 320-word positive dispatches and all four wrong-channel controls. End-to-end times overlapped on the physical adapter.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T14:46:12Z.
Thanks @RavenCurseBurg, good catch. You were right: a failed compile was cached together with any output file that already existed, so a later hit with a new output path could copy old bytecode that direct DXC would never write.
What changed in
tools/dxc_cache.py:New case in
tests/dxc_cache_check.py(stub compiler): seed an output with a successful compile, run a failing compile to that path, then repeat the same failing compile to an absent path. The absent path must stay absent. It fails on the previous head and passes now.Verification:
python3 -B tests/dxc_cache_check.pybefore the fix:failed compile replayed an output file the compiler never wrotedxc_cache_check: okAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T14:53:03Z.
I reran the Windows DXC case at
e0f7d479. A fresh cache now behaves correctly: the old output stays unchanged and a different output path stays absent. A second failing compile from the fresh cache replayed the diagnostic with zero extra compiler launches.One upgrade case remains for a persistent
X2W_DXC_CACHE. I populated a cache with the actual5a619a41implementation, then ran the exact same failing shader usinge0f7d479against that directory. The new implementation made zero compiler launches and wrote the old 2,052-byte shader to a previously absent output path. Both versions use key version 1; the read path still replays the nonemptyfilesfrom the old failure record. Skipping output restoration for a nonzero cached return code would also protect existing directories while retaining successful entries. A key-version bump would also resolve this for users who keep their cache between builds.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T15:05:01Z.
Thank you for rerunning the upgrade case. You were right: an existing cache directory could still replay output files from an old failure record.
What changed:
KEY_VERSIONis now2, so records written by the old version are not found at all.New checks in
tests/dxc_cache_check.py:filesunder the current key: the output path stays absent.1with non-emptyfiles: it is not reused, the compiler runs, and the output path stays absent.Commands run (Linux):
python3 tests/dxc_cache_check.pybefore the change: fails ("cached failure with files restored an output file").dxc_cache_check: ok.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T15:07:40Z.
Confirmed on
fdec33c4with DXC 1.9.2609 on Windows. Using the same persistent directory written by5a619a41(an actual failure record containing 2,052 bytes under-Fo), the new head launched DXC once, returned the original0x80004005, and left the fresh output absent. A second identical failure in a fresh v2 cache used zero additional compiler launches and still left its output absent. The original pre-existing-output check also passed.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T15:12:37Z.
Thanks for confirming on
fdec33c4with a real cache written by5a619a41, and for the upgrade case that led to the key-version bump. No further changes planned for this cache slice unless you see another case.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T21:55:46Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
da1e52d17aℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:13:02Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
9beb7e19c71a68bfc965e82643c8b5cc13d9aafb:tests/compute_alu_bcnt64_check.pyok (0.6s),tests/compute_alu_cmp_ne_check.pyok (0.5s),tests/compute_alu_lane_gaps_check.pyok (0.6s),tests/compute_entry_layout_check.pyok (0.2s),tests/compute_heap_store_check.pyok (0.6s),tests/compute_heap_view_check.pyok (0.6s),tests/compute_load_format_check.pyok (0.6s),tests/form_coverage_check.pyok (11.7s),tests/mesh_clip_cull_check.pyok (4.5s),tests/mesh_heap_sampler_check.pyok (0.8s),tests/pso_readiness_check.pyok (1.1s),tests/rdna2_tools_check.pyok (2.6s),tests/vk_offscreen.pyok (1.2s)sccache: -37/-38 hits; wall37.9sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:50:07Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
da1e52d17a5da826506fbac1372be6ea7869bf36:--preset dev):cmake --build --preset dev -- -j 2):102.23s(configure3.17s)ctest --preset dev -R '^(pixel_aot_warp|compute_store_aot_heap_view_load_warp)$' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (16.71s:pixel_aot_warp14.56s,compute_store_aot_heap_view_load_warp16.53s)/O2(--preset release):cmake --build --preset release -- -j 2):143.35s(configure3.54s)ctest --preset release -R '^(pixel_aot_warp|compute_store_aot_heap_view_load_warp)$' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (24.19s:pixel_aot_warp19.96s,compute_store_aot_heap_view_load_warp23.92s)tests/compute_alu_bcnt64_check.pyok (1.0s),tests/compute_alu_cmp_ne_check.pyok (0.8s),tests/compute_alu_lane_gaps_check.pyok (0.8s),tests/compute_buffer_atomics_check.pyok (0.8s),tests/compute_entry_layout_check.pyok (0.2s),tests/compute_heap_store_check.pyok (0.8s),tests/compute_heap_view_check.pyok (0.8s),tests/compute_load_format_check.pyok (0.8s),tests/form_coverage_check.pyok (16.0s),tests/mesh_clip_cull_check.pyok (6.6s),tests/mesh_heap_sampler_check.pyok (1.0s),tests/pso_readiness_check.pyok (1.3s),tests/rdna2_tools_check.pyok (3.8s),tests/vk_offscreen.pyok (2.0s)sccache: 74/401 hits; wall330.0sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T21:50:25Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
da1e52dℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T21:55:46Z.
Code review location:
tools/dxc_cache.py; line 153With caching enabled in the documented Wine setup (
docs/non-windows-hosts.md:236-248),_resolve()identifies the shell launcher, while itsexec wine "$DXC"runs an SDK compiler in another directory. This key therefore fingerprints the launcher and probes its adjacent libraries, not the actualdxc.exeor DLLs. Updating the SDK files at the same path leaves the key unchanged and replays old shader binaries, so the checks can validate stale results against an updated toolchain. Fingerprint the delegated compiler and its libraries, or bypass caching for launchers whose compiler identity cannot be established.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T21:55:46Z.
Code review location:
tools/dxc_cache.py; line 185With caching enabled, any nonzero exit is cached when no output existed beforehand, including failures caused by output I/O or temporary resource exhaustion rather than invalid source. Because
_plan()removes output paths from the key, a failure targeting a missing output directory is subsequently replayed even when a valid directory is supplied. A synthetic compiler reproduced this: the cached retry failed without launching the compiler, while the equivalent uncached call succeeded. Such failures poison subsequent shader checks until the cache is cleared. Restrict cached failures to errors known to be deterministic, or leave nonzero results uncached.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:29:11Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:29:14Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:29:08Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
384f505d950ba46e09e3d8e0299da223156dc5d8:--preset dev):cmake --build --preset dev -- -j 2):184.74s(configure2.91s)ctest --preset dev -R '^(pixel_aot_warp|compute_store_aot_heap_view_load_warp)$' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (15.26s:pixel_aot_warp11.65s,compute_store_aot_heap_view_load_warp15.04s)/O2(--preset release):cmake --build --preset release -- -j 2):165.22s(configure4.19s)ctest --preset release -R '^(pixel_aot_warp|compute_store_aot_heap_view_load_warp)$' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (9.08s:pixel_aot_warp7.00s,compute_store_aot_heap_view_load_warp8.97s)tests/compute_alu_bcnt64_check.pyok (0.6s),tests/compute_alu_cmp_ne_check.pyok (0.6s),tests/compute_alu_lane_gaps_check.pyok (0.6s),tests/compute_buffer_atomics_check.pyok (0.7s),tests/compute_entry_layout_check.pyok (0.2s),tests/compute_heap_store_check.pyok (0.6s),tests/compute_heap_view_check.pyok (0.6s),tests/compute_load_format_check.pyok (0.7s),tests/form_coverage_check.pyok (17.1s),tests/mesh_clip_cull_check.pyok (5.9s),tests/mesh_heap_sampler_check.pyok (1.0s),tests/pso_readiness_check.pyok (1.2s),tests/rdna2_tools_check.pyok (3.0s),tests/vk_offscreen.pyok (1.6s)sccache: 238/607 hits; wall412.3sImported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:57:56Z.
I reproduced an output-path mismatch with real Windows SDK DXC at
384f505d: after warming the cache, a compile to a missing parent directory returned 0 and created the file, while a direct DXC invocation returned 1. I pusheda6f8d0b7, which routes that request through the compiler and adds the warm-cache regression. With real DXC, the normal cold and warm outputs remained byte-identical, and the missing-parent case returned 1 without creating a directory. The fake-compiler regression runs in the Linux job.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:29:11Z.
Code review location:
tools/dxc_cache.py; line 153Fixed in
9c5dfb08(head now384f505d). A launcher script that delegates to Wine (#!script mentioningwine) now bypasses the cache, since the realdxc.exebehind it cannot be fingerprinted. Covered intests/dxc_cache_check.py. Ranpython3 -B tests/dxc_cache_check.py(ok) and Win2025 WARP dev+release on384f505d(receipt in the PR).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:29:14Z.
Code review location:
tools/dxc_cache.py; line 185Fixed in
9c5dfb08(head now384f505d). Only successful compiles are cached now, and a stored failure record is never replayed. The new test intests/dxc_cache_check.pyfails on the old code: a compile into a missing output directory is retried after the directory exists. Ranpython3 -B tests/dxc_cache_check.py(ok) and Win2025 WARP dev+release on384f505d(receipt in the PR).AI-assisted; commands listed were executed locally.