add dynamic buffer descriptor support, enhance memory operations, and add compute tests #690
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!690
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/690/head"
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?
@bipinkrish on GitHub · 2026-09-18 03:28 UTC · original
bipinkrish:feat/dynamic-buffer-descriptors→main· +787 −117 · 9 files · 7 commits · closed without mergingThis pull request introduces runtime support for dynamic buffer descriptors and volatile buffer access in the SPIR-V shader backend, along with comprehensive GPU compute test fixtures verifying functionality on native Vulkan hardware.
1. Dynamic Buffer Descriptors
DynamicBufferByteAddressandDynamicBufferGuestAddressto resolve dynamic 4-dword buffer descriptors (V#) loaded into SGPRs at runtime.add_tid: Incorporatesgl_SubgroupInvocationIDinto the index when bit 23 ofdword3is set.swizzle_enabled: Implements cache-line swizzled address arithmetic matchingBufferByteAddressusingindex_stridefromdword3and bit 31 ofdword1.requirements.subgroup_local_invocation_id = trueinSpirvEmitter.cppfor dynamic buffers to ensuregl_SubgroupInvocationIDis properly declared in module interfaces.SpirvEmitter.cppandResourceMaterialization.cpp.2. Memory Operations & BDA Refinements
LoadBdaDword,LoadBdaAddress,StoreBdaDword,StoreBdaSubword) withis_volatileflags, applying SPIR-VMemoryAccessVolatileMaskand device atomic memory barriers.StoreBdaSubwordto handle 16-bit unaligned boundary crossing (split into 8-bit operations) and atomic bitwise RMW updates for byte/halfword operations.renderCompute.cpp.3. Native GPU Compute Tests (
ShaderRecompilerComputeTests.cpp)Added 4 new compute test fixtures running against real Vulkan discrete hardware:
DynamicBufferLoadStore: Tests dynamic descriptor loading (S_BUFFER_LOAD_DWORDX4), 32-bit dynamic load/store (BUFFER_LOAD_DWORD/BUFFER_STORE_DWORD), and subword byte operations (BUFFER_LOAD_UBYTE/BUFFER_STORE_BYTE).DynamicBufferLoadStoreDwordX4: Tests 128-bit 4-component vector dynamic load and store (BUFFER_LOAD_DWORDX4/BUFFER_STORE_DWORDX4).DynamicBufferStoreAddTid: Tests dynamic store withadd_tid = 1across 32 threads, verifying each lane dynamically indexes its record viagl_SubgroupInvocationID.DynamicBufferLoadStoreSwizzle: Tests dynamic load and store withswizzle_enabled = 1andindex_stride, verifying swizzled byte addressing against host buffers.AI usage
This investigation and Implementation for this is done by an AI agent, reviewed and tested manually
@coderabbitai[bot] on GitHub · 2026-09-18 03:42 UTC · original · edited 2026-09-30 07:24 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
8336d170-2a2a-4d3c-b8c9-3d2e04835564📥 Commits
Reviewing files that changed from the base of the PR and between
9cb933c3e4anda1b3eedd0c.📒 Files selected for processing (3)
src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpptests/ShaderRecompilerComputeTests.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough
The change adds
dynamic_bufferandglcmetadata to memory operations. Resource tracking detects dynamic descriptor origins and preserves them as DMA-backed buffers. SPIR-V emission supports dynamic-buffer BDA loads, stores, wide accesses, formatted accesses, and 32-bit atomics. Volatile operations emit barriers. Unsupported dynamic operations fail explicitly. Compute tests cover descriptor addressing,add_tid, swizzling, and wide transfers.DispatchDirectwaits for scheduled command execution.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Feature
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 1.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 56 functions across 8 files. (1 skipped: 1 too large.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -393,6 +397,7 @@ void RenderExecutor::DispatchDirect(uint64_t submit_id, CommandBuffer& buffer,// The removed host fence also ordered read-only dispatches before later writers.ShaderAccessBarrier(vk_buffer, vk::PipelineStageFlagBits::eComputeShader);ResetBindings();m_context.GetCommandScheduler().FlushAndWait();@coderabbitai[bot] on GitHub · 2026-09-18 03:42 UTC · original · edited 2026-09-18 03:59 UTC
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 18986
🤖 get_repo_knowledge executed:
get_repo_knowledge KytyPS5/KytyPS5 /tmp/coderabbit-repo-knowledge/kytyps5-kytyps5-b6cddd0b/architectureLength of output: 6888
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 50371
Synchronize the image-clear fast path. When
TryConsumeComputeImageClearreturns true,TextureCache::ClearImagerecords Vulkan clear work through the activeCommandBuffer;ClearImageFromBuffercalls it before returning true.DispatchDirectthen returns at lines 274-277 without callingFlushAndWait(), so the clear can remain incomplete when the caller continues. Move the wait to the shared successful path or add it before this return.✅ Addressed in commits
de1545etocf51df7@coderabbitai[bot] on GitHub · 2026-09-18 03:42 UTC · original · edited 2026-09-18 03:48 UTC
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppline 301 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 16308
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 50371
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7280
Handle 16-bit stores that cross a dword boundary.
BUFFER_STOREpasses the raw buffer address to the dynamic path, andStoreSubwordforwards it toStoreBdaSubwordwithout an alignment guard. Whenaddress & 3 == 3, the 16-bit mask and value become0xffff << 24; only the low byte fits in the first dword, and no store updates the next dword. Split this case into two byte merges, updating both aligned dwords with separate BDA presence checks.✅ Addressed in commits
de1545etoe94eaed@coderabbitai[bot] on GitHub · 2026-09-18 03:42 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
7a7e8763-f299-4dcd-8f86-fb643a733b31📥 Commits
Reviewing files that changed from the base of the PR and between
104530eafcandb23ee5aa8d.📒 Files selected for processing (7)
src/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@coderabbitai[bot] on GitHub · 2026-09-18 04:08 UTC · original · edited 2026-09-19 08:44 UTC
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppline 271 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Propagate
mem.glcto BDA subword stores.StoreBdaSubwordhas no volatility argument. Dynamic U8 and U16 stores therefore emit non-volatile loads and stores with no device barrier, even whenmem.glcis set. This differs fromStoreBdaDword, which receives and appliesmem.glc.Pass
mem.glcintoStoreBdaSubword. Apply the volatile access mask and device synchronization to its BDA memory operations.Also applies to: 300-301, 315-316
✅ Addressed in commit
ef7a6e5@coderabbitai[bot] on GitHub · 2026-09-18 04:08 UTC · original · edited 2026-09-19 08:44 UTC
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppline 316 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 28189
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 50372
🌐 Web query:
SPIR-V OpAtomicCompareExchange PhysicalStorageBuffer storage class Vulkan physical storage buffer atomics💡 Result:
<search_synthesis>
In Vulkan, you can perform atomic operations, including OpAtomicCompareExchange, on memory accessed via the PhysicalStorageBuffer storage class [1][2]. This is enabled by the SPV_KHR_physical_storage_buffer extension (or its equivalent in later Vulkan core versions) [1][3][4]. Key technical requirements and considerations include: 1. Addressing Model: To use the PhysicalStorageBuffer storage class, the SPIR-V module must use the PhysicalStorageBuffer64 addressing model [1][2]. This requires the PhysicalStorageBufferAddresses capability [1][3]. 2. Atomic Operation Support: The PhysicalStorageBuffer storage class is explicitly included in the list of storage classes that support atomic access in SPIR-V [1][2]. You use standard SPIR-V atomic instructions such as OpAtomicCompareExchange with pointers targeting this storage class [5]. 3. Hardware and Feature Support: The device must support the buffer device address feature (e.g., VkPhysicalDeviceBufferDeviceAddressFeatures::bufferDeviceAddress) [3][6]. 4. Implementation Details: - Atomic operations on PhysicalStorageBuffer pointers are treated similarly to other atomic memory operations in SPIR-V, requiring explicit memory scope (typically Device) and memory semantics (e.g., Acquire, Release, or AcquireRelease) [5][7]. - When generating SPIR-V, the pointer passed to the atomic instruction must be a valid pointer to the PhysicalStorageBuffer storage class [1][3]. If working with raw integer device addresses, you must convert them to a PhysicalStorageBuffer pointer using OpConvertUToPtr before performing the atomic operation [1][8][3]. - Be aware of language-specific or compiler-side issues when handling these pointers, such as ensuring they are treated as valid lvalues if the backend (e.g., SPIRV-Cross for Metal) requires an addressable reference to perform the atomic operation [8].
</search_synthesis>
<source_evidence>
https://github.khronos.org/SPIRV-Registry/extensions/KHR/SPV_KHR_physical_storage_buffer.html This extension adds a new storage class PhysicalStorageBuffer which is similar to StorageBuffer except pointers to the PhysicalStorageBuffer storage class are treated as physical pointer types according to a new addressing model PhysicalStorageBuffer64. This addressing model is a hybrid of logical and physical addressing, with only pointers to PhysicalStorageBuffer storage class being physical, and using 64-bit addresses. It also adds a new capablity PhysicalStorageBufferAddresses and enables a few instructions currently supported for Addresses. ... If the addressing model is not PhysicalStorageBuffer64, then the PhysicalStorageBuffer storage class must not be used. ... Add PhysicalStorageBuffer to the list of storage classes that support atomic access. ... OpVariable must not use a storage class of PhysicalStorageBuffer. ... For variables holding PhysicalStorageBuffer pointers, applying the AliasedPointer decoration on the OpVariable indicates that the PhysicalStorageBuffer pointers are potentially aliased. Applying RestrictPointer is allowed, but has no effect. Variables holding PhysicalStorageBuffer pointers must be decorated as either AliasedPointer or RestrictPointer. ... Add a new row for PhysicalStorageBuffer that is a copy of StorageBuffer. Add PhysicalStorageBuffer everywhere StorageBuffer is used in the "Second Storage Classes" column. ... For the PhysicalStorageBuffer storage class, OpVariable is understood to mean the PhysicalStorageBuffer pointer value(s) stored in the variable. An Aliased PhysicalStorageBuffer pointer stored in a Function variable can potentially alias with other variables in the same function, or with global variables or function parameters. ... | Addressing Model | | Enabling Capabilities | | --- | --- | --- | | 5348 | PhysicalStorageBuffer64 Indicates pointers whose storage classes are PhysicalStorageBuffer are physical pointer types with address width equal to 64 bits, and pointers to all other storage classes are logical. | PhysicalStorageBufferAddresses | ... | Storage Class | | Enabling Capabilities | | --- | --- | --- | | 5349 | PhysicalStorageBuffer Shared externally, readable and writable, visible across all functions in all invocations in all work groups. Graphics storage buffers using physical addressing. | PhysicalStorageBufferAddresses | ... Add PhysicalStorageBuffer to the ... of storage classes for the StorageBuffer16BitAccess, UniformAndStorageBuffer16BitAccess, ... Buffer8BitAccess, and UniformAndStorageBuffer8BitAccess capabilities. ... Modify the OpTypeForwardPointer, OpConvertUToPtr, OpConvertPtrToU, and OpPtrAccessChain instructions to add PhysicalStorageBufferAddresses to their capability lists. ... Modify OpConvertUToPtr to require that the result type must be a physical pointer type. ... Modify OpConvertPtrToU to require that the Pointer operand must have a physical pointer type. ... for physical storage buffer pointers. ... Resolution: Pointers to the PhysicalStorageBuffer storage class don’t quite fit the pre-existing definitions because the pointer is not created by OpVariable, rather it is loaded from memory or generated with OpConvertUToPtr. So we extend the definition of a memory object declaration to include a variable that holds a PhysicalStorageBuffer pointer, and add a way to decorate that the object in the variable is aliased/restrict rather than just the variable itself. https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/SPV_KHR_physical_storage_buffer.asciidoc This extension adds a new storage class *PhysicalStorageBuffer* which is similar to *StorageBuffer* except pointers to the *PhysicalStorageBuffer* storage class are treated as physical pointer types according to a new addressing model *PhysicalStorageBuffer64*. This addressing model is a hybrid of logical and physical addressing, with only pointers to *PhysicalStorageBuffer* storage class being physical, and using 64-bit addresses. It also adds a new capablity *PhysicalStorageBufferAddresses* and enables a few instructions currently supported for *Addresses*. ... pointer type if the <<Storage ... MemoryObjectDeclaration&`#39`;Memory Object Declaration:&`#39`; An *OpVariable*, or an *OpFunctionParameter* of pointer type, or the contents of an *OpVariable* that holds a pointer to *PhysicalStorageBuffer* <<Storage_Class, storage class>> or holds an array of such pointers. ... If the <<Addressing_Model, addressing model>> is not *PhysicalStorageBuffer64*, then the *PhysicalStorageBuffer* <<Storage_Class, storage class>> must not be used. ... Add *PhysicalStorageBuffer* to the list of <<Storage_Class, storage classes>> that support atomic access. ... *OpVariable* must not use a <<Storage_Class, storage class>> of *PhysicalStorageBuffer*. ... If an *OpVariable*&`#39`;s pointee type is a pointer (or array of pointers) in ... *PhysicalStorageBuffer* <<Storage_Class, storage class>>, then the variable must be decorated with exactly one of *AliasedPointer* or *RestrictPointer*. ... Any pointer value whose <<Storage_Class, storage class>> is *PhysicalStorageBuffer* and that points to a matrix or an array of matrices or a row or element of a matrix must be the result of an *OpAccessChain* or *OpPtrAccessChain* instruction whose base is a structure type (or recursively must be the result of a sequence of only access chains from a structure to the final value). Such a pointer must only be used as the &`#39`;Pointer&`#39`; operand to *OpLoad* or *OpStore*. ... For variables holding *PhysicalStorageBuffer* pointers, applying the *AliasedPointer* decoration on the *OpVariable* indicates that the *PhysicalStorageBuffer* pointers are potentially aliased. Applying *RestrictPointer* is allowed, but has no effect. Variables holding *PhysicalStorageBuffer* pointers must be decorated as either *AliasedPointer* or *RestrictPointer*. ... Add a new row for *PhysicalStorageBuffer* that is a copy of *StorageBuffer*. Add *PhysicalStorageBuffer* everywhere *StorageBuffer* is used in the "Second Storage Classes" column. ... For the *PhysicalStorageBuffer* <<Storage_Class, storage class>>, *OpVariable* is understood to mean the *PhysicalStorageBuffer* pointer value(s) stored in the variable. An *Aliased* *PhysicalStorageBuffer* pointer stored in a *Function* variable can potentially alias with other variables in the same function, or with global variables or function parameters. ... 2+^ ... | 5348 | *PhysicalStorageBuffer64* + ... Indicates pointers whose <<Storage_Class, storage classes>> are *PhysicalStorageBuffer* are physical pointer types with address width equal to 64 bits, and pointers to all other <<Storage_Class, storage classes>> are logical. | *PhysicalStorageBufferAddresses* |==== -- ... 3.7 Storage Class ... ~~~~~~~~~~~~~~~~~ -- [options="header"] |==== 2+^| Storage Class ^| Enabling Capabilities | 5349 | *PhysicalStorageBuffer* + ... Shared externally, readable and writable, visible across all functions in all invocations in all work groups. Graphics storage buffers using physical addressing. | *PhysicalStorageBufferAddresses* |==== -- ... Add *PhysicalStorageBuffer* to the list of storage classes for the *StorageBuffer16BitAccess*, *UniformAndStorageBuffer16BitAccess*, *StorageBuffer8BitAccess*, and *UniformAndStorageBuffer8BitAccess* capabilities. ... Modify the *OpTypeForwardPointer*, *OpConve…[truncated] https://docs.vulkan.org/guide/latest/buffer_device_address.html Buffer Device Address :: Vulkan Documentation Project # Buffer Device Address Buffer Device Address allows you to have a pointer to the`VkBuffer` in your shaders. There are many other usages such as Ray Tracing, GPU Side tooling, etc. This will be more of a technical breakdown of how it works, if you looking for a simple "how do I just use this", then please take a look at the Vulkan Samples. ## Extension The original proposal was done with the`VK_EXT_buffer_device_address` extension. Shortly afterwards,`VK_KHR_buffer_device_address` was added, which had some minor feature differences. Starting in Vulkan 1.2 this has become core and it is very widely available on GPUs on every platform. Starting in Vulkan 1.3 it became required, so if you are using Vulkan 1.3, you are guaranteed support. ### Name alias The naming of this`Buffer Device Address` feature will be different depending on where you look. For GLSL, it is`buffer reference`(see GL_EXT_buffer_reference). This is because syntactically it’s used more like a C++ reference than a pointer. For SPIR-V, it is`PhysicalStorageBuffer`(see SPV_KHR_physical_storage_buffer). The name comes from the fact there was a`StorageBuffer` and now it is "Physical". (`Physical` is from "physical addressing" which is a concept in`Kernel` SPIR-V) If you are coming from DirectX, you will know the feature as`GPU virtual address`. ## Vulkan Side From the Vulkan code, the only 3 things you need to do is Enable the`bufferDeviceAddress` feature. (Also the extension if using Vulkan 1.0 or 1.1) Add`VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR` when creating your`VkBuffer`. Add`VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR` when allocating your`VkDeviceMemory`. From here you can use the`vkGetBufferDeviceAddress` call and it will return a`VkDeviceAddress`. This is now your 64-bit pointer to that`VkBuffer` that can be handed down into your shader. For tools, the`vkGetBufferDeviceAddress` function might break assumptions that Vulkan function only return`void` or`VkResult` ## SPIR-V Side If you are using GLSL/HLSL/Slang/etc then the following is all taken care for you! ### Capability The SPIR-V will contain the`OpCapability PhysicalStorageBufferAddresses` instruction that will match up with`VkPhysicalDeviceVulkan12Features::bufferDeviceAddress`(or`VkPhysicalDeviceBufferDeviceAddressFeatures::bufferDeviceAddress`) to let everyone know the device does support this. ### Addressing Model SPIR-V has an Addressing Model that has 3 group of options `Logical`- this is what Vulkan 1.0 uses, it has no concept of pointers `Physical32`/`Physical64`- this for OpenCL `PhysicalStorageBuffer64`- this is what you will use if you are making use of Buffer Device Address ### shaderInt64 Since these`VkDeviceAddress` are represented as 64-bit integer pointers in your shader, you will likely want`shaderInt64` support for your device. Some device migth support`bufferDeviceAddress`, but not`shaderInt64`. The way around this situation is to make everything an`uvec2`(see GL_EXT_buffer_reference_uvec2). ### Alignment See dedicated BDA Alignment chapter. ### Nullptr SPIR-V has a`OpConstantNull`, but that can’t be used with`PhysicalStorageBuffer`. The way around this is to either convert the pointer to an integer with`OpConvertPtrToU` or to a`uvec2` with`OpBitcast`. Vulkan defines the integer value of`0` to be null (as everyone would hopefully expect!). ### Cross stage variables There is still on-going discussion to clarify if/how passing pointers from two stages works (ex. vertex to fragment). The main issue is you may get validation layers errors with the`Location` matching (see https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/5349). The suggestion is to just pass a`uvec2` or`int64` across stages and re-cast it in your consumer stage. ### OpTypeForwardPointer and infinite loops The`OpTypeForwardPointer` is used to forward reference the type of the pointer. This is useful if the app want…[truncated] https://docs.vulkan.org/spec/latest/chapters/descriptors.html Shaders can also access buffers without going through descriptors by using Physical Storage Buffer Access to access them through 64-bit addresses. ... ### Storage Buffer ... A storage buffer (VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) is a descriptor type associated with a buffer resource directly, described in a shader as a structure with various members that load, store, and atomic operations can be performed on. ... Atomic operations can only be performed on members of certain types as defined in the SPIR-V environment appendix. ... ## Physical Storage Buffer Access ... Buffer device addresses can also be used to access buffer memory in a shader, using the `SPV_KHR_physical_storage_buffer` extension or the equivalent `SPV_EXT_physical_storage_buffer` extension and the `PhysicalStorageBuffer` storage class. For example, this value can be stored in a uniform buffer, and the shader can read the value from the uniform buffer and use it to do a dependent read/write to this buffer. All loads, stores, and atomics in a shader through `PhysicalStorageBuffer` pointers must access addresses in the address range of some buffer. GitHub issue 4983 in microsoft/DirectXShaderCompiler (link omitted to avoid creating a cross-reference) ## [SPIR-V] Atomics can&`#39`;t be used with vk::RawBuffer commands ... Due to some limitations with HLSL involving device addressing, we&`#39`;re making heavy use of HLSL&`#39`;s vk::RawBufferLoad and vk::RawBufferStore commands for our bindless rendering architecture. ... However, I&`#39`;m running into an issue where this effectively makes all atomic operations impossible... ... HLSL&`#39`;s current InterlockedCompareExchange function expects a resource value like a RWStructuredBuffer. And there is currently no way to construct a RWStructuredBuffer from a raw vulkan address. ... I&`#39`;m not sure if this is possible, but it would be ideal if we could construct a RWStructuredBuffer from a vulkan raw device address (and also potentially a size in bytes?) and then be able to use that official resource handle for atomic interlocked HLSL intrinsics... ... Or alternatively, perhaps we could add a vk::RawBufferInterlockedCompareExchange function which would act on the raw vulkan device address itself... ... > > > the whole `vk:::RawBuffer` design seems to be riddled with bugs, the `OpAccessChain`s are not being constructed properly for loads/stores, see `#4986` > > > > This seems mostly irrelevant. What does this have to do with atomics? > > In GLSL you can declare a bunch of nested structs and you can perform an `atomicExchange(buffer_reference.memberBInA.memberCInB.myUint, 45)` without a problem. > > With the way `vk::RawBuffer` currently works, you&`#39`;d have to do all the pointer arithmetic to find out the address from the base pointer to feed as an argument ... > The behavior of GLSL is also mostly irrelevant, as it pertains to how glslc compiles to SPIR-V. > > The HLSL programming language is different from GLSL in how atomics work. In HLSL, we have InterlockedCompareExchange, which requires a "resource" type. > > Hence why we either 1) construct such a resource handle from a raw device address, or 2) implement a vk specific intrinsic that works on the raw device address. > > Re pointer arithmetic, again that is unrelated to this issue. I am assuming that users do their own pointer arithmetic (like we do in a simple templated function wrapping vk::RawBuffer commands) ... > So, if I follow the SPIR-V spec right, we&`#39`;d potentially want to emit something roughly like the following: > > // CHECK: addr:%\d+ = OpLoad %ulong > // CHECK-NEXT: newValue:%\d+ = OpLoad %int %variable > // CHECK-NEXT: comparatorValue:%\d+ = OpLoad %int %comparator > // CHECK-NEXT: buf:%\d+ = OpBitcast %_ptr_PhysicalStorageBuffer_int addr > // CHECK-NEXT: result:%\d+ = OpAtomicCompareExchange buf Device AcquireRelease None newValue comparatorValue > // CHECK-NEXT: OpStore %originalValue result > > For the Scope, since this is a raw device address, I&`#39`;d assume "Device" is the right choice here. For shared memory atomics, those already work in SPIR-V though the built-in InterlockedCompareExchange call. > > I think for the "Equal" memory semantics this should be AcquireRelease, since we exchange when the original value equals the comparator. > > For the "Unequal" memory semantics, per spec this can&`#39`;t be Release or AcquireRelease. I think it should be None then? Since at this point we know the exchange isn&`#39`;t going to happen? ... > > The HLSL programming language is different from GLSL in how atomics work. In HLSL, we have InterlockedCompareExchange, which requires a "resource" type. > > Don&`#39`;t care, you can make whatever API you want as long as it emits the correct DXIL or SPIR-V. > > > Re pointer arithmetic, again that is unrelated to this issue. I am assuming that users do their own pointer arithmetic (like we do in a simple templated function wrapping vk::RawBuffer commands) > > Well thats rather painful compared to how transparent…[truncated]Citations:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 30744
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1536
Make BDA subword stores atomic.
Aligned BDA 16-bit stores load one dword, merge the subword, and then perform a plain store. Two invocations can load the same dword and lose one update when they modify different halves.
Use a device-scope compare-exchange loop for this read-modify-write path. Also use it for each byte update produced by an unaligned 16-bit store, because each byte path performs the same dword read-modify-write operation.
PhysicalStorageBufferpointers support this atomic operation.✅ Addressed in commit
ef7a6e5@coderabbitai[bot] on GitHub · 2026-09-18 04:08 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
02c52df6-6c73-4f25-8276-0784b243a693📥 Commits
Reviewing files that changed from the base of the PR and between
b23ee5aa8dandcf51df75a9.📒 Files selected for processing (3)
src/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@francoisatt on GitHub · 2026-09-18 17:34 UTC · original
Tested
cf51df7on Windows (native Vulkan, RTX 5080, full clean build).Full suite: 36/39, no regressions. The three failures are the known SDL link issue (#565), same as on clean main.
Note that no test currently exercises the new dynamic-buffer path on GPU.
If you add a compute fixture that dispatches a dynamic-buffer load/store and checks the readback, I can run it on native Vulkan. Not verified against any title on my side.
@ -237,0 +427,4 @@address = Binary(state, spv::OpIAdd, TypeU32(state), address, ctx.Arg(inst, 3));}return address;}@coderabbitai[bot] on GitHub · 2026-09-19 09:05 UTC · original · edited 2026-09-19 09:27 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14353
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 50372
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 28256
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 50371
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 50371
Preserve descriptor flags in dynamic buffer addresses.
DynamicBufferGuestAddresspasses onlydword1toDynamicBufferByteAddress, which extracts only the stride.ShaderBufferResource::SwizzleEnabled()readsdword1bit 31, andShaderBufferResource::AddTid()readsdword3bit 23. Dynamic descriptors can contain both fields. When swizzle or add-thread addressing applies, the dynamic path can compute a different physical byte address fromBufferByteAddress. Pass the required descriptor fields and apply the same address handling, or reject unsupported dynamic descriptors explicitly.✅ Addressed in commits
a08acadtoa1b3eed@coderabbitai[bot] on GitHub · 2026-09-19 09:05 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
317816e4-d0bd-4046-bf7e-426142940adc📥 Commits
Reviewing files that changed from the base of the PR and between
cf51df75a9and9cb933c3e4.📒 Files selected for processing (3)
src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/frontend/translate/Memory.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@bipinkrish on GitHub · 2026-09-19 09:29 UTC · original
@francoisatt rebased with main and added the test cases you requested
@francoisatt on GitHub · 2026-09-20 08:41 UTC · original
Thanks for adding them. Ran
a1b3eedon Windows (native Vulkan, RTX 5080, driver 596.49, full clean build).All four new cases pass on GPU:
[compute] DynamicBufferLoadStore ok
[compute] DynamicBufferLoadStoreDwordX4 ok
[compute] DynamicBufferStoreAddTid ok
[compute] DynamicBufferLoadStoreSwizzle ok
The full shader_recompiler_compute_tests run completes with no failure.
Full suite: 36/39, the three failures being the known SDL link issue (#565), same as on clean main.
Not verified: other GPU vendors (NVIDIA only).
@DenizSAHIN570 on GitHub · 2026-09-23 19:30 UTC · original
Tested this on Linux with GTA V (PPSA04264): Nobara 44, RX 9070 XT, RADV (Mesa 26.2.2). I saw the Windows/NVIDIA results above, so this is another platform test.
I merged #690 (
a1b3eed) ontoba55ba5(the 2026-09-20 build). It merged cleanly.Before: loading story mode died with
shader resource tracking: hash=0x6a53456e7ef5d1b0 stage=compute pc=0x0000086c GetBufferResource dword 0 is not a valid runtime value.
Tracing it with a local diagnostic, dword 0 comes from Ballot -> CompositeExtractU32x4 -> ... -> ReadFirstLane -> ReadConstBuffer, the same shape as the GTA V chain in #507 (different shader hash).
After: that error is gone and the run goes much further (72 compute shaders compiled in my run, versus 7–29 when it hit the error before).
The next things I hit were separate: a missing DS opcode (0xa0, DS_WRITE_B8_D16_HI), and after implementing that locally, a GPU hang (ErrorDeviceLost) in a compute shader that doesn't use the dynamic path (dma=0, traced with RADV_DEBUG=hang). I don't think that hang is related to this PR.
Not verified: whether the dynamic-descriptor results render correctly. I only checked that the resource-tracking failure is gone. Only tested on RADV.
I used AI when doing this but everything is done on my machine and verified by me.
Pull request closed