compute: carry descriptor spills through v_writelane_b32 / v_readlane_b32 #3161
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3161"
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-27T19:17:18Z.
Fixes #3150. Part of #2935. Target branch
main. Follows #2940 (#2950), which lowered numeric SGPR spills through VGPR lanes.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl):v_writelane_b32with a constant lane and a non-numeric scalar source records the source symbol and emits nothing. That covers a descriptor dword, a table or root address, and an unbound value.v_readlane_b32of the same VGPR and constant lane restores the symbol in its destination SGPR and emits nothing.constant32moves fromDirectComputeto file scope so the analysis can use it.native_store_replaygains a--direct-warpmode for the WARP variant of the new test. This touches the same device-creation lines as #3155; I will rebase on whichever lands first.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
main80668b97plus this commit.native_lane_spill_descriptor_hardware(new) passed.v_readlane_b32and load through the refilled descriptor.compile_dxilrefuses five controls:native_lane_spill_descriptor_warpskips (77) on this machine.native_lane_access_hardware,native_wave_request_hardware,native_direct_container, thenative_dpp*tests and thenative_gather*tests pass, 16 tests in all, two of them WARP skips.Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmain80668b97.41 of 2,689 compute requests stopped first at a
v_writelane_b32with "unbound numeric SGPR". With this change, 40 of them pass every spill and stop later:s_or_saveexec_b32image_sample_lzon a 3D image, sampler at s88 (5) or s104 (1)v_permlanex16_b32The last one stops at a
v_fma_f32with an unbound SGPR source.The compiled count stays at 403, and no request that compiled before stops compiling. The requests of one start-up run give the same result: 416 before and after, and the same 41.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T21:12:25Z.
LGTM. The refactoring of
Stateto track lane spills cleanly separates symbolic descriptor tracking from scalar state. The handling in both the analysis pass and direct compute lowering is consistent, and the new test covers the critical edge cases (conflicts, overwrites). Ready to merge.Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T21:49:23Z.
Review: APPROVED
I reviewed
9a8c3478merged overmain2b7ebf18. The merge is clean (treece82c8af) andgit diff --cached --checkis clean.What I traced.
v_writelane_b32records a non-numeric, non-indexed, definition-free SGPR symbol under (VGPR, guest lane) and emits nothing. Any other source erases that key.v_readlane_b32of the same key restores the symbol into its SGPR. At a join, a key whose symbol differs, or is present on only one side, becomesnullopt, and a later readlane of it is refused. Both join orders are handled: thereset()loop covers keys present inin, and theemplace(..., nullopt)loop covers keys present only inafter.read()andwrite()refuse any VGPR access to a register whose before-state holds a spill key. The one exception is the lane write itself (lane_write).read_storageis used only by the readlane/writelane lowering andwrite_active. Every VGPR store goes throughwrite(), soclear_vector_spillsis a second line of defence, not the guard. That matches the PR's note on its third mutation.constant32moved to file scope with the same nine float words, andoperand()now uses it. The emitted constants are unchanged.parseis called withgraphand notgraphics. The only such caller is thedirect_dxilcompute path.What I ran. I built
compile_dxil native_store_replayindevandrelease, then randev: 8/8 hardware tests pass.native_lane_spill_descriptor_hardwarematched all 192 descriptor-spill and numeric-spill words and the guards.release: the new test,native_lane_access_hardwareandnative_direct_containerpass.native_lane_spill_descriptor_warpskips (77) in both presets, so the five compile controls ran but the WARP readback didn't.main2dde49a8, compiling the fixture's positive program refuses it at+0x38: unbound numeric SGPR s32, the first descriptor spill.Mutants. I rebuilt
compile_dxil native_store_replayindevfor each, then ran the new test (WARP for the compile controls, hardware for the readback):!(other->second == value)term)joincontrol compiles)read()symbolic-lane refusal removedvalu)write()symbolic-lane refusal removedoverwrite)has_spillrefusal removedsgpr_selector)emplace(..., nullopt)removed)v_writelane_b32does not erase the keyidentity_spillalso carriesindexed_descriptorwaveReadLaneAtRestored and rebuilt afterwards;
git diff --quietis clean.I then compiled four extra programs built from the test's own helpers.
symbolic VGPR lane read has conflicting incoming values. Under the one-sided-join mutant three of them are still refused, later, asunproven resource descriptor s32, so that mutant moves the refusal but doesn't produce wrong code here.unproven resource descriptor s32). Under the no-erase mutant it compiles, restoring the overwritten descriptor.Non-blocking. "A write to the same lane replaces it" is implemented correctly, but no test pins it. A sixth control in
native_lane_spill_descriptor_check.pywould kill that mutant: a numericv_writelane_b32over a symbolic lane, followed by the refill and the load, expected to be refused. The indexed-descriptor exclusion is likewise unpinned.Verdict: approve on
9a8c3478.Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off. WARP variant skipped (77).
CI:
Build and test on Windowspasses on9a8c3478.This reply was AI-assisted.