Repository navigation
Conversation
xcl-dev#3500 collapses an S# waterfall loop (v_readfirstlane s[sb..sb+3] from v[vb..vb+3], compare, s_and_saveexec, MIMG, s_xor exec) into one pass over a non-uniform heap sampler. It drops the four v_readfirstlane writes and maps the MIMG to v[vb+3] for S# word 3 only, but the emulated explicit-LOD gather (mimg_gather4_lod, image_gather4_l*) also reads S# words 0-2 (address modes, FORCE_UNORMALIZED, LOD bias, min/max LOD, mip filter) and still took them from s[sb..sb+2], which are then never written: stale or unrelated values per lane. The collapse now records the S# base v[vb] and every S# word read of a MIMG goes through Lw::mimg_sword, which takes v[vb+k] for a collapsed waterfall and s[ssamp+k] otherwise. The compact form's block key now includes that base too: the MIMG's words do not name vb, so two collapsed waterfalls over different VGPRs (or a collapsed and an uncollapsed one) with the same MIMG words could share one lowering. XCL_WATERFALL_LANE_SWORDS=0 instead leaves waterfalls whose body has an image_gather4* uncollapsed (the other correct form); XCL_WATERFALL_COLLAPSE=0 still collapses none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review (head 0324e7c, diff read, not a merge-check; checks red):
Fine: by reading, the fix is right. Main maps a collapsed MIMG to v[vb+3] for word 3 only, while AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: AI-written and posted by Foniass without a human check of each point. |
|
test report (not a merge-check; requested AMD test of #3663) base: df0cfef |
Requested by Prime
#3500 collapses a sampler (S#) waterfall loop into one pass where each lane reads its own sampler from v[vb..vb+3]. It removes the four
v_readfirstlanewrites to s[sb..sb+3] and points the MIMG at v[vb+3] for S# word 3 only. The emulated explicit-LOD gather (image_gather4_l*,mimg_gather4_lod) also reads S# words 0-2 (address modes, FORCE_UNORMALIZED, LOD bias, min/max LOD, mip filter), and it still took them from s[sb..sb+2]. After the collapse nothing writes those SGPRs, so each lane got stale or unrelated values. This change makes every S# word read of a MIMG in a collapsed waterfall come from the lane's own v[vb+k].Related: #3643 also changes
waterfall::collapseand thecompact.rsblock key for collapsed waterfalls; whichever lands second needs a rebase, and its 4-dword collapse should then record the S# base. #3621 keys translations onXCL_WATERFALL_COLLAPSE; the newXCL_WATERFALL_LANE_SWORDSwould need the same tag. #3298 adds an explicit-LOD comparison sample that reads S# words 0-2; if both land, those reads should go throughmimg_swordtoo.What is in it
crates/xcl/src/gpu/dxil/waterfall.rs:collapsenow maps each MIMG to the S# base v[vb] instead of v[vb+3]. WithXCL_WATERFALL_LANE_SWORDS=0, a loop whose body has animage_gather4*is not collapsed. Two tests: the gather4 loop collapses only with per-lane S# words, and a collapsedimage_gather4_ltranslates the same whichever (dead) SGPRs the waterfall used.crates/xcl/src/gpu/dxil/lower_image.rs:mimg_sword(pc, ssamp, k)reads S# word k from v[vb+k] for a collapsed waterfall and from s[ssamp+k] otherwise.mimg_s3andmimg_gather4_loduse it.crates/xcl/src/gpu/dxil/compact.rs: the block key includes the S# base, since the MIMG's words do not name it. Two collapsed waterfalls over different VGPRs could otherwise share one lowering.crates/xcl/src/gpu/dxil/lower.rs: doc comment onwaterfall_ssamp.Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnupasses. The test suite was not run on this exact branch.Regression run
Not tested
scripts/smoke.ps1on this branch; AMD.Switches
XCL_WATERFALL_LANE_SWORDS, default on.=0leaves sampler waterfalls whose body has animage_gather4*uncollapsed (the loop runs as on the console).XCL_WATERFALL_COLLAPSE=0still collapses none. LikeXCL_WATERFALL_COLLAPSEon main, it is not part of the translation cache key, so clear the cache when changing it.AI use
🤖 Generated with Claude Code