Does Vulkan support local subgroup memory sharing and manipulation?

1.6k Views Asked by At

In OpenCL I could use __local whenever I wanted to manipulate subgroup memory. Analogically CUDA has __shared__ keyword. Does Vulkan have something equivalent? I cannot see anything in the subgroup tutorial https://www.khronos.org/blog/vulkan-subgroup-tutorial although I do see that they mention shared memory, but they never actually explain how to initialize it.

1

There are 1 best solutions below

3
On BEST ANSWER

Vulkan supports shared buffers. They are better described here

https://www.khronos.org/opengl/wiki/Compute_Shader#Shared_variables

An example of usage might look as follows

layout (local_size_x = 32) in;

layout(std430, set = 0, binding = 1) buffer SomeBuffer{
    int some_ints[];
};

shared int[32] shared_ints;

void main(){
   shared_ints[gl_LocalInvocationID.x] = some_ints[gl_GlobalInvocationID.x];
}