shader: lower v_readlane_b32 and v_writelane_b32 in the direct C++ compute path #2950
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2950"
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 Leyukaka on 2026-11-26T22:54:13Z.
Fixes #2940 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch
cpp-migration.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl):v_readlane_b32 sD, vS, laneis now lowered in direct compute.waveReadLaneAt.v_readfirstlane_b32does.v_writelane_b32 vD, sS, lanewritessSto the selected lane only. It uses the unpredicated register store, so guest EXEC does not apply, as in the RDNA2 ISA description.v_readlane_b32joins the multi-wave64 convergence guard.v_readfirstlane_b32with DPP control or VOP3 modifiers ("readfirstlane modifiers"); they were ignored before. The HLSL profile now namesv_readlane_b32in its refusal ("unsupported HLSL instruction v_readlane_b32") instead of "unsupported opcode".vcc_lo(s106) andvcc_hi(s107) in direct compute.s_mov_b32and the lane reads. A 64-bit read of VCC reads s106:s107. s107 is refused as a wave32v_cndmaskmask.vcc_hirefused. The measured programs refill a spilled VCC pair withv_readlane_b32 vcc_lo, …followed byv_readlane_b32 vcc_hi, …, so refusingvcc_hiwould stop them one instruction later.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
cpp-migrationa990f323plus this commit.native_lane_access_hardwarepassed. It covers two 32-lane wave32 groups, 768 words plus guards, against an independent CPU model:v_writelanewith EXEC narrowed to one lane;vcc_lofeedingv_cndmask_b32, and intovcc_hi;s_mov_b32 vcc_hiread back, and the high word of a wave32 VCC pair copy.native_dpp_quad_*,native_dpp_mirror_hardwareandnative_compute_clearstill pass.Mutation checks, run by hand; each fails the test:
lane ^ 1;v_writelanehonour EXEC;vcc_hias 0 in wave32;Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsbuilt from this branch.v_readlane_b32 vcc_lo) now get past it.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T23:17:04Z.
Review: APPROVED
Review of head
d8a40dc1, tested merged ontocpp-migrationea07313b. It merges cleanly, and CI on the head is green. Approving and merging.Code read:
v_writelane_b32selects only on the lane and ignores EXEC, as in RDNA 2.s107is ordinary scalar data that starts at 0, so a 64-bit read ofvccnow sees the reals107instead of a forced 0.v_cndmask_b32withs107as its mask source is refused.exchange_halves. As you note, the fixture does not cover it.Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release.
ctest --preset release --no-tests=error -R '^native_'gives 38 tests, 37 passed and 1 skipped (77,native_comparison_pso_warp), includingnative_lane_access_hardware.Mutation here: reading
lane ^ 1inv_readlane_b32(physical ^ 1) failsnative_lane_access_hardware. With it restored, it passes.On the VCC change against #2940's plan: allowing
vcc_hifor the spilled-pair refill is the right call in wave32 compute, given thes107handling above.Small nit, same as on #2937:
docs/experiments.mdgains a pointer section, while the folder guide asks for the topic file only. I will close #2940 by hand.AI-assisted; the commands above were run locally.