How to pass a reference to storage in WGSL?

129 views Asked by At

In WGSL how can I pass a reference to a storage to a function ?

My reduced example looks like this:

@group(0) @binding(0)  var<storage>             srcData: array<f32>;
@group(0) @binding(1)  var<storage, read_write> dstData: array<f32>;

fn getData(u: array<f32>, i: i32) -> f32 {
    return u[i];
}

fn setData(u: array<f32>, i: i32, value: f32) {
    u[i] = value;
}

fn test(i: i32) -> void {
    setData(dstData, i, getData(srcData, i));
}

where I want to pass a declared storage as a u. However this doesn't seem to work as the compiler tells me: runtime-sized arrays can only be used in the <storage> address space

What's the correct syntax to do this ?

1

There are 1 answers

0
Lenny On BEST ANSWER

So it seems this is currently not possible according to this post. :'(