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

Merged
NiiRoZz merged 1 commit from upstream-pr/2299 into main 2026-11-25 11:01:58 +00:00
NiiRoZz commented 2026-11-25 10:46:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T10:46:05Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6602699259 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2299). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T10:46:05Z. --- ## 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)
tedin7 commented 2026-11-25 11:02:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:48:46Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6056156226 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2299#pullrequestreview-6056156226). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:48:46Z. **Review:** COMMENTED --- 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.
upstream-sync closed this pull request 2026-11-25 12:01:42 +00:00
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
R0Y00/Xbox2Windows!2291
No description provided.