startup: move the shader cache revision to x2w-startup-shader-9 #2299

Manually merged
github merged 1 commit from gh-pr/2299/head into gh-pr/2299/base 2026-11-27 00:13:48 +00:00
Owner

@⁠NiiRoZz on GitHub · 2026-11-25 10:46 UTC · original
NiiRoZz:startup/shader-cache-revision-9 → main · +8 −8 · 5 files · 1 commits · merged 2026-11-25 11:01 UTC

Change

#2279 changed the HLSL gfx2hlsl emits for programs with loops and joins, but the cache key did not change. A cache
filled before it keeps shaders whose loop counter is a folded constant (s14 = 0x00000000u + 0x00000001u;), so the
dispatcher loop runs to its 65,536-iteration guard for every pixel. Local observation (one run, counts only): one such
cached pixel shader cost about 128 ms of GPU time per frame at 1280x720. After retranslating the same request with
current main, the counter reads s14 = s14 + 0x00000001u;.

This moves the revision so those caches are not reused:

  • graphics x2w-startup-shader-8 -> x2w-startup-shader-9 (src/startup_stubs/d3d12_draw.inl,
    tools/startup/gfx2hlsl.py, tests/startup_indirect_draw_indexed.cpp, docs/startup-runtime.md);
  • compute x2w-startup-shader-8cs -> x2w-startup-shader-9cs (d3d12_draw.inl, gfx2hlsl.py,
    tests/startup_compute_request_offline_check.py, whose pinned literal key changes to c034b1a1c9e1d289).

Nothing else changes. Other merged translator PRs since revision 8 may also change output for programs that already
translated; only #2279 was checked.

Verification

On origin/main 25317c63 plus this change, Windows 11 build 26300:

Command Result
tests/startup_compute_request_offline_check.py pass (fails with the old literal key, pass after the update)
tests/startup_gfx2hlsl_export_mask_check.py 0 failed
tests/startup_image_sample_a16_check.py pass (checks the runtime and offline revisions match)
tests/startup_image_load_mip_check.py pass
tests/startup_translator_check.py 0 failed
tests/docs_links_check.py pass

Evidence and follow-up

  • Local cache of 57 pixel shaders: 8 contained the guard loop with a folded counter; retranslated by main, all 8
    now read the counter at run time.
  • Second local run with the retranslated cache (same build, one run each, GPU timestamp queries around each
    submitted list): measured GPU time per 5 s window in the same phase fell from 880-2850 ms to 16-137 ms, and the
    128 ms draw no longer appears among the slowest commands. The presentation rate in that phase did not recover
    (2-19 presents per window in both runs), so it has other, non-GPU causes that this change does not address.
  • Not run: the C++ fixture startup_indirect_draw_indexed carries its own copy of the revision string; it needs a
    build (ctest --preset dev -R startup_indirect_draw_indexed). No GPU run.
  • This does not establish title startup or frame rate.

Checklist

  • One behavior: the cache revision only.
  • No game files, dumps or links.
  • Docs updated (docs/startup-runtime.md).
  • startup_indirect_draw_indexed built and run.

AI-assisted (Claude Code); the commands above were run locally.

🤖 Generated with Claude Code

**@⁠NiiRoZz** on GitHub · 2026-11-25 10:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2299) `NiiRoZz:startup/shader-cache-revision-9` → `main` · +8 −8 · 5 files · 1 commits · merged 2026-11-25 11:01 UTC ## Change #2279 changed the HLSL gfx2hlsl emits for programs with loops and joins, but the cache key did not change. A cache filled before it keeps shaders whose loop counter is a folded constant (`s14 = 0x00000000u + 0x00000001u;`), so the dispatcher loop runs to its 65,536-iteration guard for every pixel. Local observation (one run, counts only): one such cached pixel shader cost about 128 ms of GPU time per frame at 1280x720. After retranslating the same request with current main, the counter reads `s14 = s14 + 0x00000001u;`. This moves the revision so those caches are not reused: - graphics `x2w-startup-shader-8` -> `x2w-startup-shader-9` (`src/startup_stubs/d3d12_draw.inl`, `tools/startup/gfx2hlsl.py`, `tests/startup_indirect_draw_indexed.cpp`, `docs/startup-runtime.md`); - compute `x2w-startup-shader-8cs` -> `x2w-startup-shader-9cs` (`d3d12_draw.inl`, `gfx2hlsl.py`, `tests/startup_compute_request_offline_check.py`, whose pinned literal key changes to `c034b1a1c9e1d289`). Nothing else changes. Other merged translator PRs since revision 8 may also change output for programs that already translated; only #2279 was checked. ## Verification On origin/main `25317c63` plus this change, Windows 11 build 26300: | Command | Result | |---|---| | `tests/startup_compute_request_offline_check.py` | pass (fails with the old literal key, pass after the update) | | `tests/startup_gfx2hlsl_export_mask_check.py` | 0 failed | | `tests/startup_image_sample_a16_check.py` | pass (checks the runtime and offline revisions match) | | `tests/startup_image_load_mip_check.py` | pass | | `tests/startup_translator_check.py` | 0 failed | | `tests/docs_links_check.py` | pass | ## Evidence and follow-up - Local cache of 57 pixel shaders: 8 contained the guard loop with a folded counter; retranslated by main, all 8 now read the counter at run time. - Second local run with the retranslated cache (same build, one run each, GPU timestamp queries around each submitted list): measured GPU time per 5 s window in the same phase fell from 880-2850 ms to 16-137 ms, and the 128 ms draw no longer appears among the slowest commands. The presentation rate in that phase did not recover (2-19 presents per window in both runs), so it has other, non-GPU causes that this change does not address. - Not run: the C++ fixture `startup_indirect_draw_indexed` carries its own copy of the revision string; it needs a build (`ctest --preset dev -R startup_indirect_draw_indexed`). No GPU run. - This does not establish title startup or frame rate. ## Checklist - [x] One behavior: the cache revision only. - [x] No game files, dumps or links. - [x] Docs updated (`docs/startup-runtime.md`). - [ ] `startup_indirect_draw_indexed` built and run. AI-assisted (Claude Code); the commands above were run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
#2279 changed the HLSL emitted for programs with loops and joins without
changing the key, so caches filled before it keep folded loop counters.
The compute test's pinned key moves with the revision.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:13:47 +00:00
github manually merged commit 3b8883e4bc into gh-pr/2299/base 2026-11-27 00:13:48 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 10:48 UTC · original · reviewed

