Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

This is not currently possible in WGSL. You would have manually write the conversions from some base type (e.g. array<u32>) to the various types you need. Example:

@group(0) @binding(0)
var<storage> buf : array<u32>

// idx is based on vec4s
read_vec4f(idx : u32) -> vec4f {
  let addr = idx * 4;
  let x = buf[addr];
  let y = buf[addr + 1];
  let z = buf[addr + 2];
  let w = buf[addr + 3];
  return vecf(x,y,z,w);
}

There is certainly desire for more fully featured pointers, but that won't make the initial release.

Replies: 2 comments

Comment options

greggman
Mar 23, 2023
Maintainer Author

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by greggman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants