Shaders: count reused compute shaders as cache hits #1223

Open
alpz1000 wants to merge 1 commit from upstream-pr/1232 into main
alpz1000 commented 2026-11-24 13:26:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by alpz1000 on 2026-11-24T13:26:28Z.


xcl shaders --precompile counted every successful compute shader lookup as a fresh compile, including when it reused cached DXIL. This change reports fresh compiles and cache hits separately.

What is in it

  • Carry cache status through the compute shader translation path.
  • Count each result correctly in the precompile summary. Pipeline creation still runs when requested.

Tested

  • Windows 11 Home 26200.9974, Intel Core i5-8400, RTX 3060 12 GB, driver 610.88, Rust 1.100.0 MSVC, DXC 1.9.2602.17. Release for the CLI check and debug for the workspace suite.
  • Cold cache: 43 compiled, 0 cached, 0 errors.
  • Warm cache: 0 compiled, 43 cached, 0 errors, also with the translation cache disabled.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=4: 741 passed, 0 failed, 41 ignored. Two tests counted as passed reported no wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.

Regression run

Paired 60-second startup runs on the same title with fresh XCL data and caches per build.

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 3060
title: Retail title
seconds: 60
exit: 0x0
frames shown: 277 (PresentX 278)
presents per 2 s (last 3): 15 16 15
device removals: 0
crashes: 0
peak commit: 15443 MB
xcl-smoke v1
commit: 9af37dc2466a1cbe82b4f232852340cccc6efc4f
gpu: NVIDIA GeForce RTX 3060
title: Retail title
seconds: 60
exit: 0x0
frames shown: 255 (PresentX 255)
presents per 2 s (last 3): 15 16 15
device removals: 0
crashes: 0
peak commit: 15381 MB

Not tested

Gameplay beyond the 60-second startup run, other adapters, and the full shader corpus.

AI use

OpenAI Codex (GPT-6) implemented the change, ran the local checks, and drafted the description.

