feat(shader): store through flat and global addresses #390
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/390"
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 boykopovar/AnyPS5. Originally posted by DotDebian on 2026-10-02T17:10:07Z.
What
flat_store_*andglobal_store_*(byte, short, dword, dwordx2/x3/x4) decode and translate onmain, but a store whose segment is not scratch never reaches the GPU:AnalyzeProgramRequirementsthrowswritable FLAT/GLOBAL addresses require GPU ownership tracking, andStoreAddresshas no emitter for a guest address.Since
21cb5676(stores through GPU-selected V#s) the BDA page table has that tracking: a write lookup that needsWritepermission, and a set of written pages the host marks GPU-written once the work completed. This PR sends FLAT and GLOBAL stores through it.StoreAddressemits aFlat/Globalstore with the newEmitBdaStore, on the address the loads already form (GuestAddress: 64-bit vector address, or scalar base + vector offset, plus the immediate), under the instruction's EXEC bit.get_bda_write_pointerlookup and one store, the codeEmitBdaWritealready had (now shared asEmitBdaStoreAt). Byte and short stores, and a dword store to an unaligned address, store each byte through its own lookup, so a store may straddle two ranges like the byte path of the loads.EmitBdaWriteitself (V# stores) is unchanged: an unaligned V# store still faults.ResourceTrackersetsbdaWritesfor an address store, which is what defines the write lookup andnote_bda_write.The rules of the write path are unchanged and apply as they are: a store lands only in a writable registered range the host imported in place; into a read-only range, a mirror or a copy it is refused and reported as a BDA fault (
Permission).Not part of this PR: the FLAT/GLOBAL atomics and
global_store_dword_addtid(stillFLAT opcode is not supported). They need this store path first.Tested
Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5080 (32-wide subgroups),
ctestfrom PowerShell: 109/109 pass.New test
agc_driver_flat_store(tests/execution/FlatStore.cpp): a 64-thread compute program runs on a real Vulkan device against a 64 KiB registered guest range, as wave32 and as wave64, and the whole first 8 KiB of the range are compared with a CPU reference. It coversglobal_store_dwordwith a scalar base and a vector offset,flat_store_dwordandglobal_store_dwordwith a 64-bit vector address, negative immediates,global_store_byte,global_store_short, a dword store to an unaligned address,dwordx2/x3/x4, aglobal_load_dwordof a dword stored by the same thread, and a store underv_cmpx_gt_u32(threads outside EXEC must not store). A second range registered read-only takes the same program and must stay unchanged.On
mainthe test fails withShaderRecompiler::Recompile: writable FLAT/GLOBAL addresses require GPU ownership tracking. With the EXEC gate removed from the new emitter it fails on the masked threads.Not tested: Linux (the test allocates with
std::aligned_allocthere, astests/Recorder.cppdoes, and has not been run on lavapipe or RADV), any title, stages other than compute, a host with 64-wide subgroups (wave64 ran as two lanes per invocation). The test only checks that the read-only range is unchanged; the fault itself is reported by the recorder on stderr (deferred write-back failed) and is not asserted.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:38:00Z.
Thanks for this, and sorry it sat without a comment for a while. I reviewed it as part of #491, which carries this commit unchanged: flat and global stores go through the BDA write path, and read-only, unmapped and misaligned addresses are reported instead of written.
agc_driver_flat_storepasses on my NVIDIA machine on current main, and fails on main's code.Since it adds a new guest write path, I'll run it (with #491 on top) through my PPSA21564 test runs and merge it first if they pass. The one red CI job on this head is Linux
agc_driver_vopc_compare, the f16 compare flake on llvmpipe that every PR hit at the time, not this change.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T05:03:46Z.
Thanks for this one. #491 (adriadam10) carries your commit rebased onto current main as
be866e4, the same patch with your authorship, and #491, #495 and #506 build on it. Merging this branch at673401band then #491 conflicts inResourceTracker.cpp,SpirvBda.hppandSpirvBdaRead.cpp, so to keep things moving I've merged #491, which brings in your commit as it is, and I'm closing this PR as included there.I gated
be866e4on PPSA21564 together with #491, #495 and #506: no visual or FPS change, and the full ctest passes. If anything in your branch isn't inbe866e4, let me know and we can follow up.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T15:38:58Z.
@DotDebian heads-up on
agc_driver_flat_store(yourFlatStore.cpp, which landed on main through #491): it takes 83 s on main's Linux CI, against ctest's 120 s timeout. Cold on CI's lavapipe (Ubuntu Mesa 25.2.8, LLVM 20, no shader cache) it took 250 s here. The cost is LLVM compiling the BDA accesses, and the test compiles its kernel three times (wave32, wave64, read-only). One of my tests from the same family,flat_cache_bits, sat at 113 s on main and timed out on other people's PRs (#545 #593 #668 #672). This one is next in line.I'm trimming my own ones the same way: #677 (fewer BDA ops), #688 and #689 (split by cost, opcodes and HW rows kept). Since this test came in through my PR, I'm happy to do the same for
FlatStoreunless you'd rather handle it yourself. Let me know.Pull request closed