startup: write smpl for LOD-limited samplers in the compute manifest #2474

Merged
JVProg merged 1 commit from upstream-pr/2482 into main 2026-11-25 18:43:05 +00:00
JVProg commented 2026-11-25 18:02:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JVProg on 2026-11-25T18:02:56Z.


Change

ComputePipeline.manifest() skipped only the cmp prefix of a sampler key. A constant sampler that carries LOD limits has the lod prefix, so writing the compute manifest raised TypeError: %x format: an integer is required, not str. The graphics manifest already handled both prefixes.

Both manifests now use one method, Pipeline.sampler_lines(), which holds the former graphics logic. A LOD-limited compute sampler is written as an smpl line.

Loader side: the stand-in does not load compute translations yet (docs/startup-runtime.md, compute pipeline requests). This change lets the translator publish the manifest. It does not make the compute pipeline run in the startup runtime. The existing translated_sampler_bindings.h already parses smpl, so no C++ change is made.

Refs #2463 (first item only).

Verification

Commit 38517b69 on base 1a0e506d, Windows 11 build 26300. The checks ran on the same changes before they were committed.

  • .\out\pe-env\Scripts\python.exe -B tests/startup_image_sample_lod_check.py: passes. With tools/startup/gfx2hlsl.py from the base, it fails with the TypeError above.
  • New cases: image_sample_lz and image_sample_l write smpl. Controls: with mip filter 0 the same programs write smp; a comparison sample writes smpc.
  • ctest --preset release --no-tests=error -R "^(startup_translated_sampler_bindings|startup_sampler_comparison|startup_sampler_lod|startup_image_sample_lod|startup_gfx2hlsl_compute|startup_compute_gather_l_|startup_compute_translate)" (WARP and AMD Radeon RX 9070 XT, driver 32.0.32029.2010): 44 tests passed. In the first run the four startup_compute_translate_e2e* tests failed because startup_stream_consumer was a stale binary from an older commit; they passed after rebuilding that target.
  • All tests/startup_*check.py, compute_*check.py and mesh_*check.py scripts run directly without arguments (controls for compute_desc_numeric_check.py): 131 exit 0, 2 skip, 77 exit 1. The same 77 exit 1 on the unmodified base, with the same last output line. The ones inspected need arguments such as executables or DXC (two report WinError 87), so they verify nothing here. After this run only a docstring in the new check changed, and that check was rerun.
  • DXC 10.0.26100.0, cs_6_0: the translated lz and l compute shaders compile.

Temporary local harness, not part of this PR: it built the static sampler from the translated compute manifest with the production decoder and dispatched three translated shaders on a 4x4 three-mip texture, on WARP and on the RX 9070 XT. All 12 dispatches read the expected mip:

case with smpl control, same line as smp
image_sample_l, LOD 2, MAX_LOD 1 mip 1 mip 2
image_sample_lz, MIN_LOD 1 mip 1 mip 0
image_sample_lz, MIN_LOD 2 mip 2 mip 0

The D3D12 debug layer was not available in this harness.

Evidence and follow-up

The new programs are source-built from existing helpers in tests/startup_compute_gather_l_check.py (compute_prefix, and gather_insn with a 2D sample opcode). They were not reassembled with llvm-mc: the check's binary mode does not cover them. Each case asserts the sample call the translator decodes.