<!-- greyfinch-sync:ivall/xcl:issue:5473024599 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1232). Originally posted by [alpz1000](https://github.com/alpz1000) on 2026-11-24T13:26:28Z. --- xcl shaders --precompile counted every successful compute shader lookup as a fresh compile, including when it reused cached DXIL. This change reports fresh compiles and cache hits separately. **What is in it** - Carry cache status through the compute shader translation path. - Count each result correctly in the precompile summary. Pipeline creation still runs when requested. **Tested** - Windows 11 Home 26200.9974, Intel Core i5-8400, RTX 3060 12 GB, driver 610.88, Rust 1.100.0 MSVC, DXC 1.9.2602.17. Release for the CLI check and debug for the workspace suite. - Cold cache: 43 compiled, 0 cached, 0 errors. - Warm cache: 0 compiled, 43 cached, 0 errors, also with the translation cache disabled. - cargo test --locked --workspace --no-fail-fast -- --test-threads=4: 741 passed, 0 failed, 41 ignored. Two tests counted as passed reported no wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. **Regression run** Paired 60-second startup runs on the same title with fresh XCL data and caches per build. ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 3060 title: Retail title seconds: 60 exit: 0x0 frames shown: 277 (PresentX 278) presents per 2 s (last 3): 15 16 15 device removals: 0 crashes: 0 peak commit: 15443 MB ``` ``` xcl-smoke v1 commit: 9af37dc2466a1cbe82b4f232852340cccc6efc4f gpu: NVIDIA GeForce RTX 3060 title: Retail title seconds: 60 exit: 0x0 frames shown: 255 (PresentX 255) presents per 2 s (last 3): 15 16 15 device removals: 0 crashes: 0 peak commit: 15381 MB ``` **Not tested** Gameplay beyond the 60-second startup run, other adapters, and the full shader corpus. **AI use** OpenAI Codex (GPT-6) implemented the change, ran the local checks, and drafted the description.
DavidM1911 commented 2026-11-24 14:06:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:47:27Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib shaders: 13 passed, 0 failed.

Note: the full d3d12x lib filter currently aborts with 0xc0000005 on unmodified main too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.

<!-- greyfinch-sync:ivall/xcl:comment:7133341107 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1232#issuecomment-7133341107). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T13:47:27Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib shaders: 13 passed, 0 failed. Note: the full `d3d12x` lib filter currently aborts with 0xc0000005 on unmodified `main` too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.
ettehn commented 2026-11-25 10:10:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-25T10:04:01Z.


This accounting also matters for #2120. On its exact head, a second process reused the rerouted DXIL but still printed compiled 1, already cached 0 (check). I tested a local adaptation of #1232 on 8dcc56d: carry a per-lookup DXIL reuse flag separately from the reroute flag, so it does not depend on process-wide counter deltas.

Native Windows CLI, no --pipelines, tested three cases: (1) a rerouted large record, cold and then a separate warm process, reported 1/0 then 0/1 (compiled/cached). (2) a smaller record with the translation cache disabled still reported 1/0 then 0/1 by reusing the DXC cache. (3) two identical inputs with workers enabled and a fresh cache emitted one reroute and reported 1/1. All runs exited 0 with zero reported errors under a 2 GiB job commit cap. No title or hardware GPU exercised. I have the local integration patch if useful when the conflict is resolved.

AI use — OpenAI Codex (GPT-6) adapted the code and ran the checks.

<!-- greyfinch-sync:ivall/xcl:comment:7159175973 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1232#issuecomment-7159175973). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-25T10:04:01Z. --- This accounting also matters for #2120. On its exact head, a second process reused the rerouted DXIL but still printed `compiled 1, already cached 0` ([check](https://github.com/xcl-dev/xcl/pull/2120#issuecomment-7159115445)). I tested a local adaptation of #1232 on `8dcc56d`: carry a per-lookup DXIL reuse flag separately from the reroute flag, so it does not depend on process-wide counter deltas. Native Windows CLI, no `--pipelines`, tested three cases: (1) a rerouted large record, cold and then a separate warm process, reported 1/0 then 0/1 (compiled/cached). (2) a smaller record with the translation cache disabled still reported 1/0 then 0/1 by reusing the DXC cache. (3) two identical inputs with workers enabled and a fresh cache emitted one reroute and reported 1/1. All runs exited 0 with zero reported errors under a 2 GiB job commit cap. No title or hardware GPU exercised. I have the local integration patch if useful when the conflict is resolved. AI use — OpenAI Codex (GPT-6) adapted the code and ran the checks.
DavidM1911 commented 2026-11-26 05:05:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:17:29Z.


Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7182465074 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1232#issuecomment-7182465074). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:17:29Z. --- Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
Foniass commented 2026-12-01 05:11:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:11:07Z.


Triage (#1607) – head 9af37dc

Not on main: precompile in shaders.rs still adds every compute program that console_to_dxil_in returns to compiled, even when it came from the memory, translation or DXC cache. #2613 and #2928 (both opened later) make the same compute-branch change via a console_to_dxil_in_status, but inside much larger precompile reworks. This PR only makes this change.
The flag logic is right: a memory or disk-translation hit never calls compile_one, so cached stays true, and a DXC hit is passed through from compile_cached. The PR conflicts with main, where compile_console_shader already returns (Compiled, bool) and console_to_dxil_in now goes through console_to_dxil_in_with, so it needs a rebase.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301506234 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1232#issuecomment-7301506234). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:11:07Z. --- **Triage (#1607)** – head 9af37dc Not on main: `precompile` in shaders.rs still adds every compute program that `console_to_dxil_in` returns to `compiled`, even when it came from the memory, translation or DXC cache. #2613 and #2928 (both opened later) make the same compute-branch change via a `console_to_dxil_in_status`, but inside much larger precompile reworks. This PR only makes this change. The flag logic is right: a memory or disk-translation hit never calls `compile_one`, so `cached` stays true, and a DXC hit is passed through from `compile_cached`. The PR conflicts with main, where `compile_console_shader` already returns `(Compiled, bool)` and `console_to_dxil_in` now goes through `console_to_dxil_in_with`, so it needs a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1232:upstream-pr/1232'
git switch 'upstream-pr/1232'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1232'
git switch 'upstream-pr/1232'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1232'
git switch 'upstream-pr/1232'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1232'
git switch 'main'
git merge --squash 'upstream-pr/1232'
git switch 'main'
git merge --ff-only 'upstream-pr/1232'
git switch 'main'
git merge 'upstream-pr/1232'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1223
No description provided.