Repository navigation
feat(shader): implement the packed MIMG pck2 and pck4 variants - #1314
ebosido444-ai wants to merge 1 commit into
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
… shared lines boykopovar#1372 adds its test after the vop1 decode tests and boykopovar#1314 its debt entry after s_setkill, the places where this branch added its own. The wave control decode test now precedes the vop1 decode tests and the s_sethalt entry follows sceRtcParseDateTime, so either pull request can merge first without a conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared lines boykopovar#1372 adds its test after the vop1 decode tests and boykopovar#1314 its debt entry after s_setkill, the places where this branch added its own. The wave control decode test now precedes the vop1 decode tests and the s_sethalt entry follows sceRtcParseDateTime, so either pull request can merge first without a conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I measured these opcodes on RDNA2 hardware with the HW oracle (gfx1035), encoded raw because LLVM rejects them for both gfx1013 and gfx1035:
On this hardware the ISA XML entries are not working packed loads and stores. The PR returns and writes texel data, which looks plausible but doesn't match the hardware, and the test only checks decode and the IR shape. With the measured behaviour, the right handling stays what |
|
Silicon settles it — accepting the close. The HW-oracle rows are exactly the class of evidence the #843 rule exists for: the generated ISA tables and our widening implied functional packed variants, and the hardware answers with zeros and unwritten texels (with |
|
Correction to my measurement above: the loads aren't no-ops. I only tried data masks 0x3 and 0xf. With DMASK 0x1, |
What
Implements the eight packed MIMG opcodes that #1214 identified as a hidden gap:
image_load_pck2,image_load_pck4,image_load_mip_pck2,image_load_mip_pck4,image_store_pck2,image_store_pck4,image_store_mip_pck2,image_store_mip_pck4(MIMG opcodes 112/113, 115/116, 118/119, 121/122). Until now each threwunsupported MIMG opcodeat decode while #942'sOPCODE_VARIANTSaliases counted them as decoded via the base*_PCKopcodes.Sources (numbers and semantics, all generated from AMD's machine-readable ISA):
amdgpu_isa_rdna2.xml(gpuopen.com/machine-readable-isa, schema 1.1.1): the opcode numbers and the descriptions, verbatim —IMAGE_LOAD_PCK2"Load 2 horizontal elements from the largest miplevel in an image surface... 8- and 16-bit components are zero-extended. The format specified in the resource descriptor is ignored. Illegal for element sizes greater than 64 bits.";IMAGE_LOAD_PCK4the same with 4 elements and a 32-bit element cap; theMIPforms take "a user-specified miplevel"; the stores write "already packed" texel data ("The texel data is already packed and the format specified in the resource descriptor is ignored").generated/rdna2/opcodes.h(kImageLoadPck2Mimg = 112...kImageStoreMipPck4Mimg = 122) and tinygradautogen/amd/rdna2/enum.py(IMAGE_LOAD_PCK2 = 112 ... IMAGE_STORE_MIP_PCK4 = 122) agree with each other and with the tables quoted in fix(tools): stop counting IMAGE_*_PCK2/PCK4 as decoded instructions #1214.image_load_pck/image_store_pck, semantics measured on RDNA2 hardware, gfx1035: raw texel dwords,dmaskbit i selects texel dword i), widened exactly as this family requires: the opcode, neverdmask, selects the variant and its fixed two-dword (dmask 0x3) or four-dword (dmask 0xf) packed window; the mip forms take one more address component likeimage_load_mip_pck;MemoryInfo::imagePackedmarks the access and the existingPackedImageTexel/PackedStoreTexelemission unpacks the packed format across the window dwords (shadPS4'svideo_corepacked-format unpacking is that same base path). fix(tools): count packed MIMG variants as decoded shader instructions #942 conflated the variant width withdmask; this PR separates them.Exact-or-throw (the #843 provenance rule): the one thing the ISA tables do not settle —
dmasksub-windows and the element-to-dword layout for elements above 32 bits — throws (MIMG pck2 and pck4 variants require a full data mask,RdnaImageOpDecoder.cpp) and is recorded in TechnicalDebt marked "unverified on hardware". Multisampled rejection and the D16 ban mirror the base PCK family exactly (image_store_pck2/pck4stay accepted on multisampled dimensions, asimage_store_pckis).Compat payoff: shaders using packed-format 2-/4-element surface reads and writes now translate instead of failing at decode — the hidden eight-op gap #1214 traced to
RdnaImageOpDecoder.cpphaving no entries for 112–122.Tested
Windows 11, w64devkit g++ (GCC 15), standalone decode+translate driver following the
core/libs/testspattern (ImageMsaaLoad.cpp):Built clean,
out_pck.exeexited 0. The newimage_pck_variantsctest (core/libs/tests/ImagePckVariants.cpp, registered likeimage_msaa_load) checks for all eight opcodes: opcode/RdnaOpcode/IsImageOpcodemapping, the fixed 2-/4-dword widths (dataComponents,dataDwordCount), the extra address component on the mip forms,imagePacked/imageHasMip/dataDwords/dmaskin the emittedImageRead/ImageWriteMemoryInfo throughimageLoad/imageStore, and rejection of sub-windowdmask, multisampled dimensions (for 112/113/115/116/121/122, mirroring the base family) and D16 (for all eight).python3 tools/check_conventions.py --base origin/main— "All conventions checks passed."Progress
python3 tools/progress.py: shaders 1139/1166 (97.68%) before and after — unchanged, because #942'sOPCODE_VARIANTSaliases intools/progress.pyalready credit these eight ISA names to the base*_PCKenum entries (the counting bug #1214 fixes). With this PR the credit is real: the eight new enum names map 1:1 ontoIMAGE_LOAD_PCK2...IMAGE_STORE_MIP_PCK4, so after #1214 removes the four aliases its 1131/1166 baseline becomes 1139/1166 (+8 genuinely decoded ops).tools/progress.pyis intentionally untouched here — one topic per PR.Checklist
main; no other open PR implements the same functions (all 275 open PR diffs scanned forPck2|Pck4|ImageLoadPck|112u|113u; the only hits aretools/progress.pycounting fixes in fix(tools): stop counting IMAGE_*_PCK2/PCK4 as decoded instructions #1214/test(shader): cover image load and store by2 and by4 variants and count as tested #1049/test(shader): add regression test for ImageGather4h and map packed gather variants #1053 and unrelated binary constants)NotImplemented_nid_no_patch); the exact-or-throw line and its assumption are listed in TechnicalDebt marked "unverified on hardware".mdfiles or images added to the repository (only the test and the TechnicalDebt entry)