Repository navigation
fix(kyty): lower LDS atomics on private storage to a load and store - #291
Open
relativespace2K wants to merge 1 commit into
Open
relativespace2K wants to merge 1 commit into
relativespace2K wants to merge 1 commit into
Conversation
A pixel or vertex shader that runs a DS atomic keeps its LDS in a Function or Private variable, because those stages have no workgroup storage. The emitter still wrote OpAtomicIAdd and the other OpAtomic* forms against that pointer, and Vulkan allows atomics only on Uniform, Workgroup, Image, StorageBuffer, PhysicalStorageBuffer and TaskPayloadWorkgroupEXT storage. spirv-val refused the module, and a driver may crash or miscompile on it. The atomic is lowered to a load, the operation, and a store: the variable is per invocation, so no other invocation can race with it. The same applies to the 64-bit integer atomics, to the float min/max and increment/decrement helpers that go through AtomicUpdate, and to the masked OR. The workgroup and storage-buffer forms keep their atomic instructions and barriers. Fixes the second kind of simnJS#209 for the stages the fuzzer found it on.
relativespace2K
force-pushed
the
fix/kyty-graphics-lds-atomics
branch
from
November 24, 2026 14:08
af1d7b3 to
c997b1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A pixel or vertex shader that runs an LDS atomic (
ds_add_u32,ds_min_u32, …) keeps its LDS in aFunction/Privatevariable, because those stages have no workgroup storage. The emitter still wroteOpAtomicIAddand the otherOpAtomic*forms against that pointer, and Vulkan allows atomics only onUniform,Workgroup,Image,StorageBuffer,PhysicalStorageBufferandTaskPayloadWorkgroupEXTstorage:spirv-valrefuses the module, and a driver may crash or miscompile on it.The atomic is now lowered to a load, the operation and a store when the LDS variable is private to the invocation, so no other invocation can race with it. This covers the 32-bit integer atomics, the 64-bit integer atomics, the float min/max, increment/decrement and masked-OR helpers that go through
AtomicUpdate. Workgroup and storage-buffer LDS keep their atomic instructions and barriers; compute shaders are unchanged.Tested
New hand-written cases in
kyty_shim_recompiler_robustness:ds_add_u32in a pixel shader andds_min_u32in a vertex shader.On Windows 11 IoT Enterprise LTSC 24H2, Ryzen 5 5600, RX 6800 XT (AMD proprietary 26.10.1, Vulkan 1.4.315), Release with WinLibs GCC 15.2.0 and LLVM 21.1.8, with Khronos validation 1.4.363:
The two failures are pre-existing and unrelated:
kyty_shim_merged_hull_draw(#270) andkyty_shim_wave_split_written_reads(open PR #268); the skip iskyty_shim_rt_corpus.Not done: the one-hour libFuzzer run of the acceptance criteria. This Windows build has no
ANYPS5_KYTY_FUZZERS; the two discovered shapes are now locked by the hand-written cases, which run withspirv-val.tools/check_conventions.py --base origin/AnyKyty,tools/check_kyty_settings.pyandtools/pr_overlap.py --repo simnJS/AnyPS5 --base AnyKyty --branch fix/kyty-graphics-lds-atomicsare clean.Checklist