Repository navigation
shader: lower direct D16 image loads (Part of #3703) - #3836
Conversation
lukaslw-lab
left a comment
There was a problem hiding this comment.
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.
- SHOULD Run a before/after
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. - NIT
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. - NIT #3831 rewrites the
entry_barycentricscan this PR edits (gfx1013_direct_graphics.inl:1591), so one of them will need a rebase. - Checked, no finding:
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.- The mesh Texture1D load now masks out the DMASK and D16 bits (
0x3f0ff,0x7fe00000), refuses DMASK 0 and non-D16 DMASK other than 15, and preserves inactive lanes forvec_countregisters. - Fail-closed elsewhere: bound compute loads (
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_ir is in the pr filter. It covers sparse DMASK packing, destination bounds, inactive lanes, and the compute/pixel/vertex image_load/image_load_mip forms.
068c41c to
b447ef5
Compare
There was a problem hiding this comment.
Re-review on b447ef5b (rebased on 5770f14e: new cache field mesh_texture_heap_d16, view kind d16_load_srv after root_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 5770f14e vs this head:
| Programs | |
|---|---|
| Translate, main / with this PR | 1,047 / 1,047 |
| Lost / gained | 0 / 0 |
| First refusal moved | 796 |
Largest moves: Texture1D heap contract → unsupported mesh image load dmask 187; unsupported image dimension or D16 → s_load_dwordx4 root mapping 179, → unproven packed mesh signature rows 169, → graphics register undefined on an incoming path 168, → position mask 56, → v_pack_b32_f16 constant source 15.
Checked:
- The cache tuple grows to 22 with the visitor, the reader's kind bound and
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. - The helper-touch tracking in the graphics frontend now uses
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_load through 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 5770f14e and this head, both with that fix: 796 moved (the table and list above now show this run), 0 lost, 0 gained.
AI-assisted.
Share the table and remapped Texture1D paths across level-zero and mip loads. Preserve the separate full-descriptor heap path and use the merged Mesh86 table format validator.
A seeded destination now preserves its incoming value when EXEC excludes the lane. Assert that the selected value reaches the export and keep a refusal for a destination with no incoming value.
Keep the current descriptor-token and image-field cache entries, and append the D16 load binding without changing existing binding values. The mesh contract is reconciled separately.
Use the packed register width and the existing address, descriptor and EXEC rules for D16 mesh loads. Bind table loads as format-aware D16 SRVs and keep the float-exact gate for remapped Texture1D loads. Cover mip addressing, packed writes and refusal diagnostics.
Use an explicit function template for the output writer so the native compute pack refusal frontend can build in C++17. Remove the unused C++20 bit header.
|
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.
Tests, Windows 11 26200 with RTX 5080 and WARP:
|
Keep the D16 delta on top of the merged mesh image contract and preserve the current mesh and pixel lowering paths.
|
No longer stacked: #3844 has merged. Merged |
R0Y00
left a comment
There was a problem hiding this comment.
Independently reviewed c21baf7. 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.
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.