Review of head 3b8883e4bc41cf05880f6c270774cdb26d745e54.

Result: no P1, no P2.

What I checked

  • The diff is 8 lines in 5 files. Graphics x2w-startup-shader-8 -> -9 and compute -8cs -> -9cs change together in src/startup_stubs/d3d12_draw.inl:235,355, tools/startup/gfx2hlsl.py:4038,4047, tests/startup_indirect_draw_indexed.cpp:235, tests/startup_compute_request_offline_check.py:33 and docs/startup-runtime.md.
  • A repo-wide search finds no leftover shader-8 or 8cs outside the diff.
  • The pinned compute key 0xc034b1a1c9e1d289 matches the key the checker computes for the new revision.
  • Title is neutral, mergeable is clean. On the head SHA, the Linux CI job passes and the Windows jobs were still pending when I looked.

Commands run locally on the PR head

  • python3 tests/startup_compute_request_offline_check.py -> pass
  • python3 tests/docs_links_check.py -> pass (18 files, 436 links)
  • python3 tests/bidi_controls_check.py -> pass
  • git diff --check origin/main...HEAD -> clean
  • Mutation: I put gfx2hlsl.py compute revision back to -8cs. The checker failed with 29c6e5148934abc8 != c034b1a1c9e1d289, so the pinned key catches a drift between the translator and the pin. I then reverted it with git checkout -- ..

Nit (non-blocking)

  • The graphics revision has no pinned literal key. If gfx2hlsl.py and d3d12_draw.inl drifted on the graphics string only, no Linux check would catch it. The compute side already has this guard, so a graphics twin could be a follow-up.

Windows runtime was not run: the change only edits cache revision strings, so no WARP run seems needed.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 10:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2299#pullrequestreview-6056156226) · **reviewed** Review of head `3b8883e4bc41cf05880f6c270774cdb26d745e54`. Result: no P1, no P2. What I checked - The diff is 8 lines in 5 files. Graphics `x2w-startup-shader-8` -> `-9` and compute `-8cs` -> `-9cs` change together in `src/startup_stubs/d3d12_draw.inl:235,355`, `tools/startup/gfx2hlsl.py:4038,4047`, `tests/startup_indirect_draw_indexed.cpp:235`, `tests/startup_compute_request_offline_check.py:33` and `docs/startup-runtime.md`. - A repo-wide search finds no leftover `shader-8` or `8cs` outside the diff. - The pinned compute key `0xc034b1a1c9e1d289` matches the key the checker computes for the new revision. - Title is neutral, mergeable is clean. On the head SHA, the Linux CI job passes and the Windows jobs were still pending when I looked. Commands run locally on the PR head - `python3 tests/startup_compute_request_offline_check.py` -> pass - `python3 tests/docs_links_check.py` -> pass (18 files, 436 links) - `python3 tests/bidi_controls_check.py` -> pass - `git diff --check origin/main...HEAD` -> clean - Mutation: I put `gfx2hlsl.py` compute revision back to `-8cs`. The checker failed with `29c6e5148934abc8 != c034b1a1c9e1d289`, so the pinned key catches a drift between the translator and the pin. I then reverted it with `git checkout -- .`. Nit (non-blocking) - The graphics revision has no pinned literal key. If `gfx2hlsl.py` and `d3d12_draw.inl` drifted on the graphics string only, no Linux check would catch it. The compute side already has this guard, so a graphics twin could be a follow-up. Windows runtime was not run: the change only edits cache revision strings, so no WARP run seems needed. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.