Repository navigation
feat(shader): implement image_sample_cd/_g16 variants and fix a16 gradient layout - #475
Conversation
Progress report (ebf29f8 → 559aeac)📈 GPU shader instructions: 89.37% (+2.06%, +24 implemented instructions) ✅ 24 implemented
|
|
Thanks, the per-quad LOD for _cd and the a16 gradient layout are great finds, and the hardware captures make the layout easy to follow. One problem with the lane read for _cd: SpirvAnalysis.cpp treats every ReadLane as a wave-uniform source (UniformSource), because v_readlane takes its lane from an SGPR. Here the lane differs per quad, and in the two-lane emission (a wave64 compute program on a host with 32-wide subgroups, state.laneCount == 2 in SpirvEmitter.cpp) SpirvFlowEmitter reuses the first half's result for every value in sharedLaneValues, so lanes 32 to 63 would sample with the gradients of the quads in lanes 0 to 31. ImageSampleDerivatives.cpp only runs wave32, so it can't catch this. Reading the gradients through a lane-varying shuffle that SpirvAnalysis does not count as uniform (or a small dedicated quad-read op) would fix it, and a wave64 compute case in the test would cover it. Also, since #389 merged, the branch conflicts with main in RdnaImageOpDecoder.cpp (the new image_sample_d_cl_o row sits next to image_sample_cd), so it needs a rebase. |
6acd319 to
d73164a
Compare
|
Thanks, you're right about
Passes on RADV, local lavapipe and CI's lavapipe. One limit: this RADV still reports 64-wide subgroups even with |
image_sample_cd takes its derivatives in the image_sample_d address layout; only the hardware LOD selection differs (one LOD per quad instead of per pixel). The decoder refused it. It now samples with the given gradients per lane, which matches whenever the lanes of a quad pass equal derivatives. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…dient layout Co-Authored-By: Claude <noreply@anthropic.com>
ReadLane counts as a wave-uniform source, so the two-lane wave64 path shared the first half's gradients with lanes 32 to 63. The test also runs every case as wave64 with different quads in the upper half. Co-Authored-By: Claude <noreply@anthropic.com>
d73164a to
559aeac
Compare
|
Rebased on current main (after #581). The address-layout loop now advances by |
|
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.
|
|
Thanks, and sorry I didn't come back to this after your fix on the 4th. The rebase onto #581 looks right too: the bias component still gets its own dword under a16 ( PPSA21564 has no |
|
Gated on PPSA21564: no visual or FPS change. |
What
Found by the ISA sweep: 24 MIMG sample opcodes were refused, and the existing derivative path read the wrong address dwords when
a16is set.image_sample_cd*(0x68-0x6f) andimage_sample_{c_}d*_g16/image_sample_{c_}cd*_g16(0xa2-0xbb, 0xe8-0xef) are now decoded and translated (_cl,_oandc_variants included).a16,image_sample_dpacked the gradients as 16-bit. On gfx10,a16only packs the coordinates (and bias/LOD/clamp): the gradients stay 32-bit unless the opcode is_g16. For example, 2Dimage_sample_d a16is 4 gradient dwords + 1 coordinate dword, not 3 dwords. Before this fix, every such sample returned 0 on hardware-correct inputs._g16packs two gradients per dword, and each direction starts a new dword. 1D isdsdh | dsdv | s. 3D isdsdh,dtdh | drdh,pad | dsdv,dtdv | drdv,pad | s | t | r._cdpasses its gradients in the same layout as_d. The hardware computes one LOD per quad, from the gradients of the quad's first active lane. The translation reads the gradient dwords from that lane (ReadLanewithquad base + ctz(EXEC bits of the quad)), then samples with them.G16in the address flags, soGetRdnaImageAddressComponentLayoutstays a function of the flags alone.Behaviour measured on HW (RDNA2 iGPU, raw kernels)
Setup: a single-level R32F texture whose texel value is
x + 100y + 1000z, a sampler with mag = point and min = linear, and coordinates at a quarter texel. The returned value shows which dwords were read as coordinates, and its fraction (.25or.0) gives the sign of the LOD.a16gradients" layout returns 0, and so does the "no padding"_g16layout._cd: if only one lane of a quad has large gradients, the whole quad minifies only when that lane is the quad's lane 0. With lane 0 off in EXEC, the quad's next active lane decides.Builds on #395, which removes the
_cdrefusal (its commit is included here; the conflict on the same lines is resolved in this branch). This PR keeps that change and adds the per-quad LOD.Tested
Arch Linux, Radeon 660M. New execution test
ImageSampleDerivatives: 24 sample variants over 1D/2D/3D textures, expected values captured on hardware. It passes on RADV, lavapipe (Mesa 26) and the CI's lavapipe (Mesa 25.2.8). The two EXEC-masked_cdcases are skipped when the host subgroup is smaller than 32 (lavapipe), as in the other cross-lane tests.The test fails without each piece of the fix:
a16gradients;_g16without per-direction padding;_cdtreated as_d;_cdreading lane 0 of the quad instead of the first active lane (RADV).ctest(Release): everything passes exceptagc_driver_pixel_helper_laneson local RADV, which also fails onmain.The
_clvariants decode with the same layout. Their execution needs #388 (MinLod capability), so the test does not use them.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)