shader: accept byte-window buffer descriptors for stores in the direct C++ compute path #2967
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2967"
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-27T00:09:31Z.
Fixes #2965 (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): a loaded structured-buffer descriptor is often turned into a raw byte window before a buffer store:& 0xc000ffffclears the stride;s_bfe_u32 ..., 0xe0010, thens_max_u32 ..., 1);| 0x30000000setsOOB_SELECTto 3.The analysis already recognised these edits, but only loads used them (
byte_window_srv). This change does two things:binding()accepts the same byte-window word pattern for abuffer_store_rawthrough a 4-wordraw_buffer_uavwhose word 1 is the cleared stride. It binds the unmodified descriptor as before, astools/startup/gfx2hlsl.pydoes, so the manifest and runtime are unchanged. Buffer atomics, which also bindraw_buffer_uav, keep the strict check, as ingfx2hlsl.py.s_or_b32 x, 0x30000000on a plain loaded word 3 now also yieldsbyte_oob, in addition to the cleared form, asgfx2hlsl.pyaccepts it for stores. The OR forces DW3[29:28] to 3 and touches no other bit. This also letsbyte_window_srvloads use the OR-only form, whichgfx2hlsl.pydoes not lower. It gives the same word as the cleared form, but it is not covered by the new test.The stride proof and descriptor identity checks are unchanged. Out-of-range behaviour is that of the bound raw view; sizing the view to the converted byte count would be runtime work and is not in scope.
Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
cpp-migrationf934df52plus this commit.native_bytewin_store_hardwarepassed. The issue's exact sequence feeds stores of 1, 2, 3 and 4 dwords, fully inside the bound view, in two 32-lane groups. All written words, the unwritten words and the guards matched.native_bytewin_store_controlspassed. Four forms stay refused:s_or_b32with0x20000000;buffer_atomic_addthrough the byte-window descriptor.native_salu64_hardware,native_shift64_hardware,native_lane_access_hardwareandnative_compute_clearstill pass.Mutation checks, run by hand; each fails the controls:
Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests.f934df52and 388 with this commit; none that compiled before stops compiling.f934df52, 119 requests stop first at "non-contiguous resource descriptor". With this commit:AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T00:36:06Z.
Review: APPROVED
Review of head
e14954fd, tested merged ontocpp-migration0b1456ce(after #2964 and #2966). It auto-merges cleanly, and CI on the head is green. Approving and merging.Code read:
raw_buffer_uavstore (buffer_store_raw) whose word 1 is the cleared stride now goes through the same descriptor,zero_stride_word,byte_countandbyte_oobfield chain thatbyte_window_srvloads use. The descriptor-identity and stride proofs are unchanged, and atomics keep the strict check.s_or_b32 x, 0x30000000on a plain word 3 now yieldsbyte_oobtoo. As you note, that also widensbyte_window_srvloads to the OR-only form, which the new test does not cover.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 50 tests, 49 passed and 1 skipped (77,native_comparison_pso_warp), includingnative_bytewin_store_hardwareandnative_bytewin_store_controls.Mutation here: disabling the store byte-window path (
false &&in front ofi.name == "buffer_store_raw") makesnative_bytewin_store_hardwarefail at compile withnative compute +0x4c: non-contiguous resource descriptor, the refusal this PR removes. The controls still pass. With it restored, both pass.Nit: as on your other PRs,
docs/experiments.mdgains a pointer section next to the topic note. I will close #2965 by hand.AI-assisted; the commands above were run locally.