shader: lower mip-zero 2D gathers in the startup compute translator #2274
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2282"
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 RavenCurseBurg on 2026-11-25T09:47:48Z.
Refs #2274, item A,
image_gather4_lzin the startup compute translator.The compute stage now lowers a 2D mip-zero gather through the existing pixel-stage sampler and one-hot component checks. It verifies that all eight image descriptor words still identify one fixed table view before emitting the SRV and constant sampler bindings. A raw UAV records the four taps in the synthetic compute fixture. The runtime slot-67 binding work in #2274 B remains separate.
Verification
Windows 11 build 26100.9711, source
59a05959. The four 84-byte gfx1013 programs were assembled from the included source with LLVM 15.0.7. All four matched their pinned encodings. The original translator rejected the program withimage_gather4_lz requires a pixel stage and four operands.python -B tests/startup_compute_gather_lz_check.pypassed for all four components. It also checked malformed masks, a missing or out-of-profile sampler, a missing, truncated or overwritten image descriptor, and using the same slot for the texture and raw output.python -B tests/startup_compute_gather_lz_check.py --dispatch <dxc> <offscreen_check> warpand the same command withhardwarepassed on WARP 10.0.26100.9711 and a GeForce RTX 4060, driver 32.0.15.9579. Each backend passed five 320-word comparisons. The renderer was built from upstream ed96f498. This local run reporteddebug_layer=unavailable.3f1020e2. Dropping the gather produced00000000, taking red produced3f1020e0, binding mip 0 produced3f0041e2, and swapping the outer taps produced3f1010e2. Both devices produced exactly 4, 4, 4 and 2 mismatches.python -B tools/startup/gfx2hlsl.py --pending <cache>emitted the same CS HLSL and manifest as the fixture. Its compiled DXIL passed the mip-1 readback on both devices.python -B tools/run_checks_parallel.py tests/startup_compute_gather_lz_check.py tests/startup_image_gather_lz_check.py tests/startup_gfx2hlsl_compute_check.py tests/startup_compute_translate_check.py tests/startup_gfx2hlsl_loop_constants_check.py tests/startup_image_gather_c_lz_check.py tests/docs_links_check.pypassed 7/7.git diff --checkpassed.To run the registered tests, build
offscreen_checkand runctest --preset release --no-tests=error -R '^startup_compute_gather_lz(_warp|_hardware)?$' -V.The assembly, texels and readback references are source-built repository fixtures under the MIT license. AI-assisted with Codex.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T09:51:41Z.
Review: COMMENTED
Review of head
59a0595939bf0f0e4ceac077dbed856c5684ae09(comment only, no approval).Overlap check: #2258 (merged) is the
compute_store_aotimage_gather4_lpath and #2250 (merged) is the pixel-stageimage_gather4_c_lzpath. This PR only widensop_image_gather4_lzintools/startup/gfx2hlsl.pyto the compute stage. It does not touch either. No duplicate. The CS descriptor guard is a copy of the buffer-store guard (tools/startup/gfx2hlsl.pyaround line 2140), so the two stay consistent.Scope: 6 files, +164/-2. Title is neutral and the PR is MERGEABLE. At review time, the Linux and gfx1013 fixture jobs were green and "Build and test on Windows" was still pending.
Commands run locally (Linux):
python3 -B tests/startup_compute_gather_lz_check.pypassed: "Four compute gather channels, manifest bindings and refusal controls passed".python3 -B tests/startup_image_gather_lz_check.pypassed. This is the sibling pixel gather, so no regression.python3 -B tests/startup_gfx2hlsl_compute_check.pypassed.python3 tests/docs_links_check.pypassed: 18 files, 436 links.python3 tests/bidi_controls_check.pypassed.git diff --check origin/main...HEADpassed.Logic: The lowering matches the existing pixel-stage
GatherXat mip zero. The_lzand D3D Gather both read the bound view's first mip. The CS-only guard requires a fixed table descriptor, 8 consecutive words, the same symbol per word, and not modified. That is the right condition because the manifest binds the original table view. I found no P1.Mutations (each reverted with
git checkout -- .):or desc_key(word) in self.pipe.modifiedfrom the CS guard. The test still passed.first[3] % 8withFalse, which drops the alignment refusal. The test still passed.Findings
tools/startup/gfx2hlsl.py:2589): No fixture exercises thepipe.modifiedbranch. The "overwritten descriptor" control only reaches theself.symmismatch, so a regression in the modified-descriptor refusal would go unnoticed. Suggest one control where the descriptor words are modified through the path at line 1658 and the gather is then refused.tools/startup/gfx2hlsl.py:2583): No control reaches thefirst[3] % 8refusal, which is a table offset that is not a multiple of 8. Suggest one control with a misaligned table offset.image_gather4_c_lzstill says "pixel stage". That is correct today, but keep it in mind if it is widened later.Windows: I did not run
x2w_pipe.py win2025. The PR body already reports WARP and hardware dispatch results on Win2025 for these exact fixtures, and the Windows CI job is pending. The Linux checks above cover the Python-side logic.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:01:08Z.
Review: COMMENTED
Re-review of head
8d382c4cc3f02db0f4595fb338edf4ff10f265eb(comment only, no approval).Delta since
59a0595: one commit, test-only (tests/startup_compute_gather_lz_check.py, +28). No change totools/startup/gfx2hlsl.py.Previous P2s: both resolved.
tools/startup/gfx2hlsl.py:2589): the newcheck_image_provenancecontrol re-loads the table slot, then ORs into word 41 or 46, and expectsmodified image descriptor. A positive control (duplicate load, no change) still producessrv 0 tex2d table 1 0.tools/startup/gfx2hlsl.py:2585): as[12:27]load makes the gather start at word 4 and straddle two descriptors, which is refused withfixed table image descriptor. Thes[8:23]positive control lands on byte offset 32 and the manifest showssrv 0 tex2d table 1 32anduav 0 table 1 64.CI: Linux checks, gfx1013 fixtures and Windows build/test are all pass. PR is MERGEABLE and not a draft. Title is neutral.
Commands run locally (Linux):
python3 -B tests/startup_compute_gather_lz_check.pypassed.python3 -B tests/startup_image_gather_lz_check.pypassed.python3 -B tests/startup_gfx2hlsl_compute_check.pypassed.python3 -B tests/docs_links_check.pypassed (18 files, 436 links).python3 -B tests/bidi_controls_check.pypassed.git diff --check origin/main...HEADpassed.Mutations (each reverted with
git checkout -- .):or desc_key(word) in self.pipe.modifiedat line 2589: the test now fails withaccepted, expected a refusal naming 'modified image descriptor'. Killed.or first[3] % 8at line 2585: the test now fails withaccepted, expected a refusal naming 'fixed table image descriptor'. Killed.Findings
llvm-mcis not on my PATH, so the byte-for-byteassemble(...) == wordscross-check insideencoded()was skipped here. The tests run on the hex words alone. CI assembles them, and that job is green.Windows: I did not run
x2w_pipe.py win2025. This head changes only a Python test, and the shader code is unchanged since the head the PR body reports on Win2025. The Windows CI job is green.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T09:58:38Z.
Addressed both P2s in
8d382c4c. The original gather registers remain byte-for-byte intact while a separate load of the same table slot is changed throughs_or_b32. The controls cover both four-word halves of the image. Removing only thepipe.modifiedcheck now accepts a case that must refuse.The alignment control uses a 16-dword load and puts the gather's first SGPR at loaded word 4, across the boundary between the two image descriptors. With the alignment predicate removed this incorrectly translates. Its positive counterpart starts at word 8, and the manifest identifies the SRV at table byte offset 32 and the output at byte offset 64. I ran both suggested mutations independently and confirmed the new tests fail for their respective reasons. The LLVM CI path reassembles the added instructions.
The exact-head Windows CTest run for 59a05959 also completed. The normal control and WARP test passed with D3D12 debug enabled and zero errors and warnings. A GeForce RTX 4060 repeated all five positive readbacks and four negative controls locally; this machine reported the debug layer unavailable.
offform when its data is proven wave-uniform #2643