-
Hello, Is it possible to create a multidimensional array like this:
I would like to get from wgsl: Thank you in advance for your answers. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
A What you need to do is design a data format which does use a single allocation for the data.
|
Beta Was this translation helpful? Give feedback.
-
Yes, I will use this workaround... |
Beta Was this translation helpful? Give feedback.
A
Vec<Vec<u32>>
is a pointer to a memory allocation containing pointers to memory allocations containingu32
s. You can't copy it directly into a GPU buffer for the same reasonbytemuck
doesn't straightforwardly accept it: it's not a single allocation, and it contains pointers which would be meaningless (or at least unsafe) on the GPU. For the same kind of reason,array<array<u32>>
is not a valid WGSL array type.What you need to do is design a data format which does use a single allocation for the data.
Vec
is the same length) then this is simple: use a singleVec<u32>
, and compute “flattened” indices in it asx + width * y
— the same way you'd acce…