shader: lower image_gather4_c_lz in the direct C++ image path #2971
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2971"
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 legacy-code-archaeologist on 2026-11-27T00:20:04Z.
Change
image_ioinsrc/gfx1013_direct_compute.inlnow lowersimage_gather4_c_lz(MIMG opcode 79) to DXILtextureGatherCmp(opcode 74). Before, the direct frontend refused it withdirect image opcode or descriptor modifiers; the same program withimage_sample_c_lzcompiled. Refs #2969 (an image op of the instruction-coverage item in #2935).gfx2hlsl.pylowers this form asop_image_gather4_c_lz.dmask0x1. The address is the reference, then u and v (and the slice), as for the comparison samples of this path.sampler_indexfield checks, plus the base-level fix ofimage_gather4_lz: DXIL gathers have no LOD operand, so the static sampler is fixed to mip zero.image_gather4_cwith implicit LOD,_c_land_c_b. D16 is already refused at decode.gfx2hlsl.pytakes this form only in pixel stages, on 2D images and with a bilinear comparison sampler. Here, compute stages, 2D arrays and the point filter of the existing comparison checks are accepted, as for the comparison samples of this path. A gather reads the same four texels whatever the filter (D3D11.3 gather rule; not measured on the console).Verification
cpp-migrationb260984fplus this commit, Windows 10.0.26100.9711,devpreset.ctest --preset dev --no-tests=error -R '^native_gather_compare_warp$|^native_direct_container$|^native_graphics_comparison_pso_warp$': 3/3 passed.native_gather_compare_warpcreates the graphics pipeline on WARP (Microsoft Basic Render Driver 10.0.26100.9711). It runs cold and from the cache, with the comparison (COMPARISON_MIN_MAG_MIP_POINT,LESS) and regular point static samplers.dxc -dumpbin. It has onetextureGatherCmpwith zero offsets and channel 0. Each float operand traces to its register: u from v1, v from v2, and the compare value from v0.image_sample_c_lzcontrol and a 2D array that compiles.ctest --preset dev -R '^native_' -j 2: no new failures. The two failures are graphics PSO creations that return0x80070057on the NVIDIA Quadro M1000M (driver 32.0.15.7371) and failed the same way without this change in #2966's run:native_graphics_vertex_vcc_join_hardwareandnative_startup_request_cache_hardware. 11 tests skip (77) without SM 6.6 wave32,native_comparison_pso_warpincluded.python -B tests/docs_links_check.py: ok.compile_dxilrefused op 79 with the message above (e3670100). That run was a probe, not a revert of this commit.Evidence and follow-up
All words are source-built. The programs reuse
comparison_program()oftests/native_direct_container_check.py: clamp X/Y, point with TRUNC_COORD, LESS.Not measured: the gather results are not read back on any device; the order of the four results is the DXIL order, the same assumption
image_gather4andimage_gather4_lzalready make here. The offset forms are not covered by the fixture.Checklist
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T00:38:03Z.
Review: APPROVED
Review of head
90424dbe, tested merged ontocpp-migration78a071ca(after #2964, #2966 and #2967). It auto-merges cleanly, and CI on the head is green. Approving and merging.Code read:
textureGatherCmp.f32(DXIL 74).image_gather4_lz(opcode 71)._c,_c_land_c_bforms stay refused by name.Run: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010) plus WARP, release.
ctest --preset release --no-tests=error -R '^native_'gives 51 tests, 50 passed and 1 skipped (77,native_comparison_pso_warp), includingnative_gather_compare_warpandnative_graphics_comparison_pso_warp. The two graphics PSO failures from your Quadro M1000M run do not occur here, as I also noted on #2966.Mutation here: passing
0.0instead of the reference register failsnative_gather_compare_warpon its argument check (['v1', 'v2', 'undef', 'undef', '0.000000e+00']). With it restored, it passes.Gap, as you say: no device reads the gathered values back. The check pins the IR form and WARP pipeline creation, and the four-texel order is the same assumption
image_gather4andimage_gather4_lzalready make on this path. A readback throughnative_store_replay, with a depth texture and a reference that splits the four texels, would turn that assumption into a measurement for all three gathers. That would be a worthwhile follow-up.AI-assisted; the commands above were run locally.