shader: lower direct D16 image loads (Part of #3703) #3836
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3836"
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 timbot103 on 2026-12-02T08:12:03Z.
Lowers direct
D16image_load(andimage_load_mip) across mesh Texture1D heap loads and direct compute/pixel/verteximage_io, clearing"unsupported image dimension or D16"(609 mesh programs in #3703).Part of #3703. Refs #3641.
(Opened as Draft per #3514 until an active review slot frees.)
Summary
src/gfx1013_compute_native.cpp&src/gfx1013_compute_native.h:D16on directimage_load(op == 0) andimage_load_mip(op == 1) alongsidesample_d16for non-cube, non-MSAA dimensions (dim != 3 && dim < 6).image_result_registers(const Inst&)accounting forpopcount(dmask)andD16halfword packing, reused in vector-spill clearing (gfx1013_compute_native.cpp), loop/helper touch tracking (gfx1013_direct_graphics.inl), and mesh narrowed-EXEC VGPR preservation (gfx1013_direct_mesh.inl).ComputeViewKind::d16_load_srv(serialized/named insrc/direct_compute_cache.cpp) andNativeComputeShader::mesh_texture_heap_d16(reported intools/startup/compile_dxil.cppand gated ond16_srv_mode(Format) == float_exactinsrc/startup_stubs/native_mesh86.inl).src/gfx1013_direct_compute.inl&src/gfx1013_direct_mesh.inl:write_d16_image_resultpackingDMASK-selected channels consecutively into 16-bit halves (low half first) via existing round-to-nearest-evenpacked_half_rne.D16Texture1D heap loads for arbitrary non-zeroDMASKwith destination-overflow checks andbefore_vec/partial_writestracking under narrowed EXEC.D16loads compile to DXIL withComputeViewKind::d16_load_srv(manifest publication fails closed until format-aware runtime binding lands; existingd16_sample_srvbehavior unchanged).tests/native_mesh_image_d16_check.py+tests/cmake/native_mesh_image_d16.cmake+tests/startup_compute_d16_sample_srv_check.py+docs/experiments/native-image-load-d16.md+README.md:native_mesh_image_d16_ir(runs inprCTest preset): covers sparseDMASKpacking, destination bounds, inactive-lane preservation under narrowed EXEC, neighbor-VGPR preservation, direct compute/pixel/verteximage_load&image_load_mip, and fail-closed refusals.Verification
Host: Windows 11 (
10.0.26200.9974), MSVC C++20/W4(zero warnings on edited lines), inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140; D3D12 debug layer unavailable). Baseorigin/mainf365f125.compile_dxil,offscreen_check,native_compute_ir_dump,native_pixel_ir_dump, andstartup_indirect_draw_indexed(compilingsrc/startup_stubs/native_mesh86.inl) in both Debug (dev) and Release (release) with zero warnings on edited lines.ctest --preset pr --no-tests=error -R "^native_mesh_image_d16_ir$": 1/1 passed.native_mesh_image_d16_ir,startup_compute_d16_sample_srv_controls,native_direct_mesh,native_direct_container, plus existing WARP & RTX 5080 D16 readbacks): all passed.tests/bidi_controls_check.py,tests/docs_links_check.py,git diff --check origin/main..HEAD: all clean.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:23:28Z.
Review: APPROVED
Reviewed
43c061f3(draft) by reading the diff; not built or run.Verdict: approve. D16 packing matches the ISA, and every path that cannot yet bind a format-checked view stays refused. No MUST.
m86census onf365f125. Offline, the 609 should mostly move, but at run time a mesh D16 heap load still needs a float-exact SRV format (native_mesh86.inl:570). A count of which formats the D16 programs bind would show how many can actually draw.image_result_registers(gfx1013_compute_native.cpp:121) counts 4 registers only for gathers 64, 68, 71, 79 and 87. Those are the only ones the direct lowering accepts (gfx1013_direct_compute.inl:1305), so nothing is undercounted today. A0x40 <= op < 0x60test would stay right if more gathers are added, sinceemit_graphics_loopsnow trusts this count instead of a fixed 4.entry_barycentricscan this PR edits (gfx1013_direct_graphics.inl:1591), so one of them will need a rebase.write_d16_image_result: the channels DMASK selects go into consecutive halves, low half first, with the same RNE helper as the existing D16 sample. Destination overflow is checked before the load. D16 gathers are still refused at decode, so the gather-to-4 rule never meets D16.0x3f0ff,0x7fe00000), refuses DMASK 0 and non-D16 DMASK other than 15, and preserves inactive lanes forvec_countregisters.d16_load_srv) are refused by name at publication, Mesh86 pixel views refuse the kind ("unsupported native Mesh86 SRV shape"), and pixel heap images accept onlytexture_srv.Tests:
native_mesh_image_d16_iris in theprfilter. It covers sparse DMASK packing, destination bounds, inactive lanes, and the compute/pixel/verteximage_load/image_load_mipforms.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:27:31Z.
Review: APPROVED
Re-review on
b447ef5b(rebased on5770f14e: new cache fieldmesh_texture_heap_d16, view kindd16_load_srvafterroot_buffer_uav, image result width in the helper-touch tracking).Verdict: approve.
Census, same capture and method as before (6,685 distinct mesh programs), main
5770f14evs this head:Largest moves: Texture1D heap contract →
unsupported mesh image load dmask187;unsupported image dimension or D16→s_load_dwordx4root mapping 179, →unproven packed mesh signature rows169, →graphics register undefined on an incoming path168, → position mask 56, →v_pack_b32_f16constant source 15.Checked:
view_kind_nameupdated together. The frontend revision is the SHA-256 of these sources, so old cache rows cannot be read with the new layout.image_result_registers(op). (Correction: I first wrote that an overlap check for images and MUBUF changed here; this head does not change one.)Main has since merged #3758 (mesh
image_loadthrough a full table descriptor) next to this code. The rebase will need a fresh census.Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main
5770f14eand this head, both with that fix: 796 moved (the table and list above now show this run), 0 lost, 0 gained.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T22:57:47Z.
Stacked on #3844. This branch now contains #3844's commits, because both PRs rewrite the same mesh image-load path, as noted in review. Please land #3844 first. Once it merges, only this PR's own commits remain in the diff.
cf1c9832merges this PR onto #3844 as updated for main67862ee4. The reviewed commitb447ef5bis unchanged.9ef97598moves the D16 packing into #3844's addressing and descriptor checks for both remapped and bound mesh textures, with a float-exact format gate on both paths. The cache merge keeps main's heap-token binding IDs and appends the D16 entries. The fixtures now expect D16 to be accepted, with updated refusal messages and a D16 mip-load case.25cdcd03replaces an abbreviated function template with an explicit template.native_compute_pack_refusal_checkbuilds the frontend as C++17, which main CI compiles but PR CI does not.Tests, Windows 11 26200 with RTX 5080 and WARP:
ctest --preset pr --no-tests=error -R '^native_mesh_image_(d16|contract)_ir$'passed 2/2.image_load|d16|native_compute_|native_direct_cachepassed 90, with 0 failures and 5 skips. The skips were wave32 fixtures, which WARP's 4-lane waves don't support.X2W_SYNC_MESH_REQUESTS=1.startup_image_load_d16passed on WARP and the RTX 5080. All five compute D16 sample cases matched on the RTX 5080.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:34:08Z.
No longer stacked: #3844 has merged. Merged
main(f3ab02fe) into this branch (67cb41ec), with the D16 changes applied to main's mesh lowering, docs and the two fixtures. The PR diff againstmainnow contains only the D16 work. The PR preset passes 2/2. With the mesh, image-load and D16 filter, Debug passed 91 with 1 failure and 5 skips, and Release passed 88 with 4 failures and 5 skips. Those failures also fail on cleanmain:native_mesh_entry_registers_ir(fixed in #3909) and the asynchronous WARP allocation fixtures, which pass withX2W_SYNC_MESH_REQUESTS=1. The skips are WARP's 4-lane waves. The D16 readbacks pass on WARP and the RTX 5080.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:38:18Z.
Marked Ready for review now that #3844 has merged and this branch no longer depends on it. This keeps us within 5 non-draft PRs per #3514.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T02:18:10Z.
Review: APPROVED
Independently reviewed
c21baf70. D16 loads use packed result widths at EXEC joins, the Mesh86 binder requires float-exact formats, and the native cache key fingerprints the changed source and serializer. On MSVC Debug, Windows 11 build 26300, ctest --preset dev --no-tests=error -j 1 covered native_mesh_image_(d16|contract)ir, native_direct_mesh, native_mesh_entry_registers_ir, native_direct_cache(key_)?controls and startup_compute_d16_sample_srv_(controls|warp|hardware). Eight passed, including the RTX 4060 Laptop (616.56) sample regression, and WARP reported capability skip 77 for the wave32 sample. The source-built Mesh86 evidence here is IR and binding-contract validation. Changing the high-half shift from 16 to 17 failed the D16 fixture; the restored head passed. The former mesh-entry CI failure also passed after the baseline update.