startup: write smpl for LOD-limited samplers in the compute manifest #2474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2482"
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 JVProg on 2026-11-25T18:02:56Z.
Change
ComputePipeline.manifest()skipped only thecmpprefix of a sampler key. A constant sampler that carries LOD limits has thelodprefix, so writing the compute manifest raisedTypeError: %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 ansmplline.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 existingtranslated_sampler_bindings.halready parsessmpl, so no C++ change is made.Refs #2463 (first item only).
Verification
Commit
38517b69on base1a0e506d, 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. Withtools/startup/gfx2hlsl.pyfrom the base, it fails with theTypeErrorabove.image_sample_lzandimage_sample_lwritesmpl. Controls: with mip filter 0 the same programs writesmp; a comparison sample writessmpc.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 fourstartup_compute_translate_e2e*tests failed becausestartup_stream_consumerwas a stale binary from an older commit; they passed after rebuilding that target.tests/startup_*check.py,compute_*check.pyandmesh_*check.pyscripts run directly without arguments (controlsforcompute_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 reportWinError 87), so they verify nothing here. After this run only a docstring in the new check changed, and that check was rerun.10.0.26100.0,cs_6_0: the translatedlzandlcompute 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:
smplsmpimage_sample_l, LOD 2, MAX_LOD 1image_sample_lz, MIN_LOD 1image_sample_lz, MIN_LOD 2The 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, andgather_insnwith a 2D sample opcode). They were not reassembled withllvm-mc: the check'sbinarymode 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
AI-assisted (Claude Code).
🤖 Generated with Claude Code
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:
Pipeline.sampler_lines()takes the graphics logic, andComputePipeline.manifest()now calls it. Behavior of the graphics manifest is unchanged (same code moved). The compute manifest now handles thelodprefix, which fixes the%xTypeError. No sibling callsite is left out: both manifests use the one method.check_compute_manifest()is added to the existingstartup_image_sample_lod_check.pycontrols. 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.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.gfx2hlsl.pyfrom origin/main: fails withTypeError: %x format: an integer is required, not str(the intended failure).'lod': 'smpl'fromsampler_lines(): the check fails on thesmplassertion. Restored afterwards.git diff --check origin/main...HEAD: clean.python3 tests/docs_links_check.pyandpython3 tests/bidi_controls_check.py: pass.No issues found. I did not run Win2025, did not update the branch, and did not merge.
AI-assisted; commands listed were executed locally.
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.pyexit 0 with the new linecompute manifest: smpl with LOD limits (lz, l); controls: smp with mip filter 0, smpc for comparison.sampler_lines()lodno longer maps tosmpl(the originalTypeErrorshape)cmpno longer maps tosmpckey[prefixed:]→key[:](prefix words leak into the line)prefixed = False(no prefix considered)sampler_lines()(lines += …→pass)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.pypassing 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:
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 missing0xfails. And the comparison form (smpc) is pinned separately.('mip filter none', …, 'smp')is the control that makes thesmplcase meaningful: same program, sampler without LOD limits, ordinarysmpline.Two notes
The
0x%xformatting is now in one place for both paths, which is what makes the original bug class go away — the compute manifest skipped onlycmp, the graphics one handled both. That asymmetry is exactly what producedTypeErroron 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.The graphics-side
smpc/smpassertions 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.