Follow-up outside this change: loading compute translations in the stand-in.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6610607253 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2482). Originally posted by [JVProg](https://github.com/JVProg) on 2026-11-25T18:02:56Z. --- ## Change `ComputePipeline.manifest()` skipped only the `cmp` prefix of a sampler key. A constant sampler that carries LOD limits has the `lod` prefix, so writing the compute manifest raised `TypeError: %x format: an integer is required, not str`. The graphics manifest already handled both prefixes. Both manifests now use one method, `Pipeline.sampler_lines()`, which holds the former graphics logic. A LOD-limited compute sampler is written as an `smpl` line. Loader side: **the stand-in does not load compute translations yet** (`docs/startup-runtime.md`, compute pipeline requests). This change lets the translator publish the manifest. It does not make the compute pipeline run in the startup runtime. The existing `translated_sampler_bindings.h` already parses `smpl`, so no C++ change is made. Refs #2463 (first item only). ## Verification Commit `38517b69` on base `1a0e506d`, Windows 11 build 26300. The checks ran on the same changes before they were committed. - `.\out\pe-env\Scripts\python.exe -B tests/startup_image_sample_lod_check.py`: passes. With `tools/startup/gfx2hlsl.py` from the base, it fails with the `TypeError` above. - New cases: `image_sample_lz` and `image_sample_l` write `smpl`. Controls: with mip filter 0 the same programs write `smp`; a comparison sample writes `smpc`. - `ctest --preset release --no-tests=error -R "^(startup_translated_sampler_bindings|startup_sampler_comparison|startup_sampler_lod|startup_image_sample_lod|startup_gfx2hlsl_compute|startup_compute_gather_l_|startup_compute_translate)"` (WARP and AMD Radeon RX 9070 XT, driver 32.0.32029.2010): 44 tests passed. In the first run the four `startup_compute_translate_e2e*` tests failed because `startup_stream_consumer` was a stale binary from an older commit; they passed after rebuilding that target. - All `tests/startup_*check.py`, `compute_*check.py` and `mesh_*check.py` scripts run directly without arguments (`controls` for `compute_desc_numeric_check.py`): 131 exit 0, 2 skip, 77 exit 1. The same 77 exit 1 on the unmodified base, with the same last output line. The ones inspected need arguments such as executables or DXC (two report `WinError 87`), so they verify nothing here. After this run only a docstring in the new check changed, and that check was rerun. - DXC `10.0.26100.0`, `cs_6_0`: the translated `lz` and `l` compute shaders compile. Temporary local harness, **not part of this PR**: it built the static sampler from the translated compute manifest with the production decoder and dispatched three translated shaders on a 4x4 three-mip texture, on WARP and on the RX 9070 XT. All 12 dispatches read the expected mip: | case | with `smpl` | control, same line as `smp` | |---|---|---| | `image_sample_l`, LOD 2, MAX_LOD 1 | mip 1 | mip 2 | | `image_sample_lz`, MIN_LOD 1 | mip 1 | mip 0 | | `image_sample_lz`, MIN_LOD 2 | mip 2 | mip 0 | The D3D12 debug layer was not available in this harness. ## Evidence and follow-up The new programs are source-built from existing helpers in `tests/startup_compute_gather_l_check.py` (`compute_prefix`, and `gather_insn` with a 2D sample opcode). They were not reassembled with `llvm-mc`: the check's `binary` mode does not cover them. Each case asserts the sample call the translator decodes. Follow-up outside this change: loading compute translations in the stand-in. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 19:03:59 +00:00
tedin7 commented 2026-11-25 19:04:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:40:26Z.

Review: COMMENTED


Review of head 38517b69 (comment only).

What I checked:

  • Diff is small and additive: Pipeline.sampler_lines() takes the graphics logic, and ComputePipeline.manifest() now calls it. Behavior of the graphics manifest is unchanged (same code moved). The compute manifest now handles the lod prefix, which fixes the %x TypeError. No sibling callsite is left out: both manifests use the one method.
  • Scope: Python tool plus one existing check. No .github, launcher, hooks or C++. The body states the stand-in does not load compute translations yet, so this does not claim startup progress.
  • Test: check_compute_manifest() is added to the existing startup_image_sample_lod_check.py controls. It covers lz and l with limits (smpl), a mip-filter-0 control (smp) and a comparison control (smpc), and asserts the exact manifest line.
  • No duplicate: #2265 and #2287 (merged) carry LOD limits on the graphics side only. No open PR covers the compute manifest.
  • Windows results in the body (ctest, DXC) are posted by the author for head 38517b69. I did not re-run them. No game result is claimed or needed.

Commands run locally (Linux, worktree of this head):

  • python3 tests/startup_image_sample_lod_check.py: exit 0, new "compute manifest" line printed.
  • Same check with gfx2hlsl.py from origin/main: fails with TypeError: %x format: an integer is required, not str (the intended failure).
  • Mutation: removed 'lod': 'smpl' from sampler_lines(): the check fails on the smpl assertion. Restored afterwards.
  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py and python3 tests/bidi_controls_check.py: pass.
  • PR CI on this head: 3 success, 2 skipped, none failed.

No issues found. I did not run Win2025, did not update the branch, and did not merge.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063049489 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2482#pullrequestreview-6063049489). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:40:26Z. **Review:** COMMENTED --- Review of head 38517b69 (comment only). What I checked: - Diff is small and additive: `Pipeline.sampler_lines()` takes the graphics logic, and `ComputePipeline.manifest()` now calls it. Behavior of the graphics manifest is unchanged (same code moved). The compute manifest now handles the `lod` prefix, which fixes the `%x` TypeError. No sibling callsite is left out: both manifests use the one method. - Scope: Python tool plus one existing check. No .github, launcher, hooks or C++. The body states the stand-in does not load compute translations yet, so this does not claim startup progress. - Test: `check_compute_manifest()` is added to the existing `startup_image_sample_lod_check.py` controls. It covers lz and l with limits (`smpl`), a mip-filter-0 control (`smp`) and a comparison control (`smpc`), and asserts the exact manifest line. - No duplicate: #2265 and #2287 (merged) carry LOD limits on the graphics side only. No open PR covers the compute manifest. - Windows results in the body (ctest, DXC) are posted by the author for head 38517b69. I did not re-run them. No game result is claimed or needed. Commands run locally (Linux, worktree of this head): - `python3 tests/startup_image_sample_lod_check.py`: exit 0, new "compute manifest" line printed. - Same check with `gfx2hlsl.py` from origin/main: fails with `TypeError: %x format: an integer is required, not str` (the intended failure). - Mutation: removed `'lod': 'smpl'` from `sampler_lines()`: the check fails on the `smpl` assertion. Restored afterwards. - `git diff --check origin/main...HEAD`: clean. - `python3 tests/docs_links_check.py` and `python3 tests/bidi_controls_check.py`: pass. - PR CI on this head: 3 success, 2 skipped, none failed. No issues found. I did not run Win2025, did not update the branch, and did not merge. AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-25 19:04:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:15:02Z.


Five mutations, all caught — including the regression the fix exists for, and one that could have been a silent graphics change

Baseline on this branch: startup_image_sample_lod_check.py exit 0 with the new line compute manifest: smpl with LOD limits (lz, l); controls: smp with mip filter 0, smpc for comparison.

mutation of the shared sampler_lines() result
lod no longer maps to smpl (the original TypeError shape) caught
cmp no longer maps to smpc caught
key[prefixed:] → key[:] (prefix words leak into the line) caught
prefixed = False (no prefix considered) caught
the graphics manifest stops calling sampler_lines() (lines += … → pass) caught

The last row is the one I care about. Sharing the formatter between the graphics and compute manifests is the right shape, but it also means the graphics path changed implementation without changing behaviour — and a shared helper that the graphics path silently stops calling would leave startup_image_sample_lod_check.py passing only if some other check covers the graphics manifest. It is caught here, so this fixture carries both sides.

What the added cases actually pin

The new block is worth reading for what it asserts, not just that it passes:

assert lines == ['%s 0 0x12 0xfff000 0x%x 0x0' % (tag, w2)], (form, variant, lines)

for (form, opcode) in (('lz', 0x27), ('l', 0x24)) × (variant, w2, tag) in (('limits', 0x4500000, 'smpl'), ('mip filter none', 0x500000, 'smp')). That is both LOD forms against both sampler variants, with the whole line compared as a string rather than searched — so a word order change or a missing 0x fails. And the comparison form (smpc) is pinned separately. ('mip filter none', …, 'smp') is the control that makes the smpl case meaningful: same program, sampler without LOD limits, ordinary smp line.

Two notes

  1. The 0x%x formatting is now in one place for both paths, which is what makes the original bug class go away — the compute manifest skipped only cmp, the graphics one handled both. That asymmetry is exactly what produced TypeError on 17 of 2,689 requests. Keeping the map literal ({'cmp': 'smpc', 'lod': 'smpl'}) and the prefix set (('cmp', 'lod')) in one function means the next prefix addition cannot half-land; that is worth a sentence in the commit message or the docstring, since it is the durability argument for the refactor.

  2. The graphics-side smpc/smp assertions in this file predate the change; if they were only ever exercised through the old inline loop, it is worth confirming they still read the shared helper rather than a leftover. The mutation above says they do, but a reader cannot tell from the diff.

AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7170649753 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2482#issuecomment-7170649753). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T18:15:02Z. --- ## Five mutations, all caught — including the regression the fix exists for, and one that could have been a silent graphics change Baseline on this branch: `startup_image_sample_lod_check.py` exit 0 with the new line `compute manifest: smpl with LOD limits (lz, l); controls: smp with mip filter 0, smpc for comparison`. | mutation of the shared `sampler_lines()` | result | |---|---| | `lod` no longer maps to `smpl` (the original `TypeError` shape) | **caught** | | `cmp` no longer maps to `smpc` | **caught** | | `key[prefixed:]` → `key[:]` (prefix words leak into the line) | **caught** | | `prefixed = False` (no prefix considered) | **caught** | | the graphics manifest stops calling `sampler_lines()` (`lines += …` → `pass`) | **caught** | The last row is the one I care about. Sharing the formatter between the graphics and compute manifests is the right shape, but it also means the graphics path changed implementation without changing behaviour — and a shared helper that the graphics path silently stops calling would leave `startup_image_sample_lod_check.py` passing only if some other check covers the graphics manifest. It is caught here, so this fixture carries both sides. ## What the added cases actually pin The new block is worth reading for what it asserts, not just that it passes: ```python assert lines == ['%s 0 0x12 0xfff000 0x%x 0x0' % (tag, w2)], (form, variant, lines) ``` for `(form, opcode)` in `(('lz', 0x27), ('l', 0x24))` × `(variant, w2, tag)` in `(('limits', 0x4500000, 'smpl'), ('mip filter none', 0x500000, 'smp'))`. That is both LOD forms against both sampler variants, with the whole line compared as a string rather than searched — so a word order change or a missing `0x` fails. And the comparison form (`smpc`) is pinned separately. `('mip filter none', …, 'smp')` is the control that makes the `smpl` case meaningful: same program, sampler without LOD limits, ordinary `smp` line. ## Two notes 1. **The `0x%x` formatting is now in one place for both paths, which is what makes the original bug class go away** — the compute manifest skipped only `cmp`, the graphics one handled both. That asymmetry is exactly what produced `TypeError` on 17 of 2,689 requests. Keeping the map literal (`{'cmp': 'smpc', 'lod': 'smpl'}`) and the prefix set (`('cmp', 'lod')`) in one function means the next prefix addition cannot half-land; that is worth a sentence in the commit message or the docstring, since it is the durability argument for the refactor. 2. **The graphics-side `smpc`/`smp` assertions in this file predate the change**; if they were only ever exercised through the old inline loop, it is worth confirming they still read the shared helper rather than a leftover. The mutation above says they do, but a reader cannot tell from the diff. AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.
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!2474
No description provided.